001package org.hl7.fhir.dstu3.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Mon, Apr 17, 2017 17:38-0400 for FHIR v3.0.1
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Representation of the content produced in a DICOM imaging study. A study comprises a set of series, each of which includes a set of Service-Object Pair Instances (SOP Instances - images or other data) acquired or produced in a common context.  A series is of only one modality (e.g. X-ray, CT, MR, ultrasound), but a study may have multiple series of different modalities.
047 */
048@ResourceDef(name="ImagingStudy", profile="http://hl7.org/fhir/Profile/ImagingStudy")
049public class ImagingStudy extends DomainResource {
050
051    public enum InstanceAvailability {
052        /**
053         * null
054         */
055        ONLINE, 
056        /**
057         * null
058         */
059        OFFLINE, 
060        /**
061         * null
062         */
063        NEARLINE, 
064        /**
065         * null
066         */
067        UNAVAILABLE, 
068        /**
069         * added to help the parsers with the generic types
070         */
071        NULL;
072        public static InstanceAvailability fromCode(String codeString) throws FHIRException {
073            if (codeString == null || "".equals(codeString))
074                return null;
075        if ("ONLINE".equals(codeString))
076          return ONLINE;
077        if ("OFFLINE".equals(codeString))
078          return OFFLINE;
079        if ("NEARLINE".equals(codeString))
080          return NEARLINE;
081        if ("UNAVAILABLE".equals(codeString))
082          return UNAVAILABLE;
083        if (Configuration.isAcceptInvalidEnums())
084          return null;
085        else
086          throw new FHIRException("Unknown InstanceAvailability code '"+codeString+"'");
087        }
088        public String toCode() {
089          switch (this) {
090            case ONLINE: return "ONLINE";
091            case OFFLINE: return "OFFLINE";
092            case NEARLINE: return "NEARLINE";
093            case UNAVAILABLE: return "UNAVAILABLE";
094            default: return "?";
095          }
096        }
097        public String getSystem() {
098          switch (this) {
099            case ONLINE: return "http://dicom.nema.org/resources/ontology/DCM";
100            case OFFLINE: return "http://dicom.nema.org/resources/ontology/DCM";
101            case NEARLINE: return "http://dicom.nema.org/resources/ontology/DCM";
102            case UNAVAILABLE: return "http://dicom.nema.org/resources/ontology/DCM";
103            default: return "?";
104          }
105        }
106        public String getDefinition() {
107          switch (this) {
108            case ONLINE: return "";
109            case OFFLINE: return "";
110            case NEARLINE: return "";
111            case UNAVAILABLE: return "";
112            default: return "?";
113          }
114        }
115        public String getDisplay() {
116          switch (this) {
117            case ONLINE: return "ONLINE";
118            case OFFLINE: return "OFFLINE";
119            case NEARLINE: return "NEARLINE";
120            case UNAVAILABLE: return "UNAVAILABLE";
121            default: return "?";
122          }
123        }
124    }
125
126  public static class InstanceAvailabilityEnumFactory implements EnumFactory<InstanceAvailability> {
127    public InstanceAvailability fromCode(String codeString) throws IllegalArgumentException {
128      if (codeString == null || "".equals(codeString))
129            if (codeString == null || "".equals(codeString))
130                return null;
131        if ("ONLINE".equals(codeString))
132          return InstanceAvailability.ONLINE;
133        if ("OFFLINE".equals(codeString))
134          return InstanceAvailability.OFFLINE;
135        if ("NEARLINE".equals(codeString))
136          return InstanceAvailability.NEARLINE;
137        if ("UNAVAILABLE".equals(codeString))
138          return InstanceAvailability.UNAVAILABLE;
139        throw new IllegalArgumentException("Unknown InstanceAvailability code '"+codeString+"'");
140        }
141        public Enumeration<InstanceAvailability> fromType(Base code) throws FHIRException {
142          if (code == null)
143            return null;
144          if (code.isEmpty())
145            return new Enumeration<InstanceAvailability>(this);
146          String codeString = ((PrimitiveType) code).asStringValue();
147          if (codeString == null || "".equals(codeString))
148            return null;
149        if ("ONLINE".equals(codeString))
150          return new Enumeration<InstanceAvailability>(this, InstanceAvailability.ONLINE);
151        if ("OFFLINE".equals(codeString))
152          return new Enumeration<InstanceAvailability>(this, InstanceAvailability.OFFLINE);
153        if ("NEARLINE".equals(codeString))
154          return new Enumeration<InstanceAvailability>(this, InstanceAvailability.NEARLINE);
155        if ("UNAVAILABLE".equals(codeString))
156          return new Enumeration<InstanceAvailability>(this, InstanceAvailability.UNAVAILABLE);
157        throw new FHIRException("Unknown InstanceAvailability code '"+codeString+"'");
158        }
159    public String toCode(InstanceAvailability code) {
160      if (code == InstanceAvailability.ONLINE)
161        return "ONLINE";
162      if (code == InstanceAvailability.OFFLINE)
163        return "OFFLINE";
164      if (code == InstanceAvailability.NEARLINE)
165        return "NEARLINE";
166      if (code == InstanceAvailability.UNAVAILABLE)
167        return "UNAVAILABLE";
168      return "?";
169      }
170    public String toSystem(InstanceAvailability code) {
171      return code.getSystem();
172      }
173    }
174
175    @Block()
176    public static class ImagingStudySeriesComponent extends BackboneElement implements IBaseBackboneElement {
177        /**
178         * Formal identifier for this series.
179         */
180        @Child(name = "uid", type = {OidType.class}, order=1, min=1, max=1, modifier=false, summary=true)
181        @Description(shortDefinition="Formal DICOM identifier for this series", formalDefinition="Formal identifier for this series." )
182        protected OidType uid;
183
184        /**
185         * The numeric identifier of this series in the study.
186         */
187        @Child(name = "number", type = {UnsignedIntType.class}, order=2, min=0, max=1, modifier=false, summary=true)
188        @Description(shortDefinition="Numeric identifier of this series", formalDefinition="The numeric identifier of this series in the study." )
189        protected UnsignedIntType number;
190
191        /**
192         * The modality of this series sequence.
193         */
194        @Child(name = "modality", type = {Coding.class}, order=3, min=1, max=1, modifier=false, summary=true)
195        @Description(shortDefinition="The modality of the instances in the series", formalDefinition="The modality of this series sequence." )
196        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/dicom-cid29")
197        protected Coding modality;
198
199        /**
200         * A description of the series.
201         */
202        @Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
203        @Description(shortDefinition="A short human readable summary of the series", formalDefinition="A description of the series." )
204        protected StringType description;
205
206        /**
207         * Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
208         */
209        @Child(name = "numberOfInstances", type = {UnsignedIntType.class}, order=5, min=0, max=1, modifier=false, summary=true)
210        @Description(shortDefinition="Number of Series Related Instances", formalDefinition="Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present." )
211        protected UnsignedIntType numberOfInstances;
212
213        /**
214         * Availability of series (online, offline or nearline).
215         */
216        @Child(name = "availability", type = {CodeType.class}, order=6, min=0, max=1, modifier=false, summary=true)
217        @Description(shortDefinition="ONLINE | OFFLINE | NEARLINE | UNAVAILABLE", formalDefinition="Availability of series (online, offline or nearline)." )
218        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/instance-availability")
219        protected Enumeration<InstanceAvailability> availability;
220
221        /**
222         * The network service providing access (e.g., query, view, or retrieval) for this series. See implementation notes for information about using DICOM endpoints. A series-level endpoint, if present, has precedence over a study-level endpoint with the same Endpoint.type.
223         */
224        @Child(name = "endpoint", type = {Endpoint.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
225        @Description(shortDefinition="Series access endpoint", formalDefinition="The network service providing access (e.g., query, view, or retrieval) for this series. See implementation notes for information about using DICOM endpoints. A series-level endpoint, if present, has precedence over a study-level endpoint with the same Endpoint.type." )
226        protected List<Reference> endpoint;
227        /**
228         * The actual objects that are the target of the reference (The network service providing access (e.g., query, view, or retrieval) for this series. See implementation notes for information about using DICOM endpoints. A series-level endpoint, if present, has precedence over a study-level endpoint with the same Endpoint.type.)
229         */
230        protected List<Endpoint> endpointTarget;
231
232
233        /**
234         * The anatomic structures examined. See DICOM Part 16 Annex L (http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html) for DICOM to SNOMED-CT mappings. The bodySite may indicate the laterality of body part imaged; if so, it shall be consistent with any content of ImagingStudy.series.laterality.
235         */
236        @Child(name = "bodySite", type = {Coding.class}, order=8, min=0, max=1, modifier=false, summary=true)
237        @Description(shortDefinition="Body part examined", formalDefinition="The anatomic structures examined. See DICOM Part 16 Annex L (http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html) for DICOM to SNOMED-CT mappings. The bodySite may indicate the laterality of body part imaged; if so, it shall be consistent with any content of ImagingStudy.series.laterality." )
238        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/body-site")
239        protected Coding bodySite;
240
241        /**
242         * The laterality of the (possibly paired) anatomic structures examined. E.g., the left knee, both lungs, or unpaired abdomen. If present, shall be consistent with any laterality information indicated in ImagingStudy.series.bodySite.
243         */
244        @Child(name = "laterality", type = {Coding.class}, order=9, min=0, max=1, modifier=false, summary=true)
245        @Description(shortDefinition="Body part laterality", formalDefinition="The laterality of the (possibly paired) anatomic structures examined. E.g., the left knee, both lungs, or unpaired abdomen. If present, shall be consistent with any laterality information indicated in ImagingStudy.series.bodySite." )
246        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/bodysite-laterality")
247        protected Coding laterality;
248
249        /**
250         * The date and time the series was started.
251         */
252        @Child(name = "started", type = {DateTimeType.class}, order=10, min=0, max=1, modifier=false, summary=true)
253        @Description(shortDefinition="When the series started", formalDefinition="The date and time the series was started." )
254        protected DateTimeType started;
255
256        /**
257         * The physician or operator (often the radiology technician)  who performed the series. The performer is recorded at the series level, since each series in a study may be performed by a different practitioner, at different times, and using different devices. A series may be performed by multiple practitioners.
258         */
259        @Child(name = "performer", type = {Practitioner.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
260        @Description(shortDefinition="Who performed the series", formalDefinition="The physician or operator (often the radiology technician)  who performed the series. The performer is recorded at the series level, since each series in a study may be performed by a different practitioner, at different times, and using different devices. A series may be performed by multiple practitioners." )
261        protected List<Reference> performer;
262        /**
263         * The actual objects that are the target of the reference (The physician or operator (often the radiology technician)  who performed the series. The performer is recorded at the series level, since each series in a study may be performed by a different practitioner, at different times, and using different devices. A series may be performed by multiple practitioners.)
264         */
265        protected List<Practitioner> performerTarget;
266
267
268        /**
269         * A single SOP instance within the series, e.g. an image, or presentation state.
270         */
271        @Child(name = "instance", type = {}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
272        @Description(shortDefinition="A single SOP instance from the series", formalDefinition="A single SOP instance within the series, e.g. an image, or presentation state." )
273        protected List<ImagingStudySeriesInstanceComponent> instance;
274
275        private static final long serialVersionUID = -1469376087L;
276
277    /**
278     * Constructor
279     */
280      public ImagingStudySeriesComponent() {
281        super();
282      }
283
284    /**
285     * Constructor
286     */
287      public ImagingStudySeriesComponent(OidType uid, Coding modality) {
288        super();
289        this.uid = uid;
290        this.modality = modality;
291      }
292
293        /**
294         * @return {@link #uid} (Formal identifier for this series.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
295         */
296        public OidType getUidElement() { 
297          if (this.uid == null)
298            if (Configuration.errorOnAutoCreate())
299              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.uid");
300            else if (Configuration.doAutoCreate())
301              this.uid = new OidType(); // bb
302          return this.uid;
303        }
304
305        public boolean hasUidElement() { 
306          return this.uid != null && !this.uid.isEmpty();
307        }
308
309        public boolean hasUid() { 
310          return this.uid != null && !this.uid.isEmpty();
311        }
312
313        /**
314         * @param value {@link #uid} (Formal identifier for this series.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
315         */
316        public ImagingStudySeriesComponent setUidElement(OidType value) { 
317          this.uid = value;
318          return this;
319        }
320
321        /**
322         * @return Formal identifier for this series.
323         */
324        public String getUid() { 
325          return this.uid == null ? null : this.uid.getValue();
326        }
327
328        /**
329         * @param value Formal identifier for this series.
330         */
331        public ImagingStudySeriesComponent setUid(String value) { 
332            if (this.uid == null)
333              this.uid = new OidType();
334            this.uid.setValue(value);
335          return this;
336        }
337
338        /**
339         * @return {@link #number} (The numeric identifier of this series in the study.). This is the underlying object with id, value and extensions. The accessor "getNumber" gives direct access to the value
340         */
341        public UnsignedIntType getNumberElement() { 
342          if (this.number == null)
343            if (Configuration.errorOnAutoCreate())
344              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.number");
345            else if (Configuration.doAutoCreate())
346              this.number = new UnsignedIntType(); // bb
347          return this.number;
348        }
349
350        public boolean hasNumberElement() { 
351          return this.number != null && !this.number.isEmpty();
352        }
353
354        public boolean hasNumber() { 
355          return this.number != null && !this.number.isEmpty();
356        }
357
358        /**
359         * @param value {@link #number} (The numeric identifier of this series in the study.). This is the underlying object with id, value and extensions. The accessor "getNumber" gives direct access to the value
360         */
361        public ImagingStudySeriesComponent setNumberElement(UnsignedIntType value) { 
362          this.number = value;
363          return this;
364        }
365
366        /**
367         * @return The numeric identifier of this series in the study.
368         */
369        public int getNumber() { 
370          return this.number == null || this.number.isEmpty() ? 0 : this.number.getValue();
371        }
372
373        /**
374         * @param value The numeric identifier of this series in the study.
375         */
376        public ImagingStudySeriesComponent setNumber(int value) { 
377            if (this.number == null)
378              this.number = new UnsignedIntType();
379            this.number.setValue(value);
380          return this;
381        }
382
383        /**
384         * @return {@link #modality} (The modality of this series sequence.)
385         */
386        public Coding getModality() { 
387          if (this.modality == null)
388            if (Configuration.errorOnAutoCreate())
389              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.modality");
390            else if (Configuration.doAutoCreate())
391              this.modality = new Coding(); // cc
392          return this.modality;
393        }
394
395        public boolean hasModality() { 
396          return this.modality != null && !this.modality.isEmpty();
397        }
398
399        /**
400         * @param value {@link #modality} (The modality of this series sequence.)
401         */
402        public ImagingStudySeriesComponent setModality(Coding value) { 
403          this.modality = value;
404          return this;
405        }
406
407        /**
408         * @return {@link #description} (A description of the series.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
409         */
410        public StringType getDescriptionElement() { 
411          if (this.description == null)
412            if (Configuration.errorOnAutoCreate())
413              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.description");
414            else if (Configuration.doAutoCreate())
415              this.description = new StringType(); // bb
416          return this.description;
417        }
418
419        public boolean hasDescriptionElement() { 
420          return this.description != null && !this.description.isEmpty();
421        }
422
423        public boolean hasDescription() { 
424          return this.description != null && !this.description.isEmpty();
425        }
426
427        /**
428         * @param value {@link #description} (A description of the series.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
429         */
430        public ImagingStudySeriesComponent setDescriptionElement(StringType value) { 
431          this.description = value;
432          return this;
433        }
434
435        /**
436         * @return A description of the series.
437         */
438        public String getDescription() { 
439          return this.description == null ? null : this.description.getValue();
440        }
441
442        /**
443         * @param value A description of the series.
444         */
445        public ImagingStudySeriesComponent setDescription(String value) { 
446          if (Utilities.noString(value))
447            this.description = null;
448          else {
449            if (this.description == null)
450              this.description = new StringType();
451            this.description.setValue(value);
452          }
453          return this;
454        }
455
456        /**
457         * @return {@link #numberOfInstances} (Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfInstances" gives direct access to the value
458         */
459        public UnsignedIntType getNumberOfInstancesElement() { 
460          if (this.numberOfInstances == null)
461            if (Configuration.errorOnAutoCreate())
462              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.numberOfInstances");
463            else if (Configuration.doAutoCreate())
464              this.numberOfInstances = new UnsignedIntType(); // bb
465          return this.numberOfInstances;
466        }
467
468        public boolean hasNumberOfInstancesElement() { 
469          return this.numberOfInstances != null && !this.numberOfInstances.isEmpty();
470        }
471
472        public boolean hasNumberOfInstances() { 
473          return this.numberOfInstances != null && !this.numberOfInstances.isEmpty();
474        }
475
476        /**
477         * @param value {@link #numberOfInstances} (Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfInstances" gives direct access to the value
478         */
479        public ImagingStudySeriesComponent setNumberOfInstancesElement(UnsignedIntType value) { 
480          this.numberOfInstances = value;
481          return this;
482        }
483
484        /**
485         * @return Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
486         */
487        public int getNumberOfInstances() { 
488          return this.numberOfInstances == null || this.numberOfInstances.isEmpty() ? 0 : this.numberOfInstances.getValue();
489        }
490
491        /**
492         * @param value Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
493         */
494        public ImagingStudySeriesComponent setNumberOfInstances(int value) { 
495            if (this.numberOfInstances == null)
496              this.numberOfInstances = new UnsignedIntType();
497            this.numberOfInstances.setValue(value);
498          return this;
499        }
500
501        /**
502         * @return {@link #availability} (Availability of series (online, offline or nearline).). This is the underlying object with id, value and extensions. The accessor "getAvailability" gives direct access to the value
503         */
504        public Enumeration<InstanceAvailability> getAvailabilityElement() { 
505          if (this.availability == null)
506            if (Configuration.errorOnAutoCreate())
507              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.availability");
508            else if (Configuration.doAutoCreate())
509              this.availability = new Enumeration<InstanceAvailability>(new InstanceAvailabilityEnumFactory()); // bb
510          return this.availability;
511        }
512
513        public boolean hasAvailabilityElement() { 
514          return this.availability != null && !this.availability.isEmpty();
515        }
516
517        public boolean hasAvailability() { 
518          return this.availability != null && !this.availability.isEmpty();
519        }
520
521        /**
522         * @param value {@link #availability} (Availability of series (online, offline or nearline).). This is the underlying object with id, value and extensions. The accessor "getAvailability" gives direct access to the value
523         */
524        public ImagingStudySeriesComponent setAvailabilityElement(Enumeration<InstanceAvailability> value) { 
525          this.availability = value;
526          return this;
527        }
528
529        /**
530         * @return Availability of series (online, offline or nearline).
531         */
532        public InstanceAvailability getAvailability() { 
533          return this.availability == null ? null : this.availability.getValue();
534        }
535
536        /**
537         * @param value Availability of series (online, offline or nearline).
538         */
539        public ImagingStudySeriesComponent setAvailability(InstanceAvailability value) { 
540          if (value == null)
541            this.availability = null;
542          else {
543            if (this.availability == null)
544              this.availability = new Enumeration<InstanceAvailability>(new InstanceAvailabilityEnumFactory());
545            this.availability.setValue(value);
546          }
547          return this;
548        }
549
550        /**
551         * @return {@link #endpoint} (The network service providing access (e.g., query, view, or retrieval) for this series. See implementation notes for information about using DICOM endpoints. A series-level endpoint, if present, has precedence over a study-level endpoint with the same Endpoint.type.)
552         */
553        public List<Reference> getEndpoint() { 
554          if (this.endpoint == null)
555            this.endpoint = new ArrayList<Reference>();
556          return this.endpoint;
557        }
558
559        /**
560         * @return Returns a reference to <code>this</code> for easy method chaining
561         */
562        public ImagingStudySeriesComponent setEndpoint(List<Reference> theEndpoint) { 
563          this.endpoint = theEndpoint;
564          return this;
565        }
566
567        public boolean hasEndpoint() { 
568          if (this.endpoint == null)
569            return false;
570          for (Reference item : this.endpoint)
571            if (!item.isEmpty())
572              return true;
573          return false;
574        }
575
576        public Reference addEndpoint() { //3
577          Reference t = new Reference();
578          if (this.endpoint == null)
579            this.endpoint = new ArrayList<Reference>();
580          this.endpoint.add(t);
581          return t;
582        }
583
584        public ImagingStudySeriesComponent addEndpoint(Reference t) { //3
585          if (t == null)
586            return this;
587          if (this.endpoint == null)
588            this.endpoint = new ArrayList<Reference>();
589          this.endpoint.add(t);
590          return this;
591        }
592
593        /**
594         * @return The first repetition of repeating field {@link #endpoint}, creating it if it does not already exist
595         */
596        public Reference getEndpointFirstRep() { 
597          if (getEndpoint().isEmpty()) {
598            addEndpoint();
599          }
600          return getEndpoint().get(0);
601        }
602
603        /**
604         * @deprecated Use Reference#setResource(IBaseResource) instead
605         */
606        @Deprecated
607        public List<Endpoint> getEndpointTarget() { 
608          if (this.endpointTarget == null)
609            this.endpointTarget = new ArrayList<Endpoint>();
610          return this.endpointTarget;
611        }
612
613        /**
614         * @deprecated Use Reference#setResource(IBaseResource) instead
615         */
616        @Deprecated
617        public Endpoint addEndpointTarget() { 
618          Endpoint r = new Endpoint();
619          if (this.endpointTarget == null)
620            this.endpointTarget = new ArrayList<Endpoint>();
621          this.endpointTarget.add(r);
622          return r;
623        }
624
625        /**
626         * @return {@link #bodySite} (The anatomic structures examined. See DICOM Part 16 Annex L (http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html) for DICOM to SNOMED-CT mappings. The bodySite may indicate the laterality of body part imaged; if so, it shall be consistent with any content of ImagingStudy.series.laterality.)
627         */
628        public Coding getBodySite() { 
629          if (this.bodySite == null)
630            if (Configuration.errorOnAutoCreate())
631              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.bodySite");
632            else if (Configuration.doAutoCreate())
633              this.bodySite = new Coding(); // cc
634          return this.bodySite;
635        }
636
637        public boolean hasBodySite() { 
638          return this.bodySite != null && !this.bodySite.isEmpty();
639        }
640
641        /**
642         * @param value {@link #bodySite} (The anatomic structures examined. See DICOM Part 16 Annex L (http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html) for DICOM to SNOMED-CT mappings. The bodySite may indicate the laterality of body part imaged; if so, it shall be consistent with any content of ImagingStudy.series.laterality.)
643         */
644        public ImagingStudySeriesComponent setBodySite(Coding value) { 
645          this.bodySite = value;
646          return this;
647        }
648
649        /**
650         * @return {@link #laterality} (The laterality of the (possibly paired) anatomic structures examined. E.g., the left knee, both lungs, or unpaired abdomen. If present, shall be consistent with any laterality information indicated in ImagingStudy.series.bodySite.)
651         */
652        public Coding getLaterality() { 
653          if (this.laterality == null)
654            if (Configuration.errorOnAutoCreate())
655              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.laterality");
656            else if (Configuration.doAutoCreate())
657              this.laterality = new Coding(); // cc
658          return this.laterality;
659        }
660
661        public boolean hasLaterality() { 
662          return this.laterality != null && !this.laterality.isEmpty();
663        }
664
665        /**
666         * @param value {@link #laterality} (The laterality of the (possibly paired) anatomic structures examined. E.g., the left knee, both lungs, or unpaired abdomen. If present, shall be consistent with any laterality information indicated in ImagingStudy.series.bodySite.)
667         */
668        public ImagingStudySeriesComponent setLaterality(Coding value) { 
669          this.laterality = value;
670          return this;
671        }
672
673        /**
674         * @return {@link #started} (The date and time the series was started.). This is the underlying object with id, value and extensions. The accessor "getStarted" gives direct access to the value
675         */
676        public DateTimeType getStartedElement() { 
677          if (this.started == null)
678            if (Configuration.errorOnAutoCreate())
679              throw new Error("Attempt to auto-create ImagingStudySeriesComponent.started");
680            else if (Configuration.doAutoCreate())
681              this.started = new DateTimeType(); // bb
682          return this.started;
683        }
684
685        public boolean hasStartedElement() { 
686          return this.started != null && !this.started.isEmpty();
687        }
688
689        public boolean hasStarted() { 
690          return this.started != null && !this.started.isEmpty();
691        }
692
693        /**
694         * @param value {@link #started} (The date and time the series was started.). This is the underlying object with id, value and extensions. The accessor "getStarted" gives direct access to the value
695         */
696        public ImagingStudySeriesComponent setStartedElement(DateTimeType value) { 
697          this.started = value;
698          return this;
699        }
700
701        /**
702         * @return The date and time the series was started.
703         */
704        public Date getStarted() { 
705          return this.started == null ? null : this.started.getValue();
706        }
707
708        /**
709         * @param value The date and time the series was started.
710         */
711        public ImagingStudySeriesComponent setStarted(Date value) { 
712          if (value == null)
713            this.started = null;
714          else {
715            if (this.started == null)
716              this.started = new DateTimeType();
717            this.started.setValue(value);
718          }
719          return this;
720        }
721
722        /**
723         * @return {@link #performer} (The physician or operator (often the radiology technician)  who performed the series. The performer is recorded at the series level, since each series in a study may be performed by a different practitioner, at different times, and using different devices. A series may be performed by multiple practitioners.)
724         */
725        public List<Reference> getPerformer() { 
726          if (this.performer == null)
727            this.performer = new ArrayList<Reference>();
728          return this.performer;
729        }
730
731        /**
732         * @return Returns a reference to <code>this</code> for easy method chaining
733         */
734        public ImagingStudySeriesComponent setPerformer(List<Reference> thePerformer) { 
735          this.performer = thePerformer;
736          return this;
737        }
738
739        public boolean hasPerformer() { 
740          if (this.performer == null)
741            return false;
742          for (Reference item : this.performer)
743            if (!item.isEmpty())
744              return true;
745          return false;
746        }
747
748        public Reference addPerformer() { //3
749          Reference t = new Reference();
750          if (this.performer == null)
751            this.performer = new ArrayList<Reference>();
752          this.performer.add(t);
753          return t;
754        }
755
756        public ImagingStudySeriesComponent addPerformer(Reference t) { //3
757          if (t == null)
758            return this;
759          if (this.performer == null)
760            this.performer = new ArrayList<Reference>();
761          this.performer.add(t);
762          return this;
763        }
764
765        /**
766         * @return The first repetition of repeating field {@link #performer}, creating it if it does not already exist
767         */
768        public Reference getPerformerFirstRep() { 
769          if (getPerformer().isEmpty()) {
770            addPerformer();
771          }
772          return getPerformer().get(0);
773        }
774
775        /**
776         * @deprecated Use Reference#setResource(IBaseResource) instead
777         */
778        @Deprecated
779        public List<Practitioner> getPerformerTarget() { 
780          if (this.performerTarget == null)
781            this.performerTarget = new ArrayList<Practitioner>();
782          return this.performerTarget;
783        }
784
785        /**
786         * @deprecated Use Reference#setResource(IBaseResource) instead
787         */
788        @Deprecated
789        public Practitioner addPerformerTarget() { 
790          Practitioner r = new Practitioner();
791          if (this.performerTarget == null)
792            this.performerTarget = new ArrayList<Practitioner>();
793          this.performerTarget.add(r);
794          return r;
795        }
796
797        /**
798         * @return {@link #instance} (A single SOP instance within the series, e.g. an image, or presentation state.)
799         */
800        public List<ImagingStudySeriesInstanceComponent> getInstance() { 
801          if (this.instance == null)
802            this.instance = new ArrayList<ImagingStudySeriesInstanceComponent>();
803          return this.instance;
804        }
805
806        /**
807         * @return Returns a reference to <code>this</code> for easy method chaining
808         */
809        public ImagingStudySeriesComponent setInstance(List<ImagingStudySeriesInstanceComponent> theInstance) { 
810          this.instance = theInstance;
811          return this;
812        }
813
814        public boolean hasInstance() { 
815          if (this.instance == null)
816            return false;
817          for (ImagingStudySeriesInstanceComponent item : this.instance)
818            if (!item.isEmpty())
819              return true;
820          return false;
821        }
822
823        public ImagingStudySeriesInstanceComponent addInstance() { //3
824          ImagingStudySeriesInstanceComponent t = new ImagingStudySeriesInstanceComponent();
825          if (this.instance == null)
826            this.instance = new ArrayList<ImagingStudySeriesInstanceComponent>();
827          this.instance.add(t);
828          return t;
829        }
830
831        public ImagingStudySeriesComponent addInstance(ImagingStudySeriesInstanceComponent t) { //3
832          if (t == null)
833            return this;
834          if (this.instance == null)
835            this.instance = new ArrayList<ImagingStudySeriesInstanceComponent>();
836          this.instance.add(t);
837          return this;
838        }
839
840        /**
841         * @return The first repetition of repeating field {@link #instance}, creating it if it does not already exist
842         */
843        public ImagingStudySeriesInstanceComponent getInstanceFirstRep() { 
844          if (getInstance().isEmpty()) {
845            addInstance();
846          }
847          return getInstance().get(0);
848        }
849
850        protected void listChildren(List<Property> childrenList) {
851          super.listChildren(childrenList);
852          childrenList.add(new Property("uid", "oid", "Formal identifier for this series.", 0, java.lang.Integer.MAX_VALUE, uid));
853          childrenList.add(new Property("number", "unsignedInt", "The numeric identifier of this series in the study.", 0, java.lang.Integer.MAX_VALUE, number));
854          childrenList.add(new Property("modality", "Coding", "The modality of this series sequence.", 0, java.lang.Integer.MAX_VALUE, modality));
855          childrenList.add(new Property("description", "string", "A description of the series.", 0, java.lang.Integer.MAX_VALUE, description));
856          childrenList.add(new Property("numberOfInstances", "unsignedInt", "Number of SOP Instances in the Study. The value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.", 0, java.lang.Integer.MAX_VALUE, numberOfInstances));
857          childrenList.add(new Property("availability", "code", "Availability of series (online, offline or nearline).", 0, java.lang.Integer.MAX_VALUE, availability));
858          childrenList.add(new Property("endpoint", "Reference(Endpoint)", "The network service providing access (e.g., query, view, or retrieval) for this series. See implementation notes for information about using DICOM endpoints. A series-level endpoint, if present, has precedence over a study-level endpoint with the same Endpoint.type.", 0, java.lang.Integer.MAX_VALUE, endpoint));
859          childrenList.add(new Property("bodySite", "Coding", "The anatomic structures examined. See DICOM Part 16 Annex L (http://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html) for DICOM to SNOMED-CT mappings. The bodySite may indicate the laterality of body part imaged; if so, it shall be consistent with any content of ImagingStudy.series.laterality.", 0, java.lang.Integer.MAX_VALUE, bodySite));
860          childrenList.add(new Property("laterality", "Coding", "The laterality of the (possibly paired) anatomic structures examined. E.g., the left knee, both lungs, or unpaired abdomen. If present, shall be consistent with any laterality information indicated in ImagingStudy.series.bodySite.", 0, java.lang.Integer.MAX_VALUE, laterality));
861          childrenList.add(new Property("started", "dateTime", "The date and time the series was started.", 0, java.lang.Integer.MAX_VALUE, started));
862          childrenList.add(new Property("performer", "Reference(Practitioner)", "The physician or operator (often the radiology technician)  who performed the series. The performer is recorded at the series level, since each series in a study may be performed by a different practitioner, at different times, and using different devices. A series may be performed by multiple practitioners.", 0, java.lang.Integer.MAX_VALUE, performer));
863          childrenList.add(new Property("instance", "", "A single SOP instance within the series, e.g. an image, or presentation state.", 0, java.lang.Integer.MAX_VALUE, instance));
864        }
865
866      @Override
867      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
868        switch (hash) {
869        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // OidType
870        case -1034364087: /*number*/ return this.number == null ? new Base[0] : new Base[] {this.number}; // UnsignedIntType
871        case -622722335: /*modality*/ return this.modality == null ? new Base[0] : new Base[] {this.modality}; // Coding
872        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
873        case -1043544226: /*numberOfInstances*/ return this.numberOfInstances == null ? new Base[0] : new Base[] {this.numberOfInstances}; // UnsignedIntType
874        case 1997542747: /*availability*/ return this.availability == null ? new Base[0] : new Base[] {this.availability}; // Enumeration<InstanceAvailability>
875        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : this.endpoint.toArray(new Base[this.endpoint.size()]); // Reference
876        case 1702620169: /*bodySite*/ return this.bodySite == null ? new Base[0] : new Base[] {this.bodySite}; // Coding
877        case -170291817: /*laterality*/ return this.laterality == null ? new Base[0] : new Base[] {this.laterality}; // Coding
878        case -1897185151: /*started*/ return this.started == null ? new Base[0] : new Base[] {this.started}; // DateTimeType
879        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // Reference
880        case 555127957: /*instance*/ return this.instance == null ? new Base[0] : this.instance.toArray(new Base[this.instance.size()]); // ImagingStudySeriesInstanceComponent
881        default: return super.getProperty(hash, name, checkValid);
882        }
883
884      }
885
886      @Override
887      public Base setProperty(int hash, String name, Base value) throws FHIRException {
888        switch (hash) {
889        case 115792: // uid
890          this.uid = castToOid(value); // OidType
891          return value;
892        case -1034364087: // number
893          this.number = castToUnsignedInt(value); // UnsignedIntType
894          return value;
895        case -622722335: // modality
896          this.modality = castToCoding(value); // Coding
897          return value;
898        case -1724546052: // description
899          this.description = castToString(value); // StringType
900          return value;
901        case -1043544226: // numberOfInstances
902          this.numberOfInstances = castToUnsignedInt(value); // UnsignedIntType
903          return value;
904        case 1997542747: // availability
905          value = new InstanceAvailabilityEnumFactory().fromType(castToCode(value));
906          this.availability = (Enumeration) value; // Enumeration<InstanceAvailability>
907          return value;
908        case 1741102485: // endpoint
909          this.getEndpoint().add(castToReference(value)); // Reference
910          return value;
911        case 1702620169: // bodySite
912          this.bodySite = castToCoding(value); // Coding
913          return value;
914        case -170291817: // laterality
915          this.laterality = castToCoding(value); // Coding
916          return value;
917        case -1897185151: // started
918          this.started = castToDateTime(value); // DateTimeType
919          return value;
920        case 481140686: // performer
921          this.getPerformer().add(castToReference(value)); // Reference
922          return value;
923        case 555127957: // instance
924          this.getInstance().add((ImagingStudySeriesInstanceComponent) value); // ImagingStudySeriesInstanceComponent
925          return value;
926        default: return super.setProperty(hash, name, value);
927        }
928
929      }
930
931      @Override
932      public Base setProperty(String name, Base value) throws FHIRException {
933        if (name.equals("uid")) {
934          this.uid = castToOid(value); // OidType
935        } else if (name.equals("number")) {
936          this.number = castToUnsignedInt(value); // UnsignedIntType
937        } else if (name.equals("modality")) {
938          this.modality = castToCoding(value); // Coding
939        } else if (name.equals("description")) {
940          this.description = castToString(value); // StringType
941        } else if (name.equals("numberOfInstances")) {
942          this.numberOfInstances = castToUnsignedInt(value); // UnsignedIntType
943        } else if (name.equals("availability")) {
944          value = new InstanceAvailabilityEnumFactory().fromType(castToCode(value));
945          this.availability = (Enumeration) value; // Enumeration<InstanceAvailability>
946        } else if (name.equals("endpoint")) {
947          this.getEndpoint().add(castToReference(value));
948        } else if (name.equals("bodySite")) {
949          this.bodySite = castToCoding(value); // Coding
950        } else if (name.equals("laterality")) {
951          this.laterality = castToCoding(value); // Coding
952        } else if (name.equals("started")) {
953          this.started = castToDateTime(value); // DateTimeType
954        } else if (name.equals("performer")) {
955          this.getPerformer().add(castToReference(value));
956        } else if (name.equals("instance")) {
957          this.getInstance().add((ImagingStudySeriesInstanceComponent) value);
958        } else
959          return super.setProperty(name, value);
960        return value;
961      }
962
963      @Override
964      public Base makeProperty(int hash, String name) throws FHIRException {
965        switch (hash) {
966        case 115792:  return getUidElement();
967        case -1034364087:  return getNumberElement();
968        case -622722335:  return getModality(); 
969        case -1724546052:  return getDescriptionElement();
970        case -1043544226:  return getNumberOfInstancesElement();
971        case 1997542747:  return getAvailabilityElement();
972        case 1741102485:  return addEndpoint(); 
973        case 1702620169:  return getBodySite(); 
974        case -170291817:  return getLaterality(); 
975        case -1897185151:  return getStartedElement();
976        case 481140686:  return addPerformer(); 
977        case 555127957:  return addInstance(); 
978        default: return super.makeProperty(hash, name);
979        }
980
981      }
982
983      @Override
984      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
985        switch (hash) {
986        case 115792: /*uid*/ return new String[] {"oid"};
987        case -1034364087: /*number*/ return new String[] {"unsignedInt"};
988        case -622722335: /*modality*/ return new String[] {"Coding"};
989        case -1724546052: /*description*/ return new String[] {"string"};
990        case -1043544226: /*numberOfInstances*/ return new String[] {"unsignedInt"};
991        case 1997542747: /*availability*/ return new String[] {"code"};
992        case 1741102485: /*endpoint*/ return new String[] {"Reference"};
993        case 1702620169: /*bodySite*/ return new String[] {"Coding"};
994        case -170291817: /*laterality*/ return new String[] {"Coding"};
995        case -1897185151: /*started*/ return new String[] {"dateTime"};
996        case 481140686: /*performer*/ return new String[] {"Reference"};
997        case 555127957: /*instance*/ return new String[] {};
998        default: return super.getTypesForProperty(hash, name);
999        }
1000
1001      }
1002
1003      @Override
1004      public Base addChild(String name) throws FHIRException {
1005        if (name.equals("uid")) {
1006          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.uid");
1007        }
1008        else if (name.equals("number")) {
1009          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.number");
1010        }
1011        else if (name.equals("modality")) {
1012          this.modality = new Coding();
1013          return this.modality;
1014        }
1015        else if (name.equals("description")) {
1016          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.description");
1017        }
1018        else if (name.equals("numberOfInstances")) {
1019          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.numberOfInstances");
1020        }
1021        else if (name.equals("availability")) {
1022          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.availability");
1023        }
1024        else if (name.equals("endpoint")) {
1025          return addEndpoint();
1026        }
1027        else if (name.equals("bodySite")) {
1028          this.bodySite = new Coding();
1029          return this.bodySite;
1030        }
1031        else if (name.equals("laterality")) {
1032          this.laterality = new Coding();
1033          return this.laterality;
1034        }
1035        else if (name.equals("started")) {
1036          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.started");
1037        }
1038        else if (name.equals("performer")) {
1039          return addPerformer();
1040        }
1041        else if (name.equals("instance")) {
1042          return addInstance();
1043        }
1044        else
1045          return super.addChild(name);
1046      }
1047
1048      public ImagingStudySeriesComponent copy() {
1049        ImagingStudySeriesComponent dst = new ImagingStudySeriesComponent();
1050        copyValues(dst);
1051        dst.uid = uid == null ? null : uid.copy();
1052        dst.number = number == null ? null : number.copy();
1053        dst.modality = modality == null ? null : modality.copy();
1054        dst.description = description == null ? null : description.copy();
1055        dst.numberOfInstances = numberOfInstances == null ? null : numberOfInstances.copy();
1056        dst.availability = availability == null ? null : availability.copy();
1057        if (endpoint != null) {
1058          dst.endpoint = new ArrayList<Reference>();
1059          for (Reference i : endpoint)
1060            dst.endpoint.add(i.copy());
1061        };
1062        dst.bodySite = bodySite == null ? null : bodySite.copy();
1063        dst.laterality = laterality == null ? null : laterality.copy();
1064        dst.started = started == null ? null : started.copy();
1065        if (performer != null) {
1066          dst.performer = new ArrayList<Reference>();
1067          for (Reference i : performer)
1068            dst.performer.add(i.copy());
1069        };
1070        if (instance != null) {
1071          dst.instance = new ArrayList<ImagingStudySeriesInstanceComponent>();
1072          for (ImagingStudySeriesInstanceComponent i : instance)
1073            dst.instance.add(i.copy());
1074        };
1075        return dst;
1076      }
1077
1078      @Override
1079      public boolean equalsDeep(Base other) {
1080        if (!super.equalsDeep(other))
1081          return false;
1082        if (!(other instanceof ImagingStudySeriesComponent))
1083          return false;
1084        ImagingStudySeriesComponent o = (ImagingStudySeriesComponent) other;
1085        return compareDeep(uid, o.uid, true) && compareDeep(number, o.number, true) && compareDeep(modality, o.modality, true)
1086           && compareDeep(description, o.description, true) && compareDeep(numberOfInstances, o.numberOfInstances, true)
1087           && compareDeep(availability, o.availability, true) && compareDeep(endpoint, o.endpoint, true) && compareDeep(bodySite, o.bodySite, true)
1088           && compareDeep(laterality, o.laterality, true) && compareDeep(started, o.started, true) && compareDeep(performer, o.performer, true)
1089           && compareDeep(instance, o.instance, true);
1090      }
1091
1092      @Override
1093      public boolean equalsShallow(Base other) {
1094        if (!super.equalsShallow(other))
1095          return false;
1096        if (!(other instanceof ImagingStudySeriesComponent))
1097          return false;
1098        ImagingStudySeriesComponent o = (ImagingStudySeriesComponent) other;
1099        return compareValues(uid, o.uid, true) && compareValues(number, o.number, true) && compareValues(description, o.description, true)
1100           && compareValues(numberOfInstances, o.numberOfInstances, true) && compareValues(availability, o.availability, true)
1101           && compareValues(started, o.started, true);
1102      }
1103
1104      public boolean isEmpty() {
1105        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(uid, number, modality, description
1106          , numberOfInstances, availability, endpoint, bodySite, laterality, started, performer
1107          , instance);
1108      }
1109
1110  public String fhirType() {
1111    return "ImagingStudy.series";
1112
1113  }
1114
1115  }
1116
1117    @Block()
1118    public static class ImagingStudySeriesInstanceComponent extends BackboneElement implements IBaseBackboneElement {
1119        /**
1120         * Formal identifier for this image or other content.
1121         */
1122        @Child(name = "uid", type = {OidType.class}, order=1, min=1, max=1, modifier=false, summary=false)
1123        @Description(shortDefinition="Formal DICOM identifier for this instance", formalDefinition="Formal identifier for this image or other content." )
1124        protected OidType uid;
1125
1126        /**
1127         * The number of instance in the series.
1128         */
1129        @Child(name = "number", type = {UnsignedIntType.class}, order=2, min=0, max=1, modifier=false, summary=false)
1130        @Description(shortDefinition="The number of this instance in the series", formalDefinition="The number of instance in the series." )
1131        protected UnsignedIntType number;
1132
1133        /**
1134         * DICOM instance  type.
1135         */
1136        @Child(name = "sopClass", type = {OidType.class}, order=3, min=1, max=1, modifier=false, summary=false)
1137        @Description(shortDefinition="DICOM class type", formalDefinition="DICOM instance  type." )
1138        protected OidType sopClass;
1139
1140        /**
1141         * The description of the instance.
1142         */
1143        @Child(name = "title", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
1144        @Description(shortDefinition="Description of instance", formalDefinition="The description of the instance." )
1145        protected StringType title;
1146
1147        private static final long serialVersionUID = -771526344L;
1148
1149    /**
1150     * Constructor
1151     */
1152      public ImagingStudySeriesInstanceComponent() {
1153        super();
1154      }
1155
1156    /**
1157     * Constructor
1158     */
1159      public ImagingStudySeriesInstanceComponent(OidType uid, OidType sopClass) {
1160        super();
1161        this.uid = uid;
1162        this.sopClass = sopClass;
1163      }
1164
1165        /**
1166         * @return {@link #uid} (Formal identifier for this image or other content.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
1167         */
1168        public OidType getUidElement() { 
1169          if (this.uid == null)
1170            if (Configuration.errorOnAutoCreate())
1171              throw new Error("Attempt to auto-create ImagingStudySeriesInstanceComponent.uid");
1172            else if (Configuration.doAutoCreate())
1173              this.uid = new OidType(); // bb
1174          return this.uid;
1175        }
1176
1177        public boolean hasUidElement() { 
1178          return this.uid != null && !this.uid.isEmpty();
1179        }
1180
1181        public boolean hasUid() { 
1182          return this.uid != null && !this.uid.isEmpty();
1183        }
1184
1185        /**
1186         * @param value {@link #uid} (Formal identifier for this image or other content.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
1187         */
1188        public ImagingStudySeriesInstanceComponent setUidElement(OidType value) { 
1189          this.uid = value;
1190          return this;
1191        }
1192
1193        /**
1194         * @return Formal identifier for this image or other content.
1195         */
1196        public String getUid() { 
1197          return this.uid == null ? null : this.uid.getValue();
1198        }
1199
1200        /**
1201         * @param value Formal identifier for this image or other content.
1202         */
1203        public ImagingStudySeriesInstanceComponent setUid(String value) { 
1204            if (this.uid == null)
1205              this.uid = new OidType();
1206            this.uid.setValue(value);
1207          return this;
1208        }
1209
1210        /**
1211         * @return {@link #number} (The number of instance in the series.). This is the underlying object with id, value and extensions. The accessor "getNumber" gives direct access to the value
1212         */
1213        public UnsignedIntType getNumberElement() { 
1214          if (this.number == null)
1215            if (Configuration.errorOnAutoCreate())
1216              throw new Error("Attempt to auto-create ImagingStudySeriesInstanceComponent.number");
1217            else if (Configuration.doAutoCreate())
1218              this.number = new UnsignedIntType(); // bb
1219          return this.number;
1220        }
1221
1222        public boolean hasNumberElement() { 
1223          return this.number != null && !this.number.isEmpty();
1224        }
1225
1226        public boolean hasNumber() { 
1227          return this.number != null && !this.number.isEmpty();
1228        }
1229
1230        /**
1231         * @param value {@link #number} (The number of instance in the series.). This is the underlying object with id, value and extensions. The accessor "getNumber" gives direct access to the value
1232         */
1233        public ImagingStudySeriesInstanceComponent setNumberElement(UnsignedIntType value) { 
1234          this.number = value;
1235          return this;
1236        }
1237
1238        /**
1239         * @return The number of instance in the series.
1240         */
1241        public int getNumber() { 
1242          return this.number == null || this.number.isEmpty() ? 0 : this.number.getValue();
1243        }
1244
1245        /**
1246         * @param value The number of instance in the series.
1247         */
1248        public ImagingStudySeriesInstanceComponent setNumber(int value) { 
1249            if (this.number == null)
1250              this.number = new UnsignedIntType();
1251            this.number.setValue(value);
1252          return this;
1253        }
1254
1255        /**
1256         * @return {@link #sopClass} (DICOM instance  type.). This is the underlying object with id, value and extensions. The accessor "getSopClass" gives direct access to the value
1257         */
1258        public OidType getSopClassElement() { 
1259          if (this.sopClass == null)
1260            if (Configuration.errorOnAutoCreate())
1261              throw new Error("Attempt to auto-create ImagingStudySeriesInstanceComponent.sopClass");
1262            else if (Configuration.doAutoCreate())
1263              this.sopClass = new OidType(); // bb
1264          return this.sopClass;
1265        }
1266
1267        public boolean hasSopClassElement() { 
1268          return this.sopClass != null && !this.sopClass.isEmpty();
1269        }
1270
1271        public boolean hasSopClass() { 
1272          return this.sopClass != null && !this.sopClass.isEmpty();
1273        }
1274
1275        /**
1276         * @param value {@link #sopClass} (DICOM instance  type.). This is the underlying object with id, value and extensions. The accessor "getSopClass" gives direct access to the value
1277         */
1278        public ImagingStudySeriesInstanceComponent setSopClassElement(OidType value) { 
1279          this.sopClass = value;
1280          return this;
1281        }
1282
1283        /**
1284         * @return DICOM instance  type.
1285         */
1286        public String getSopClass() { 
1287          return this.sopClass == null ? null : this.sopClass.getValue();
1288        }
1289
1290        /**
1291         * @param value DICOM instance  type.
1292         */
1293        public ImagingStudySeriesInstanceComponent setSopClass(String value) { 
1294            if (this.sopClass == null)
1295              this.sopClass = new OidType();
1296            this.sopClass.setValue(value);
1297          return this;
1298        }
1299
1300        /**
1301         * @return {@link #title} (The description of the instance.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
1302         */
1303        public StringType getTitleElement() { 
1304          if (this.title == null)
1305            if (Configuration.errorOnAutoCreate())
1306              throw new Error("Attempt to auto-create ImagingStudySeriesInstanceComponent.title");
1307            else if (Configuration.doAutoCreate())
1308              this.title = new StringType(); // bb
1309          return this.title;
1310        }
1311
1312        public boolean hasTitleElement() { 
1313          return this.title != null && !this.title.isEmpty();
1314        }
1315
1316        public boolean hasTitle() { 
1317          return this.title != null && !this.title.isEmpty();
1318        }
1319
1320        /**
1321         * @param value {@link #title} (The description of the instance.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
1322         */
1323        public ImagingStudySeriesInstanceComponent setTitleElement(StringType value) { 
1324          this.title = value;
1325          return this;
1326        }
1327
1328        /**
1329         * @return The description of the instance.
1330         */
1331        public String getTitle() { 
1332          return this.title == null ? null : this.title.getValue();
1333        }
1334
1335        /**
1336         * @param value The description of the instance.
1337         */
1338        public ImagingStudySeriesInstanceComponent setTitle(String value) { 
1339          if (Utilities.noString(value))
1340            this.title = null;
1341          else {
1342            if (this.title == null)
1343              this.title = new StringType();
1344            this.title.setValue(value);
1345          }
1346          return this;
1347        }
1348
1349        protected void listChildren(List<Property> childrenList) {
1350          super.listChildren(childrenList);
1351          childrenList.add(new Property("uid", "oid", "Formal identifier for this image or other content.", 0, java.lang.Integer.MAX_VALUE, uid));
1352          childrenList.add(new Property("number", "unsignedInt", "The number of instance in the series.", 0, java.lang.Integer.MAX_VALUE, number));
1353          childrenList.add(new Property("sopClass", "oid", "DICOM instance  type.", 0, java.lang.Integer.MAX_VALUE, sopClass));
1354          childrenList.add(new Property("title", "string", "The description of the instance.", 0, java.lang.Integer.MAX_VALUE, title));
1355        }
1356
1357      @Override
1358      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1359        switch (hash) {
1360        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // OidType
1361        case -1034364087: /*number*/ return this.number == null ? new Base[0] : new Base[] {this.number}; // UnsignedIntType
1362        case 1560041540: /*sopClass*/ return this.sopClass == null ? new Base[0] : new Base[] {this.sopClass}; // OidType
1363        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
1364        default: return super.getProperty(hash, name, checkValid);
1365        }
1366
1367      }
1368
1369      @Override
1370      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1371        switch (hash) {
1372        case 115792: // uid
1373          this.uid = castToOid(value); // OidType
1374          return value;
1375        case -1034364087: // number
1376          this.number = castToUnsignedInt(value); // UnsignedIntType
1377          return value;
1378        case 1560041540: // sopClass
1379          this.sopClass = castToOid(value); // OidType
1380          return value;
1381        case 110371416: // title
1382          this.title = castToString(value); // StringType
1383          return value;
1384        default: return super.setProperty(hash, name, value);
1385        }
1386
1387      }
1388
1389      @Override
1390      public Base setProperty(String name, Base value) throws FHIRException {
1391        if (name.equals("uid")) {
1392          this.uid = castToOid(value); // OidType
1393        } else if (name.equals("number")) {
1394          this.number = castToUnsignedInt(value); // UnsignedIntType
1395        } else if (name.equals("sopClass")) {
1396          this.sopClass = castToOid(value); // OidType
1397        } else if (name.equals("title")) {
1398          this.title = castToString(value); // StringType
1399        } else
1400          return super.setProperty(name, value);
1401        return value;
1402      }
1403
1404      @Override
1405      public Base makeProperty(int hash, String name) throws FHIRException {
1406        switch (hash) {
1407        case 115792:  return getUidElement();
1408        case -1034364087:  return getNumberElement();
1409        case 1560041540:  return getSopClassElement();
1410        case 110371416:  return getTitleElement();
1411        default: return super.makeProperty(hash, name);
1412        }
1413
1414      }
1415
1416      @Override
1417      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1418        switch (hash) {
1419        case 115792: /*uid*/ return new String[] {"oid"};
1420        case -1034364087: /*number*/ return new String[] {"unsignedInt"};
1421        case 1560041540: /*sopClass*/ return new String[] {"oid"};
1422        case 110371416: /*title*/ return new String[] {"string"};
1423        default: return super.getTypesForProperty(hash, name);
1424        }
1425
1426      }
1427
1428      @Override
1429      public Base addChild(String name) throws FHIRException {
1430        if (name.equals("uid")) {
1431          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.uid");
1432        }
1433        else if (name.equals("number")) {
1434          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.number");
1435        }
1436        else if (name.equals("sopClass")) {
1437          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.sopClass");
1438        }
1439        else if (name.equals("title")) {
1440          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.title");
1441        }
1442        else
1443          return super.addChild(name);
1444      }
1445
1446      public ImagingStudySeriesInstanceComponent copy() {
1447        ImagingStudySeriesInstanceComponent dst = new ImagingStudySeriesInstanceComponent();
1448        copyValues(dst);
1449        dst.uid = uid == null ? null : uid.copy();
1450        dst.number = number == null ? null : number.copy();
1451        dst.sopClass = sopClass == null ? null : sopClass.copy();
1452        dst.title = title == null ? null : title.copy();
1453        return dst;
1454      }
1455
1456      @Override
1457      public boolean equalsDeep(Base other) {
1458        if (!super.equalsDeep(other))
1459          return false;
1460        if (!(other instanceof ImagingStudySeriesInstanceComponent))
1461          return false;
1462        ImagingStudySeriesInstanceComponent o = (ImagingStudySeriesInstanceComponent) other;
1463        return compareDeep(uid, o.uid, true) && compareDeep(number, o.number, true) && compareDeep(sopClass, o.sopClass, true)
1464           && compareDeep(title, o.title, true);
1465      }
1466
1467      @Override
1468      public boolean equalsShallow(Base other) {
1469        if (!super.equalsShallow(other))
1470          return false;
1471        if (!(other instanceof ImagingStudySeriesInstanceComponent))
1472          return false;
1473        ImagingStudySeriesInstanceComponent o = (ImagingStudySeriesInstanceComponent) other;
1474        return compareValues(uid, o.uid, true) && compareValues(number, o.number, true) && compareValues(sopClass, o.sopClass, true)
1475           && compareValues(title, o.title, true);
1476      }
1477
1478      public boolean isEmpty() {
1479        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(uid, number, sopClass, title
1480          );
1481      }
1482
1483  public String fhirType() {
1484    return "ImagingStudy.series.instance";
1485
1486  }
1487
1488  }
1489
1490    /**
1491     * Formal identifier for the study.
1492     */
1493    @Child(name = "uid", type = {OidType.class}, order=0, min=1, max=1, modifier=false, summary=true)
1494    @Description(shortDefinition="Formal DICOM identifier for the study", formalDefinition="Formal identifier for the study." )
1495    protected OidType uid;
1496
1497    /**
1498     * Accession Number is an identifier related to some aspect of imaging workflow and data management. Usage may vary across different institutions.  See for instance [IHE Radiology Technical Framework Volume 1 Appendix A](http://www.ihe.net/uploadedFiles/Documents/Radiology/IHE_RAD_TF_Rev13.0_Vol1_FT_2014-07-30.pdf).
1499     */
1500    @Child(name = "accession", type = {Identifier.class}, order=1, min=0, max=1, modifier=false, summary=true)
1501    @Description(shortDefinition="Related workflow identifier (\"Accession Number\")", formalDefinition="Accession Number is an identifier related to some aspect of imaging workflow and data management. Usage may vary across different institutions.  See for instance [IHE Radiology Technical Framework Volume 1 Appendix A](http://www.ihe.net/uploadedFiles/Documents/Radiology/IHE_RAD_TF_Rev13.0_Vol1_FT_2014-07-30.pdf)." )
1502    protected Identifier accession;
1503
1504    /**
1505     * Other identifiers for the study.
1506     */
1507    @Child(name = "identifier", type = {Identifier.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1508    @Description(shortDefinition="Other identifiers for the study", formalDefinition="Other identifiers for the study." )
1509    protected List<Identifier> identifier;
1510
1511    /**
1512     * Availability of study (online, offline, or nearline).
1513     */
1514    @Child(name = "availability", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
1515    @Description(shortDefinition="ONLINE | OFFLINE | NEARLINE | UNAVAILABLE", formalDefinition="Availability of study (online, offline, or nearline)." )
1516    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/instance-availability")
1517    protected Enumeration<InstanceAvailability> availability;
1518
1519    /**
1520     * A list of all the Series.ImageModality values that are actual acquisition modalities, i.e. those in the DICOM Context Group 29 (value set OID 1.2.840.10008.6.1.19).
1521     */
1522    @Child(name = "modalityList", type = {Coding.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1523    @Description(shortDefinition="All series modality if actual acquisition modalities", formalDefinition="A list of all the Series.ImageModality values that are actual acquisition modalities, i.e. those in the DICOM Context Group 29 (value set OID 1.2.840.10008.6.1.19)." )
1524    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/dicom-cid29")
1525    protected List<Coding> modalityList;
1526
1527    /**
1528     * The patient imaged in the study.
1529     */
1530    @Child(name = "patient", type = {Patient.class}, order=5, min=1, max=1, modifier=false, summary=true)
1531    @Description(shortDefinition="Who the images are of", formalDefinition="The patient imaged in the study." )
1532    protected Reference patient;
1533
1534    /**
1535     * The actual object that is the target of the reference (The patient imaged in the study.)
1536     */
1537    protected Patient patientTarget;
1538
1539    /**
1540     * The encounter or episode at which the request is initiated.
1541     */
1542    @Child(name = "context", type = {Encounter.class, EpisodeOfCare.class}, order=6, min=0, max=1, modifier=false, summary=true)
1543    @Description(shortDefinition="Originating context", formalDefinition="The encounter or episode at which the request is initiated." )
1544    protected Reference context;
1545
1546    /**
1547     * The actual object that is the target of the reference (The encounter or episode at which the request is initiated.)
1548     */
1549    protected Resource contextTarget;
1550
1551    /**
1552     * Date and time the study started.
1553     */
1554    @Child(name = "started", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
1555    @Description(shortDefinition="When the study was started", formalDefinition="Date and time the study started." )
1556    protected DateTimeType started;
1557
1558    /**
1559     * A list of the diagnostic requests that resulted in this imaging study being performed.
1560     */
1561    @Child(name = "basedOn", type = {ReferralRequest.class, CarePlan.class, ProcedureRequest.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1562    @Description(shortDefinition="Request fulfilled", formalDefinition="A list of the diagnostic requests that resulted in this imaging study being performed." )
1563    protected List<Reference> basedOn;
1564    /**
1565     * The actual objects that are the target of the reference (A list of the diagnostic requests that resulted in this imaging study being performed.)
1566     */
1567    protected List<Resource> basedOnTarget;
1568
1569
1570    /**
1571     * The requesting/referring physician.
1572     */
1573    @Child(name = "referrer", type = {Practitioner.class}, order=9, min=0, max=1, modifier=false, summary=true)
1574    @Description(shortDefinition="Referring physician", formalDefinition="The requesting/referring physician." )
1575    protected Reference referrer;
1576
1577    /**
1578     * The actual object that is the target of the reference (The requesting/referring physician.)
1579     */
1580    protected Practitioner referrerTarget;
1581
1582    /**
1583     * Who read the study and interpreted the images or other content.
1584     */
1585    @Child(name = "interpreter", type = {Practitioner.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1586    @Description(shortDefinition="Who interpreted images", formalDefinition="Who read the study and interpreted the images or other content." )
1587    protected List<Reference> interpreter;
1588    /**
1589     * The actual objects that are the target of the reference (Who read the study and interpreted the images or other content.)
1590     */
1591    protected List<Practitioner> interpreterTarget;
1592
1593
1594    /**
1595     * The network service providing access (e.g., query, view, or retrieval) for the study. See implementation notes for information about using DICOM endpoints. A study-level endpoint applies to each series in the study, unless overridden by a series-level endpoint with the same Endpoint.type.
1596     */
1597    @Child(name = "endpoint", type = {Endpoint.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1598    @Description(shortDefinition="Study access endpoint", formalDefinition="The network service providing access (e.g., query, view, or retrieval) for the study. See implementation notes for information about using DICOM endpoints. A study-level endpoint applies to each series in the study, unless overridden by a series-level endpoint with the same Endpoint.type." )
1599    protected List<Reference> endpoint;
1600    /**
1601     * The actual objects that are the target of the reference (The network service providing access (e.g., query, view, or retrieval) for the study. See implementation notes for information about using DICOM endpoints. A study-level endpoint applies to each series in the study, unless overridden by a series-level endpoint with the same Endpoint.type.)
1602     */
1603    protected List<Endpoint> endpointTarget;
1604
1605
1606    /**
1607     * Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.
1608     */
1609    @Child(name = "numberOfSeries", type = {UnsignedIntType.class}, order=12, min=0, max=1, modifier=false, summary=true)
1610    @Description(shortDefinition="Number of Study Related Series", formalDefinition="Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present." )
1611    protected UnsignedIntType numberOfSeries;
1612
1613    /**
1614     * Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
1615     */
1616    @Child(name = "numberOfInstances", type = {UnsignedIntType.class}, order=13, min=0, max=1, modifier=false, summary=true)
1617    @Description(shortDefinition="Number of Study Related Instances", formalDefinition="Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present." )
1618    protected UnsignedIntType numberOfInstances;
1619
1620    /**
1621     * A reference to the performed Procedure.
1622     */
1623    @Child(name = "procedureReference", type = {Procedure.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1624    @Description(shortDefinition="The performed Procedure reference", formalDefinition="A reference to the performed Procedure." )
1625    protected List<Reference> procedureReference;
1626    /**
1627     * The actual objects that are the target of the reference (A reference to the performed Procedure.)
1628     */
1629    protected List<Procedure> procedureReferenceTarget;
1630
1631
1632    /**
1633     * The code for the performed procedure type.
1634     */
1635    @Child(name = "procedureCode", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1636    @Description(shortDefinition="The performed procedure code", formalDefinition="The code for the performed procedure type." )
1637    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-code")
1638    protected List<CodeableConcept> procedureCode;
1639
1640    /**
1641     * Description of clinical condition indicating why the ImagingStudy was requested.
1642     */
1643    @Child(name = "reason", type = {CodeableConcept.class}, order=16, min=0, max=1, modifier=false, summary=true)
1644    @Description(shortDefinition="Why the study was requested", formalDefinition="Description of clinical condition indicating why the ImagingStudy was requested." )
1645    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-reason")
1646    protected CodeableConcept reason;
1647
1648    /**
1649     * Institution-generated description or classification of the Study performed.
1650     */
1651    @Child(name = "description", type = {StringType.class}, order=17, min=0, max=1, modifier=false, summary=true)
1652    @Description(shortDefinition="Institution-generated description", formalDefinition="Institution-generated description or classification of the Study performed." )
1653    protected StringType description;
1654
1655    /**
1656     * Each study has one or more series of images or other content.
1657     */
1658    @Child(name = "series", type = {}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1659    @Description(shortDefinition="Each study has one or more series of instances", formalDefinition="Each study has one or more series of images or other content." )
1660    protected List<ImagingStudySeriesComponent> series;
1661
1662    private static final long serialVersionUID = -1987354693L;
1663
1664  /**
1665   * Constructor
1666   */
1667    public ImagingStudy() {
1668      super();
1669    }
1670
1671  /**
1672   * Constructor
1673   */
1674    public ImagingStudy(OidType uid, Reference patient) {
1675      super();
1676      this.uid = uid;
1677      this.patient = patient;
1678    }
1679
1680    /**
1681     * @return {@link #uid} (Formal identifier for the study.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
1682     */
1683    public OidType getUidElement() { 
1684      if (this.uid == null)
1685        if (Configuration.errorOnAutoCreate())
1686          throw new Error("Attempt to auto-create ImagingStudy.uid");
1687        else if (Configuration.doAutoCreate())
1688          this.uid = new OidType(); // bb
1689      return this.uid;
1690    }
1691
1692    public boolean hasUidElement() { 
1693      return this.uid != null && !this.uid.isEmpty();
1694    }
1695
1696    public boolean hasUid() { 
1697      return this.uid != null && !this.uid.isEmpty();
1698    }
1699
1700    /**
1701     * @param value {@link #uid} (Formal identifier for the study.). This is the underlying object with id, value and extensions. The accessor "getUid" gives direct access to the value
1702     */
1703    public ImagingStudy setUidElement(OidType value) { 
1704      this.uid = value;
1705      return this;
1706    }
1707
1708    /**
1709     * @return Formal identifier for the study.
1710     */
1711    public String getUid() { 
1712      return this.uid == null ? null : this.uid.getValue();
1713    }
1714
1715    /**
1716     * @param value Formal identifier for the study.
1717     */
1718    public ImagingStudy setUid(String value) { 
1719        if (this.uid == null)
1720          this.uid = new OidType();
1721        this.uid.setValue(value);
1722      return this;
1723    }
1724
1725    /**
1726     * @return {@link #accession} (Accession Number is an identifier related to some aspect of imaging workflow and data management. Usage may vary across different institutions.  See for instance [IHE Radiology Technical Framework Volume 1 Appendix A](http://www.ihe.net/uploadedFiles/Documents/Radiology/IHE_RAD_TF_Rev13.0_Vol1_FT_2014-07-30.pdf).)
1727     */
1728    public Identifier getAccession() { 
1729      if (this.accession == null)
1730        if (Configuration.errorOnAutoCreate())
1731          throw new Error("Attempt to auto-create ImagingStudy.accession");
1732        else if (Configuration.doAutoCreate())
1733          this.accession = new Identifier(); // cc
1734      return this.accession;
1735    }
1736
1737    public boolean hasAccession() { 
1738      return this.accession != null && !this.accession.isEmpty();
1739    }
1740
1741    /**
1742     * @param value {@link #accession} (Accession Number is an identifier related to some aspect of imaging workflow and data management. Usage may vary across different institutions.  See for instance [IHE Radiology Technical Framework Volume 1 Appendix A](http://www.ihe.net/uploadedFiles/Documents/Radiology/IHE_RAD_TF_Rev13.0_Vol1_FT_2014-07-30.pdf).)
1743     */
1744    public ImagingStudy setAccession(Identifier value) { 
1745      this.accession = value;
1746      return this;
1747    }
1748
1749    /**
1750     * @return {@link #identifier} (Other identifiers for the study.)
1751     */
1752    public List<Identifier> getIdentifier() { 
1753      if (this.identifier == null)
1754        this.identifier = new ArrayList<Identifier>();
1755      return this.identifier;
1756    }
1757
1758    /**
1759     * @return Returns a reference to <code>this</code> for easy method chaining
1760     */
1761    public ImagingStudy setIdentifier(List<Identifier> theIdentifier) { 
1762      this.identifier = theIdentifier;
1763      return this;
1764    }
1765
1766    public boolean hasIdentifier() { 
1767      if (this.identifier == null)
1768        return false;
1769      for (Identifier item : this.identifier)
1770        if (!item.isEmpty())
1771          return true;
1772      return false;
1773    }
1774
1775    public Identifier addIdentifier() { //3
1776      Identifier t = new Identifier();
1777      if (this.identifier == null)
1778        this.identifier = new ArrayList<Identifier>();
1779      this.identifier.add(t);
1780      return t;
1781    }
1782
1783    public ImagingStudy addIdentifier(Identifier t) { //3
1784      if (t == null)
1785        return this;
1786      if (this.identifier == null)
1787        this.identifier = new ArrayList<Identifier>();
1788      this.identifier.add(t);
1789      return this;
1790    }
1791
1792    /**
1793     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1794     */
1795    public Identifier getIdentifierFirstRep() { 
1796      if (getIdentifier().isEmpty()) {
1797        addIdentifier();
1798      }
1799      return getIdentifier().get(0);
1800    }
1801
1802    /**
1803     * @return {@link #availability} (Availability of study (online, offline, or nearline).). This is the underlying object with id, value and extensions. The accessor "getAvailability" gives direct access to the value
1804     */
1805    public Enumeration<InstanceAvailability> getAvailabilityElement() { 
1806      if (this.availability == null)
1807        if (Configuration.errorOnAutoCreate())
1808          throw new Error("Attempt to auto-create ImagingStudy.availability");
1809        else if (Configuration.doAutoCreate())
1810          this.availability = new Enumeration<InstanceAvailability>(new InstanceAvailabilityEnumFactory()); // bb
1811      return this.availability;
1812    }
1813
1814    public boolean hasAvailabilityElement() { 
1815      return this.availability != null && !this.availability.isEmpty();
1816    }
1817
1818    public boolean hasAvailability() { 
1819      return this.availability != null && !this.availability.isEmpty();
1820    }
1821
1822    /**
1823     * @param value {@link #availability} (Availability of study (online, offline, or nearline).). This is the underlying object with id, value and extensions. The accessor "getAvailability" gives direct access to the value
1824     */
1825    public ImagingStudy setAvailabilityElement(Enumeration<InstanceAvailability> value) { 
1826      this.availability = value;
1827      return this;
1828    }
1829
1830    /**
1831     * @return Availability of study (online, offline, or nearline).
1832     */
1833    public InstanceAvailability getAvailability() { 
1834      return this.availability == null ? null : this.availability.getValue();
1835    }
1836
1837    /**
1838     * @param value Availability of study (online, offline, or nearline).
1839     */
1840    public ImagingStudy setAvailability(InstanceAvailability value) { 
1841      if (value == null)
1842        this.availability = null;
1843      else {
1844        if (this.availability == null)
1845          this.availability = new Enumeration<InstanceAvailability>(new InstanceAvailabilityEnumFactory());
1846        this.availability.setValue(value);
1847      }
1848      return this;
1849    }
1850
1851    /**
1852     * @return {@link #modalityList} (A list of all the Series.ImageModality values that are actual acquisition modalities, i.e. those in the DICOM Context Group 29 (value set OID 1.2.840.10008.6.1.19).)
1853     */
1854    public List<Coding> getModalityList() { 
1855      if (this.modalityList == null)
1856        this.modalityList = new ArrayList<Coding>();
1857      return this.modalityList;
1858    }
1859
1860    /**
1861     * @return Returns a reference to <code>this</code> for easy method chaining
1862     */
1863    public ImagingStudy setModalityList(List<Coding> theModalityList) { 
1864      this.modalityList = theModalityList;
1865      return this;
1866    }
1867
1868    public boolean hasModalityList() { 
1869      if (this.modalityList == null)
1870        return false;
1871      for (Coding item : this.modalityList)
1872        if (!item.isEmpty())
1873          return true;
1874      return false;
1875    }
1876
1877    public Coding addModalityList() { //3
1878      Coding t = new Coding();
1879      if (this.modalityList == null)
1880        this.modalityList = new ArrayList<Coding>();
1881      this.modalityList.add(t);
1882      return t;
1883    }
1884
1885    public ImagingStudy addModalityList(Coding t) { //3
1886      if (t == null)
1887        return this;
1888      if (this.modalityList == null)
1889        this.modalityList = new ArrayList<Coding>();
1890      this.modalityList.add(t);
1891      return this;
1892    }
1893
1894    /**
1895     * @return The first repetition of repeating field {@link #modalityList}, creating it if it does not already exist
1896     */
1897    public Coding getModalityListFirstRep() { 
1898      if (getModalityList().isEmpty()) {
1899        addModalityList();
1900      }
1901      return getModalityList().get(0);
1902    }
1903
1904    /**
1905     * @return {@link #patient} (The patient imaged in the study.)
1906     */
1907    public Reference getPatient() { 
1908      if (this.patient == null)
1909        if (Configuration.errorOnAutoCreate())
1910          throw new Error("Attempt to auto-create ImagingStudy.patient");
1911        else if (Configuration.doAutoCreate())
1912          this.patient = new Reference(); // cc
1913      return this.patient;
1914    }
1915
1916    public boolean hasPatient() { 
1917      return this.patient != null && !this.patient.isEmpty();
1918    }
1919
1920    /**
1921     * @param value {@link #patient} (The patient imaged in the study.)
1922     */
1923    public ImagingStudy setPatient(Reference value) { 
1924      this.patient = value;
1925      return this;
1926    }
1927
1928    /**
1929     * @return {@link #patient} 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 patient imaged in the study.)
1930     */
1931    public Patient getPatientTarget() { 
1932      if (this.patientTarget == null)
1933        if (Configuration.errorOnAutoCreate())
1934          throw new Error("Attempt to auto-create ImagingStudy.patient");
1935        else if (Configuration.doAutoCreate())
1936          this.patientTarget = new Patient(); // aa
1937      return this.patientTarget;
1938    }
1939
1940    /**
1941     * @param value {@link #patient} 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 patient imaged in the study.)
1942     */
1943    public ImagingStudy setPatientTarget(Patient value) { 
1944      this.patientTarget = value;
1945      return this;
1946    }
1947
1948    /**
1949     * @return {@link #context} (The encounter or episode at which the request is initiated.)
1950     */
1951    public Reference getContext() { 
1952      if (this.context == null)
1953        if (Configuration.errorOnAutoCreate())
1954          throw new Error("Attempt to auto-create ImagingStudy.context");
1955        else if (Configuration.doAutoCreate())
1956          this.context = new Reference(); // cc
1957      return this.context;
1958    }
1959
1960    public boolean hasContext() { 
1961      return this.context != null && !this.context.isEmpty();
1962    }
1963
1964    /**
1965     * @param value {@link #context} (The encounter or episode at which the request is initiated.)
1966     */
1967    public ImagingStudy setContext(Reference value) { 
1968      this.context = value;
1969      return this;
1970    }
1971
1972    /**
1973     * @return {@link #context} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The encounter or episode at which the request is initiated.)
1974     */
1975    public Resource getContextTarget() { 
1976      return this.contextTarget;
1977    }
1978
1979    /**
1980     * @param value {@link #context} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The encounter or episode at which the request is initiated.)
1981     */
1982    public ImagingStudy setContextTarget(Resource value) { 
1983      this.contextTarget = value;
1984      return this;
1985    }
1986
1987    /**
1988     * @return {@link #started} (Date and time the study started.). This is the underlying object with id, value and extensions. The accessor "getStarted" gives direct access to the value
1989     */
1990    public DateTimeType getStartedElement() { 
1991      if (this.started == null)
1992        if (Configuration.errorOnAutoCreate())
1993          throw new Error("Attempt to auto-create ImagingStudy.started");
1994        else if (Configuration.doAutoCreate())
1995          this.started = new DateTimeType(); // bb
1996      return this.started;
1997    }
1998
1999    public boolean hasStartedElement() { 
2000      return this.started != null && !this.started.isEmpty();
2001    }
2002
2003    public boolean hasStarted() { 
2004      return this.started != null && !this.started.isEmpty();
2005    }
2006
2007    /**
2008     * @param value {@link #started} (Date and time the study started.). This is the underlying object with id, value and extensions. The accessor "getStarted" gives direct access to the value
2009     */
2010    public ImagingStudy setStartedElement(DateTimeType value) { 
2011      this.started = value;
2012      return this;
2013    }
2014
2015    /**
2016     * @return Date and time the study started.
2017     */
2018    public Date getStarted() { 
2019      return this.started == null ? null : this.started.getValue();
2020    }
2021
2022    /**
2023     * @param value Date and time the study started.
2024     */
2025    public ImagingStudy setStarted(Date value) { 
2026      if (value == null)
2027        this.started = null;
2028      else {
2029        if (this.started == null)
2030          this.started = new DateTimeType();
2031        this.started.setValue(value);
2032      }
2033      return this;
2034    }
2035
2036    /**
2037     * @return {@link #basedOn} (A list of the diagnostic requests that resulted in this imaging study being performed.)
2038     */
2039    public List<Reference> getBasedOn() { 
2040      if (this.basedOn == null)
2041        this.basedOn = new ArrayList<Reference>();
2042      return this.basedOn;
2043    }
2044
2045    /**
2046     * @return Returns a reference to <code>this</code> for easy method chaining
2047     */
2048    public ImagingStudy setBasedOn(List<Reference> theBasedOn) { 
2049      this.basedOn = theBasedOn;
2050      return this;
2051    }
2052
2053    public boolean hasBasedOn() { 
2054      if (this.basedOn == null)
2055        return false;
2056      for (Reference item : this.basedOn)
2057        if (!item.isEmpty())
2058          return true;
2059      return false;
2060    }
2061
2062    public Reference addBasedOn() { //3
2063      Reference t = new Reference();
2064      if (this.basedOn == null)
2065        this.basedOn = new ArrayList<Reference>();
2066      this.basedOn.add(t);
2067      return t;
2068    }
2069
2070    public ImagingStudy addBasedOn(Reference t) { //3
2071      if (t == null)
2072        return this;
2073      if (this.basedOn == null)
2074        this.basedOn = new ArrayList<Reference>();
2075      this.basedOn.add(t);
2076      return this;
2077    }
2078
2079    /**
2080     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
2081     */
2082    public Reference getBasedOnFirstRep() { 
2083      if (getBasedOn().isEmpty()) {
2084        addBasedOn();
2085      }
2086      return getBasedOn().get(0);
2087    }
2088
2089    /**
2090     * @deprecated Use Reference#setResource(IBaseResource) instead
2091     */
2092    @Deprecated
2093    public List<Resource> getBasedOnTarget() { 
2094      if (this.basedOnTarget == null)
2095        this.basedOnTarget = new ArrayList<Resource>();
2096      return this.basedOnTarget;
2097    }
2098
2099    /**
2100     * @return {@link #referrer} (The requesting/referring physician.)
2101     */
2102    public Reference getReferrer() { 
2103      if (this.referrer == null)
2104        if (Configuration.errorOnAutoCreate())
2105          throw new Error("Attempt to auto-create ImagingStudy.referrer");
2106        else if (Configuration.doAutoCreate())
2107          this.referrer = new Reference(); // cc
2108      return this.referrer;
2109    }
2110
2111    public boolean hasReferrer() { 
2112      return this.referrer != null && !this.referrer.isEmpty();
2113    }
2114
2115    /**
2116     * @param value {@link #referrer} (The requesting/referring physician.)
2117     */
2118    public ImagingStudy setReferrer(Reference value) { 
2119      this.referrer = value;
2120      return this;
2121    }
2122
2123    /**
2124     * @return {@link #referrer} 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 requesting/referring physician.)
2125     */
2126    public Practitioner getReferrerTarget() { 
2127      if (this.referrerTarget == null)
2128        if (Configuration.errorOnAutoCreate())
2129          throw new Error("Attempt to auto-create ImagingStudy.referrer");
2130        else if (Configuration.doAutoCreate())
2131          this.referrerTarget = new Practitioner(); // aa
2132      return this.referrerTarget;
2133    }
2134
2135    /**
2136     * @param value {@link #referrer} 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 requesting/referring physician.)
2137     */
2138    public ImagingStudy setReferrerTarget(Practitioner value) { 
2139      this.referrerTarget = value;
2140      return this;
2141    }
2142
2143    /**
2144     * @return {@link #interpreter} (Who read the study and interpreted the images or other content.)
2145     */
2146    public List<Reference> getInterpreter() { 
2147      if (this.interpreter == null)
2148        this.interpreter = new ArrayList<Reference>();
2149      return this.interpreter;
2150    }
2151
2152    /**
2153     * @return Returns a reference to <code>this</code> for easy method chaining
2154     */
2155    public ImagingStudy setInterpreter(List<Reference> theInterpreter) { 
2156      this.interpreter = theInterpreter;
2157      return this;
2158    }
2159
2160    public boolean hasInterpreter() { 
2161      if (this.interpreter == null)
2162        return false;
2163      for (Reference item : this.interpreter)
2164        if (!item.isEmpty())
2165          return true;
2166      return false;
2167    }
2168
2169    public Reference addInterpreter() { //3
2170      Reference t = new Reference();
2171      if (this.interpreter == null)
2172        this.interpreter = new ArrayList<Reference>();
2173      this.interpreter.add(t);
2174      return t;
2175    }
2176
2177    public ImagingStudy addInterpreter(Reference t) { //3
2178      if (t == null)
2179        return this;
2180      if (this.interpreter == null)
2181        this.interpreter = new ArrayList<Reference>();
2182      this.interpreter.add(t);
2183      return this;
2184    }
2185
2186    /**
2187     * @return The first repetition of repeating field {@link #interpreter}, creating it if it does not already exist
2188     */
2189    public Reference getInterpreterFirstRep() { 
2190      if (getInterpreter().isEmpty()) {
2191        addInterpreter();
2192      }
2193      return getInterpreter().get(0);
2194    }
2195
2196    /**
2197     * @deprecated Use Reference#setResource(IBaseResource) instead
2198     */
2199    @Deprecated
2200    public List<Practitioner> getInterpreterTarget() { 
2201      if (this.interpreterTarget == null)
2202        this.interpreterTarget = new ArrayList<Practitioner>();
2203      return this.interpreterTarget;
2204    }
2205
2206    /**
2207     * @deprecated Use Reference#setResource(IBaseResource) instead
2208     */
2209    @Deprecated
2210    public Practitioner addInterpreterTarget() { 
2211      Practitioner r = new Practitioner();
2212      if (this.interpreterTarget == null)
2213        this.interpreterTarget = new ArrayList<Practitioner>();
2214      this.interpreterTarget.add(r);
2215      return r;
2216    }
2217
2218    /**
2219     * @return {@link #endpoint} (The network service providing access (e.g., query, view, or retrieval) for the study. See implementation notes for information about using DICOM endpoints. A study-level endpoint applies to each series in the study, unless overridden by a series-level endpoint with the same Endpoint.type.)
2220     */
2221    public List<Reference> getEndpoint() { 
2222      if (this.endpoint == null)
2223        this.endpoint = new ArrayList<Reference>();
2224      return this.endpoint;
2225    }
2226
2227    /**
2228     * @return Returns a reference to <code>this</code> for easy method chaining
2229     */
2230    public ImagingStudy setEndpoint(List<Reference> theEndpoint) { 
2231      this.endpoint = theEndpoint;
2232      return this;
2233    }
2234
2235    public boolean hasEndpoint() { 
2236      if (this.endpoint == null)
2237        return false;
2238      for (Reference item : this.endpoint)
2239        if (!item.isEmpty())
2240          return true;
2241      return false;
2242    }
2243
2244    public Reference addEndpoint() { //3
2245      Reference t = new Reference();
2246      if (this.endpoint == null)
2247        this.endpoint = new ArrayList<Reference>();
2248      this.endpoint.add(t);
2249      return t;
2250    }
2251
2252    public ImagingStudy addEndpoint(Reference t) { //3
2253      if (t == null)
2254        return this;
2255      if (this.endpoint == null)
2256        this.endpoint = new ArrayList<Reference>();
2257      this.endpoint.add(t);
2258      return this;
2259    }
2260
2261    /**
2262     * @return The first repetition of repeating field {@link #endpoint}, creating it if it does not already exist
2263     */
2264    public Reference getEndpointFirstRep() { 
2265      if (getEndpoint().isEmpty()) {
2266        addEndpoint();
2267      }
2268      return getEndpoint().get(0);
2269    }
2270
2271    /**
2272     * @deprecated Use Reference#setResource(IBaseResource) instead
2273     */
2274    @Deprecated
2275    public List<Endpoint> getEndpointTarget() { 
2276      if (this.endpointTarget == null)
2277        this.endpointTarget = new ArrayList<Endpoint>();
2278      return this.endpointTarget;
2279    }
2280
2281    /**
2282     * @deprecated Use Reference#setResource(IBaseResource) instead
2283     */
2284    @Deprecated
2285    public Endpoint addEndpointTarget() { 
2286      Endpoint r = new Endpoint();
2287      if (this.endpointTarget == null)
2288        this.endpointTarget = new ArrayList<Endpoint>();
2289      this.endpointTarget.add(r);
2290      return r;
2291    }
2292
2293    /**
2294     * @return {@link #numberOfSeries} (Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfSeries" gives direct access to the value
2295     */
2296    public UnsignedIntType getNumberOfSeriesElement() { 
2297      if (this.numberOfSeries == null)
2298        if (Configuration.errorOnAutoCreate())
2299          throw new Error("Attempt to auto-create ImagingStudy.numberOfSeries");
2300        else if (Configuration.doAutoCreate())
2301          this.numberOfSeries = new UnsignedIntType(); // bb
2302      return this.numberOfSeries;
2303    }
2304
2305    public boolean hasNumberOfSeriesElement() { 
2306      return this.numberOfSeries != null && !this.numberOfSeries.isEmpty();
2307    }
2308
2309    public boolean hasNumberOfSeries() { 
2310      return this.numberOfSeries != null && !this.numberOfSeries.isEmpty();
2311    }
2312
2313    /**
2314     * @param value {@link #numberOfSeries} (Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfSeries" gives direct access to the value
2315     */
2316    public ImagingStudy setNumberOfSeriesElement(UnsignedIntType value) { 
2317      this.numberOfSeries = value;
2318      return this;
2319    }
2320
2321    /**
2322     * @return Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.
2323     */
2324    public int getNumberOfSeries() { 
2325      return this.numberOfSeries == null || this.numberOfSeries.isEmpty() ? 0 : this.numberOfSeries.getValue();
2326    }
2327
2328    /**
2329     * @param value Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.
2330     */
2331    public ImagingStudy setNumberOfSeries(int value) { 
2332        if (this.numberOfSeries == null)
2333          this.numberOfSeries = new UnsignedIntType();
2334        this.numberOfSeries.setValue(value);
2335      return this;
2336    }
2337
2338    /**
2339     * @return {@link #numberOfInstances} (Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfInstances" gives direct access to the value
2340     */
2341    public UnsignedIntType getNumberOfInstancesElement() { 
2342      if (this.numberOfInstances == null)
2343        if (Configuration.errorOnAutoCreate())
2344          throw new Error("Attempt to auto-create ImagingStudy.numberOfInstances");
2345        else if (Configuration.doAutoCreate())
2346          this.numberOfInstances = new UnsignedIntType(); // bb
2347      return this.numberOfInstances;
2348    }
2349
2350    public boolean hasNumberOfInstancesElement() { 
2351      return this.numberOfInstances != null && !this.numberOfInstances.isEmpty();
2352    }
2353
2354    public boolean hasNumberOfInstances() { 
2355      return this.numberOfInstances != null && !this.numberOfInstances.isEmpty();
2356    }
2357
2358    /**
2359     * @param value {@link #numberOfInstances} (Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.). This is the underlying object with id, value and extensions. The accessor "getNumberOfInstances" gives direct access to the value
2360     */
2361    public ImagingStudy setNumberOfInstancesElement(UnsignedIntType value) { 
2362      this.numberOfInstances = value;
2363      return this;
2364    }
2365
2366    /**
2367     * @return Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
2368     */
2369    public int getNumberOfInstances() { 
2370      return this.numberOfInstances == null || this.numberOfInstances.isEmpty() ? 0 : this.numberOfInstances.getValue();
2371    }
2372
2373    /**
2374     * @param value Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.
2375     */
2376    public ImagingStudy setNumberOfInstances(int value) { 
2377        if (this.numberOfInstances == null)
2378          this.numberOfInstances = new UnsignedIntType();
2379        this.numberOfInstances.setValue(value);
2380      return this;
2381    }
2382
2383    /**
2384     * @return {@link #procedureReference} (A reference to the performed Procedure.)
2385     */
2386    public List<Reference> getProcedureReference() { 
2387      if (this.procedureReference == null)
2388        this.procedureReference = new ArrayList<Reference>();
2389      return this.procedureReference;
2390    }
2391
2392    /**
2393     * @return Returns a reference to <code>this</code> for easy method chaining
2394     */
2395    public ImagingStudy setProcedureReference(List<Reference> theProcedureReference) { 
2396      this.procedureReference = theProcedureReference;
2397      return this;
2398    }
2399
2400    public boolean hasProcedureReference() { 
2401      if (this.procedureReference == null)
2402        return false;
2403      for (Reference item : this.procedureReference)
2404        if (!item.isEmpty())
2405          return true;
2406      return false;
2407    }
2408
2409    public Reference addProcedureReference() { //3
2410      Reference t = new Reference();
2411      if (this.procedureReference == null)
2412        this.procedureReference = new ArrayList<Reference>();
2413      this.procedureReference.add(t);
2414      return t;
2415    }
2416
2417    public ImagingStudy addProcedureReference(Reference t) { //3
2418      if (t == null)
2419        return this;
2420      if (this.procedureReference == null)
2421        this.procedureReference = new ArrayList<Reference>();
2422      this.procedureReference.add(t);
2423      return this;
2424    }
2425
2426    /**
2427     * @return The first repetition of repeating field {@link #procedureReference}, creating it if it does not already exist
2428     */
2429    public Reference getProcedureReferenceFirstRep() { 
2430      if (getProcedureReference().isEmpty()) {
2431        addProcedureReference();
2432      }
2433      return getProcedureReference().get(0);
2434    }
2435
2436    /**
2437     * @deprecated Use Reference#setResource(IBaseResource) instead
2438     */
2439    @Deprecated
2440    public List<Procedure> getProcedureReferenceTarget() { 
2441      if (this.procedureReferenceTarget == null)
2442        this.procedureReferenceTarget = new ArrayList<Procedure>();
2443      return this.procedureReferenceTarget;
2444    }
2445
2446    /**
2447     * @deprecated Use Reference#setResource(IBaseResource) instead
2448     */
2449    @Deprecated
2450    public Procedure addProcedureReferenceTarget() { 
2451      Procedure r = new Procedure();
2452      if (this.procedureReferenceTarget == null)
2453        this.procedureReferenceTarget = new ArrayList<Procedure>();
2454      this.procedureReferenceTarget.add(r);
2455      return r;
2456    }
2457
2458    /**
2459     * @return {@link #procedureCode} (The code for the performed procedure type.)
2460     */
2461    public List<CodeableConcept> getProcedureCode() { 
2462      if (this.procedureCode == null)
2463        this.procedureCode = new ArrayList<CodeableConcept>();
2464      return this.procedureCode;
2465    }
2466
2467    /**
2468     * @return Returns a reference to <code>this</code> for easy method chaining
2469     */
2470    public ImagingStudy setProcedureCode(List<CodeableConcept> theProcedureCode) { 
2471      this.procedureCode = theProcedureCode;
2472      return this;
2473    }
2474
2475    public boolean hasProcedureCode() { 
2476      if (this.procedureCode == null)
2477        return false;
2478      for (CodeableConcept item : this.procedureCode)
2479        if (!item.isEmpty())
2480          return true;
2481      return false;
2482    }
2483
2484    public CodeableConcept addProcedureCode() { //3
2485      CodeableConcept t = new CodeableConcept();
2486      if (this.procedureCode == null)
2487        this.procedureCode = new ArrayList<CodeableConcept>();
2488      this.procedureCode.add(t);
2489      return t;
2490    }
2491
2492    public ImagingStudy addProcedureCode(CodeableConcept t) { //3
2493      if (t == null)
2494        return this;
2495      if (this.procedureCode == null)
2496        this.procedureCode = new ArrayList<CodeableConcept>();
2497      this.procedureCode.add(t);
2498      return this;
2499    }
2500
2501    /**
2502     * @return The first repetition of repeating field {@link #procedureCode}, creating it if it does not already exist
2503     */
2504    public CodeableConcept getProcedureCodeFirstRep() { 
2505      if (getProcedureCode().isEmpty()) {
2506        addProcedureCode();
2507      }
2508      return getProcedureCode().get(0);
2509    }
2510
2511    /**
2512     * @return {@link #reason} (Description of clinical condition indicating why the ImagingStudy was requested.)
2513     */
2514    public CodeableConcept getReason() { 
2515      if (this.reason == null)
2516        if (Configuration.errorOnAutoCreate())
2517          throw new Error("Attempt to auto-create ImagingStudy.reason");
2518        else if (Configuration.doAutoCreate())
2519          this.reason = new CodeableConcept(); // cc
2520      return this.reason;
2521    }
2522
2523    public boolean hasReason() { 
2524      return this.reason != null && !this.reason.isEmpty();
2525    }
2526
2527    /**
2528     * @param value {@link #reason} (Description of clinical condition indicating why the ImagingStudy was requested.)
2529     */
2530    public ImagingStudy setReason(CodeableConcept value) { 
2531      this.reason = value;
2532      return this;
2533    }
2534
2535    /**
2536     * @return {@link #description} (Institution-generated description or classification of the Study performed.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2537     */
2538    public StringType getDescriptionElement() { 
2539      if (this.description == null)
2540        if (Configuration.errorOnAutoCreate())
2541          throw new Error("Attempt to auto-create ImagingStudy.description");
2542        else if (Configuration.doAutoCreate())
2543          this.description = new StringType(); // bb
2544      return this.description;
2545    }
2546
2547    public boolean hasDescriptionElement() { 
2548      return this.description != null && !this.description.isEmpty();
2549    }
2550
2551    public boolean hasDescription() { 
2552      return this.description != null && !this.description.isEmpty();
2553    }
2554
2555    /**
2556     * @param value {@link #description} (Institution-generated description or classification of the Study performed.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
2557     */
2558    public ImagingStudy setDescriptionElement(StringType value) { 
2559      this.description = value;
2560      return this;
2561    }
2562
2563    /**
2564     * @return Institution-generated description or classification of the Study performed.
2565     */
2566    public String getDescription() { 
2567      return this.description == null ? null : this.description.getValue();
2568    }
2569
2570    /**
2571     * @param value Institution-generated description or classification of the Study performed.
2572     */
2573    public ImagingStudy setDescription(String value) { 
2574      if (Utilities.noString(value))
2575        this.description = null;
2576      else {
2577        if (this.description == null)
2578          this.description = new StringType();
2579        this.description.setValue(value);
2580      }
2581      return this;
2582    }
2583
2584    /**
2585     * @return {@link #series} (Each study has one or more series of images or other content.)
2586     */
2587    public List<ImagingStudySeriesComponent> getSeries() { 
2588      if (this.series == null)
2589        this.series = new ArrayList<ImagingStudySeriesComponent>();
2590      return this.series;
2591    }
2592
2593    /**
2594     * @return Returns a reference to <code>this</code> for easy method chaining
2595     */
2596    public ImagingStudy setSeries(List<ImagingStudySeriesComponent> theSeries) { 
2597      this.series = theSeries;
2598      return this;
2599    }
2600
2601    public boolean hasSeries() { 
2602      if (this.series == null)
2603        return false;
2604      for (ImagingStudySeriesComponent item : this.series)
2605        if (!item.isEmpty())
2606          return true;
2607      return false;
2608    }
2609
2610    public ImagingStudySeriesComponent addSeries() { //3
2611      ImagingStudySeriesComponent t = new ImagingStudySeriesComponent();
2612      if (this.series == null)
2613        this.series = new ArrayList<ImagingStudySeriesComponent>();
2614      this.series.add(t);
2615      return t;
2616    }
2617
2618    public ImagingStudy addSeries(ImagingStudySeriesComponent t) { //3
2619      if (t == null)
2620        return this;
2621      if (this.series == null)
2622        this.series = new ArrayList<ImagingStudySeriesComponent>();
2623      this.series.add(t);
2624      return this;
2625    }
2626
2627    /**
2628     * @return The first repetition of repeating field {@link #series}, creating it if it does not already exist
2629     */
2630    public ImagingStudySeriesComponent getSeriesFirstRep() { 
2631      if (getSeries().isEmpty()) {
2632        addSeries();
2633      }
2634      return getSeries().get(0);
2635    }
2636
2637      protected void listChildren(List<Property> childrenList) {
2638        super.listChildren(childrenList);
2639        childrenList.add(new Property("uid", "oid", "Formal identifier for the study.", 0, java.lang.Integer.MAX_VALUE, uid));
2640        childrenList.add(new Property("accession", "Identifier", "Accession Number is an identifier related to some aspect of imaging workflow and data management. Usage may vary across different institutions.  See for instance [IHE Radiology Technical Framework Volume 1 Appendix A](http://www.ihe.net/uploadedFiles/Documents/Radiology/IHE_RAD_TF_Rev13.0_Vol1_FT_2014-07-30.pdf).", 0, java.lang.Integer.MAX_VALUE, accession));
2641        childrenList.add(new Property("identifier", "Identifier", "Other identifiers for the study.", 0, java.lang.Integer.MAX_VALUE, identifier));
2642        childrenList.add(new Property("availability", "code", "Availability of study (online, offline, or nearline).", 0, java.lang.Integer.MAX_VALUE, availability));
2643        childrenList.add(new Property("modalityList", "Coding", "A list of all the Series.ImageModality values that are actual acquisition modalities, i.e. those in the DICOM Context Group 29 (value set OID 1.2.840.10008.6.1.19).", 0, java.lang.Integer.MAX_VALUE, modalityList));
2644        childrenList.add(new Property("patient", "Reference(Patient)", "The patient imaged in the study.", 0, java.lang.Integer.MAX_VALUE, patient));
2645        childrenList.add(new Property("context", "Reference(Encounter|EpisodeOfCare)", "The encounter or episode at which the request is initiated.", 0, java.lang.Integer.MAX_VALUE, context));
2646        childrenList.add(new Property("started", "dateTime", "Date and time the study started.", 0, java.lang.Integer.MAX_VALUE, started));
2647        childrenList.add(new Property("basedOn", "Reference(ReferralRequest|CarePlan|ProcedureRequest)", "A list of the diagnostic requests that resulted in this imaging study being performed.", 0, java.lang.Integer.MAX_VALUE, basedOn));
2648        childrenList.add(new Property("referrer", "Reference(Practitioner)", "The requesting/referring physician.", 0, java.lang.Integer.MAX_VALUE, referrer));
2649        childrenList.add(new Property("interpreter", "Reference(Practitioner)", "Who read the study and interpreted the images or other content.", 0, java.lang.Integer.MAX_VALUE, interpreter));
2650        childrenList.add(new Property("endpoint", "Reference(Endpoint)", "The network service providing access (e.g., query, view, or retrieval) for the study. See implementation notes for information about using DICOM endpoints. A study-level endpoint applies to each series in the study, unless overridden by a series-level endpoint with the same Endpoint.type.", 0, java.lang.Integer.MAX_VALUE, endpoint));
2651        childrenList.add(new Property("numberOfSeries", "unsignedInt", "Number of Series in the Study. This value given may be larger than the number of series elements this Resource contains due to resource availability, security, or other factors. This element should be present if any series elements are present.", 0, java.lang.Integer.MAX_VALUE, numberOfSeries));
2652        childrenList.add(new Property("numberOfInstances", "unsignedInt", "Number of SOP Instances in Study. This value given may be larger than the number of instance elements this resource contains due to resource availability, security, or other factors. This element should be present if any instance elements are present.", 0, java.lang.Integer.MAX_VALUE, numberOfInstances));
2653        childrenList.add(new Property("procedureReference", "Reference(Procedure)", "A reference to the performed Procedure.", 0, java.lang.Integer.MAX_VALUE, procedureReference));
2654        childrenList.add(new Property("procedureCode", "CodeableConcept", "The code for the performed procedure type.", 0, java.lang.Integer.MAX_VALUE, procedureCode));
2655        childrenList.add(new Property("reason", "CodeableConcept", "Description of clinical condition indicating why the ImagingStudy was requested.", 0, java.lang.Integer.MAX_VALUE, reason));
2656        childrenList.add(new Property("description", "string", "Institution-generated description or classification of the Study performed.", 0, java.lang.Integer.MAX_VALUE, description));
2657        childrenList.add(new Property("series", "", "Each study has one or more series of images or other content.", 0, java.lang.Integer.MAX_VALUE, series));
2658      }
2659
2660      @Override
2661      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2662        switch (hash) {
2663        case 115792: /*uid*/ return this.uid == null ? new Base[0] : new Base[] {this.uid}; // OidType
2664        case -2115028956: /*accession*/ return this.accession == null ? new Base[0] : new Base[] {this.accession}; // Identifier
2665        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
2666        case 1997542747: /*availability*/ return this.availability == null ? new Base[0] : new Base[] {this.availability}; // Enumeration<InstanceAvailability>
2667        case -1030238433: /*modalityList*/ return this.modalityList == null ? new Base[0] : this.modalityList.toArray(new Base[this.modalityList.size()]); // Coding
2668        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
2669        case 951530927: /*context*/ return this.context == null ? new Base[0] : new Base[] {this.context}; // Reference
2670        case -1897185151: /*started*/ return this.started == null ? new Base[0] : new Base[] {this.started}; // DateTimeType
2671        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
2672        case -722568161: /*referrer*/ return this.referrer == null ? new Base[0] : new Base[] {this.referrer}; // Reference
2673        case -2008009094: /*interpreter*/ return this.interpreter == null ? new Base[0] : this.interpreter.toArray(new Base[this.interpreter.size()]); // Reference
2674        case 1741102485: /*endpoint*/ return this.endpoint == null ? new Base[0] : this.endpoint.toArray(new Base[this.endpoint.size()]); // Reference
2675        case 1920000407: /*numberOfSeries*/ return this.numberOfSeries == null ? new Base[0] : new Base[] {this.numberOfSeries}; // UnsignedIntType
2676        case -1043544226: /*numberOfInstances*/ return this.numberOfInstances == null ? new Base[0] : new Base[] {this.numberOfInstances}; // UnsignedIntType
2677        case 881809848: /*procedureReference*/ return this.procedureReference == null ? new Base[0] : this.procedureReference.toArray(new Base[this.procedureReference.size()]); // Reference
2678        case -698023072: /*procedureCode*/ return this.procedureCode == null ? new Base[0] : this.procedureCode.toArray(new Base[this.procedureCode.size()]); // CodeableConcept
2679        case -934964668: /*reason*/ return this.reason == null ? new Base[0] : new Base[] {this.reason}; // CodeableConcept
2680        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2681        case -905838985: /*series*/ return this.series == null ? new Base[0] : this.series.toArray(new Base[this.series.size()]); // ImagingStudySeriesComponent
2682        default: return super.getProperty(hash, name, checkValid);
2683        }
2684
2685      }
2686
2687      @Override
2688      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2689        switch (hash) {
2690        case 115792: // uid
2691          this.uid = castToOid(value); // OidType
2692          return value;
2693        case -2115028956: // accession
2694          this.accession = castToIdentifier(value); // Identifier
2695          return value;
2696        case -1618432855: // identifier
2697          this.getIdentifier().add(castToIdentifier(value)); // Identifier
2698          return value;
2699        case 1997542747: // availability
2700          value = new InstanceAvailabilityEnumFactory().fromType(castToCode(value));
2701          this.availability = (Enumeration) value; // Enumeration<InstanceAvailability>
2702          return value;
2703        case -1030238433: // modalityList
2704          this.getModalityList().add(castToCoding(value)); // Coding
2705          return value;
2706        case -791418107: // patient
2707          this.patient = castToReference(value); // Reference
2708          return value;
2709        case 951530927: // context
2710          this.context = castToReference(value); // Reference
2711          return value;
2712        case -1897185151: // started
2713          this.started = castToDateTime(value); // DateTimeType
2714          return value;
2715        case -332612366: // basedOn
2716          this.getBasedOn().add(castToReference(value)); // Reference
2717          return value;
2718        case -722568161: // referrer
2719          this.referrer = castToReference(value); // Reference
2720          return value;
2721        case -2008009094: // interpreter
2722          this.getInterpreter().add(castToReference(value)); // Reference
2723          return value;
2724        case 1741102485: // endpoint
2725          this.getEndpoint().add(castToReference(value)); // Reference
2726          return value;
2727        case 1920000407: // numberOfSeries
2728          this.numberOfSeries = castToUnsignedInt(value); // UnsignedIntType
2729          return value;
2730        case -1043544226: // numberOfInstances
2731          this.numberOfInstances = castToUnsignedInt(value); // UnsignedIntType
2732          return value;
2733        case 881809848: // procedureReference
2734          this.getProcedureReference().add(castToReference(value)); // Reference
2735          return value;
2736        case -698023072: // procedureCode
2737          this.getProcedureCode().add(castToCodeableConcept(value)); // CodeableConcept
2738          return value;
2739        case -934964668: // reason
2740          this.reason = castToCodeableConcept(value); // CodeableConcept
2741          return value;
2742        case -1724546052: // description
2743          this.description = castToString(value); // StringType
2744          return value;
2745        case -905838985: // series
2746          this.getSeries().add((ImagingStudySeriesComponent) value); // ImagingStudySeriesComponent
2747          return value;
2748        default: return super.setProperty(hash, name, value);
2749        }
2750
2751      }
2752
2753      @Override
2754      public Base setProperty(String name, Base value) throws FHIRException {
2755        if (name.equals("uid")) {
2756          this.uid = castToOid(value); // OidType
2757        } else if (name.equals("accession")) {
2758          this.accession = castToIdentifier(value); // Identifier
2759        } else if (name.equals("identifier")) {
2760          this.getIdentifier().add(castToIdentifier(value));
2761        } else if (name.equals("availability")) {
2762          value = new InstanceAvailabilityEnumFactory().fromType(castToCode(value));
2763          this.availability = (Enumeration) value; // Enumeration<InstanceAvailability>
2764        } else if (name.equals("modalityList")) {
2765          this.getModalityList().add(castToCoding(value));
2766        } else if (name.equals("patient")) {
2767          this.patient = castToReference(value); // Reference
2768        } else if (name.equals("context")) {
2769          this.context = castToReference(value); // Reference
2770        } else if (name.equals("started")) {
2771          this.started = castToDateTime(value); // DateTimeType
2772        } else if (name.equals("basedOn")) {
2773          this.getBasedOn().add(castToReference(value));
2774        } else if (name.equals("referrer")) {
2775          this.referrer = castToReference(value); // Reference
2776        } else if (name.equals("interpreter")) {
2777          this.getInterpreter().add(castToReference(value));
2778        } else if (name.equals("endpoint")) {
2779          this.getEndpoint().add(castToReference(value));
2780        } else if (name.equals("numberOfSeries")) {
2781          this.numberOfSeries = castToUnsignedInt(value); // UnsignedIntType
2782        } else if (name.equals("numberOfInstances")) {
2783          this.numberOfInstances = castToUnsignedInt(value); // UnsignedIntType
2784        } else if (name.equals("procedureReference")) {
2785          this.getProcedureReference().add(castToReference(value));
2786        } else if (name.equals("procedureCode")) {
2787          this.getProcedureCode().add(castToCodeableConcept(value));
2788        } else if (name.equals("reason")) {
2789          this.reason = castToCodeableConcept(value); // CodeableConcept
2790        } else if (name.equals("description")) {
2791          this.description = castToString(value); // StringType
2792        } else if (name.equals("series")) {
2793          this.getSeries().add((ImagingStudySeriesComponent) value);
2794        } else
2795          return super.setProperty(name, value);
2796        return value;
2797      }
2798
2799      @Override
2800      public Base makeProperty(int hash, String name) throws FHIRException {
2801        switch (hash) {
2802        case 115792:  return getUidElement();
2803        case -2115028956:  return getAccession(); 
2804        case -1618432855:  return addIdentifier(); 
2805        case 1997542747:  return getAvailabilityElement();
2806        case -1030238433:  return addModalityList(); 
2807        case -791418107:  return getPatient(); 
2808        case 951530927:  return getContext(); 
2809        case -1897185151:  return getStartedElement();
2810        case -332612366:  return addBasedOn(); 
2811        case -722568161:  return getReferrer(); 
2812        case -2008009094:  return addInterpreter(); 
2813        case 1741102485:  return addEndpoint(); 
2814        case 1920000407:  return getNumberOfSeriesElement();
2815        case -1043544226:  return getNumberOfInstancesElement();
2816        case 881809848:  return addProcedureReference(); 
2817        case -698023072:  return addProcedureCode(); 
2818        case -934964668:  return getReason(); 
2819        case -1724546052:  return getDescriptionElement();
2820        case -905838985:  return addSeries(); 
2821        default: return super.makeProperty(hash, name);
2822        }
2823
2824      }
2825
2826      @Override
2827      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2828        switch (hash) {
2829        case 115792: /*uid*/ return new String[] {"oid"};
2830        case -2115028956: /*accession*/ return new String[] {"Identifier"};
2831        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
2832        case 1997542747: /*availability*/ return new String[] {"code"};
2833        case -1030238433: /*modalityList*/ return new String[] {"Coding"};
2834        case -791418107: /*patient*/ return new String[] {"Reference"};
2835        case 951530927: /*context*/ return new String[] {"Reference"};
2836        case -1897185151: /*started*/ return new String[] {"dateTime"};
2837        case -332612366: /*basedOn*/ return new String[] {"Reference"};
2838        case -722568161: /*referrer*/ return new String[] {"Reference"};
2839        case -2008009094: /*interpreter*/ return new String[] {"Reference"};
2840        case 1741102485: /*endpoint*/ return new String[] {"Reference"};
2841        case 1920000407: /*numberOfSeries*/ return new String[] {"unsignedInt"};
2842        case -1043544226: /*numberOfInstances*/ return new String[] {"unsignedInt"};
2843        case 881809848: /*procedureReference*/ return new String[] {"Reference"};
2844        case -698023072: /*procedureCode*/ return new String[] {"CodeableConcept"};
2845        case -934964668: /*reason*/ return new String[] {"CodeableConcept"};
2846        case -1724546052: /*description*/ return new String[] {"string"};
2847        case -905838985: /*series*/ return new String[] {};
2848        default: return super.getTypesForProperty(hash, name);
2849        }
2850
2851      }
2852
2853      @Override
2854      public Base addChild(String name) throws FHIRException {
2855        if (name.equals("uid")) {
2856          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.uid");
2857        }
2858        else if (name.equals("accession")) {
2859          this.accession = new Identifier();
2860          return this.accession;
2861        }
2862        else if (name.equals("identifier")) {
2863          return addIdentifier();
2864        }
2865        else if (name.equals("availability")) {
2866          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.availability");
2867        }
2868        else if (name.equals("modalityList")) {
2869          return addModalityList();
2870        }
2871        else if (name.equals("patient")) {
2872          this.patient = new Reference();
2873          return this.patient;
2874        }
2875        else if (name.equals("context")) {
2876          this.context = new Reference();
2877          return this.context;
2878        }
2879        else if (name.equals("started")) {
2880          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.started");
2881        }
2882        else if (name.equals("basedOn")) {
2883          return addBasedOn();
2884        }
2885        else if (name.equals("referrer")) {
2886          this.referrer = new Reference();
2887          return this.referrer;
2888        }
2889        else if (name.equals("interpreter")) {
2890          return addInterpreter();
2891        }
2892        else if (name.equals("endpoint")) {
2893          return addEndpoint();
2894        }
2895        else if (name.equals("numberOfSeries")) {
2896          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.numberOfSeries");
2897        }
2898        else if (name.equals("numberOfInstances")) {
2899          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.numberOfInstances");
2900        }
2901        else if (name.equals("procedureReference")) {
2902          return addProcedureReference();
2903        }
2904        else if (name.equals("procedureCode")) {
2905          return addProcedureCode();
2906        }
2907        else if (name.equals("reason")) {
2908          this.reason = new CodeableConcept();
2909          return this.reason;
2910        }
2911        else if (name.equals("description")) {
2912          throw new FHIRException("Cannot call addChild on a primitive type ImagingStudy.description");
2913        }
2914        else if (name.equals("series")) {
2915          return addSeries();
2916        }
2917        else
2918          return super.addChild(name);
2919      }
2920
2921  public String fhirType() {
2922    return "ImagingStudy";
2923
2924  }
2925
2926      public ImagingStudy copy() {
2927        ImagingStudy dst = new ImagingStudy();
2928        copyValues(dst);
2929        dst.uid = uid == null ? null : uid.copy();
2930        dst.accession = accession == null ? null : accession.copy();
2931        if (identifier != null) {
2932          dst.identifier = new ArrayList<Identifier>();
2933          for (Identifier i : identifier)
2934            dst.identifier.add(i.copy());
2935        };
2936        dst.availability = availability == null ? null : availability.copy();
2937        if (modalityList != null) {
2938          dst.modalityList = new ArrayList<Coding>();
2939          for (Coding i : modalityList)
2940            dst.modalityList.add(i.copy());
2941        };
2942        dst.patient = patient == null ? null : patient.copy();
2943        dst.context = context == null ? null : context.copy();
2944        dst.started = started == null ? null : started.copy();
2945        if (basedOn != null) {
2946          dst.basedOn = new ArrayList<Reference>();
2947          for (Reference i : basedOn)
2948            dst.basedOn.add(i.copy());
2949        };
2950        dst.referrer = referrer == null ? null : referrer.copy();
2951        if (interpreter != null) {
2952          dst.interpreter = new ArrayList<Reference>();
2953          for (Reference i : interpreter)
2954            dst.interpreter.add(i.copy());
2955        };
2956        if (endpoint != null) {
2957          dst.endpoint = new ArrayList<Reference>();
2958          for (Reference i : endpoint)
2959            dst.endpoint.add(i.copy());
2960        };
2961        dst.numberOfSeries = numberOfSeries == null ? null : numberOfSeries.copy();
2962        dst.numberOfInstances = numberOfInstances == null ? null : numberOfInstances.copy();
2963        if (procedureReference != null) {
2964          dst.procedureReference = new ArrayList<Reference>();
2965          for (Reference i : procedureReference)
2966            dst.procedureReference.add(i.copy());
2967        };
2968        if (procedureCode != null) {
2969          dst.procedureCode = new ArrayList<CodeableConcept>();
2970          for (CodeableConcept i : procedureCode)
2971            dst.procedureCode.add(i.copy());
2972        };
2973        dst.reason = reason == null ? null : reason.copy();
2974        dst.description = description == null ? null : description.copy();
2975        if (series != null) {
2976          dst.series = new ArrayList<ImagingStudySeriesComponent>();
2977          for (ImagingStudySeriesComponent i : series)
2978            dst.series.add(i.copy());
2979        };
2980        return dst;
2981      }
2982
2983      protected ImagingStudy typedCopy() {
2984        return copy();
2985      }
2986
2987      @Override
2988      public boolean equalsDeep(Base other) {
2989        if (!super.equalsDeep(other))
2990          return false;
2991        if (!(other instanceof ImagingStudy))
2992          return false;
2993        ImagingStudy o = (ImagingStudy) other;
2994        return compareDeep(uid, o.uid, true) && compareDeep(accession, o.accession, true) && compareDeep(identifier, o.identifier, true)
2995           && compareDeep(availability, o.availability, true) && compareDeep(modalityList, o.modalityList, true)
2996           && compareDeep(patient, o.patient, true) && compareDeep(context, o.context, true) && compareDeep(started, o.started, true)
2997           && compareDeep(basedOn, o.basedOn, true) && compareDeep(referrer, o.referrer, true) && compareDeep(interpreter, o.interpreter, true)
2998           && compareDeep(endpoint, o.endpoint, true) && compareDeep(numberOfSeries, o.numberOfSeries, true)
2999           && compareDeep(numberOfInstances, o.numberOfInstances, true) && compareDeep(procedureReference, o.procedureReference, true)
3000           && compareDeep(procedureCode, o.procedureCode, true) && compareDeep(reason, o.reason, true) && compareDeep(description, o.description, true)
3001           && compareDeep(series, o.series, true);
3002      }
3003
3004      @Override
3005      public boolean equalsShallow(Base other) {
3006        if (!super.equalsShallow(other))
3007          return false;
3008        if (!(other instanceof ImagingStudy))
3009          return false;
3010        ImagingStudy o = (ImagingStudy) other;
3011        return compareValues(uid, o.uid, true) && compareValues(availability, o.availability, true) && compareValues(started, o.started, true)
3012           && compareValues(numberOfSeries, o.numberOfSeries, true) && compareValues(numberOfInstances, o.numberOfInstances, true)
3013           && compareValues(description, o.description, true);
3014      }
3015
3016      public boolean isEmpty() {
3017        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(uid, accession, identifier
3018          , availability, modalityList, patient, context, started, basedOn, referrer, interpreter
3019          , endpoint, numberOfSeries, numberOfInstances, procedureReference, procedureCode, reason
3020          , description, series);
3021      }
3022
3023  @Override
3024  public ResourceType getResourceType() {
3025    return ResourceType.ImagingStudy;
3026   }
3027
3028 /**
3029   * Search parameter: <b>identifier</b>
3030   * <p>
3031   * Description: <b>Other identifiers for the Study</b><br>
3032   * Type: <b>token</b><br>
3033   * Path: <b>ImagingStudy.identifier</b><br>
3034   * </p>
3035   */
3036  @SearchParamDefinition(name="identifier", path="ImagingStudy.identifier", description="Other identifiers for the Study", type="token" )
3037  public static final String SP_IDENTIFIER = "identifier";
3038 /**
3039   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
3040   * <p>
3041   * Description: <b>Other identifiers for the Study</b><br>
3042   * Type: <b>token</b><br>
3043   * Path: <b>ImagingStudy.identifier</b><br>
3044   * </p>
3045   */
3046  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
3047
3048 /**
3049   * Search parameter: <b>reason</b>
3050   * <p>
3051   * Description: <b>The reason for the study</b><br>
3052   * Type: <b>token</b><br>
3053   * Path: <b>ImagingStudy.reason</b><br>
3054   * </p>
3055   */
3056  @SearchParamDefinition(name="reason", path="ImagingStudy.reason", description="The reason for the study", type="token" )
3057  public static final String SP_REASON = "reason";
3058 /**
3059   * <b>Fluent Client</b> search parameter constant for <b>reason</b>
3060   * <p>
3061   * Description: <b>The reason for the study</b><br>
3062   * Type: <b>token</b><br>
3063   * Path: <b>ImagingStudy.reason</b><br>
3064   * </p>
3065   */
3066  public static final ca.uhn.fhir.rest.gclient.TokenClientParam REASON = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_REASON);
3067
3068 /**
3069   * Search parameter: <b>study</b>
3070   * <p>
3071   * Description: <b>The study identifier for the image</b><br>
3072   * Type: <b>uri</b><br>
3073   * Path: <b>ImagingStudy.uid</b><br>
3074   * </p>
3075   */
3076  @SearchParamDefinition(name="study", path="ImagingStudy.uid", description="The study identifier for the image", type="uri" )
3077  public static final String SP_STUDY = "study";
3078 /**
3079   * <b>Fluent Client</b> search parameter constant for <b>study</b>
3080   * <p>
3081   * Description: <b>The study identifier for the image</b><br>
3082   * Type: <b>uri</b><br>
3083   * Path: <b>ImagingStudy.uid</b><br>
3084   * </p>
3085   */
3086  public static final ca.uhn.fhir.rest.gclient.UriClientParam STUDY = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_STUDY);
3087
3088 /**
3089   * Search parameter: <b>dicom-class</b>
3090   * <p>
3091   * Description: <b>The type of the instance</b><br>
3092   * Type: <b>uri</b><br>
3093   * Path: <b>ImagingStudy.series.instance.sopClass</b><br>
3094   * </p>
3095   */
3096  @SearchParamDefinition(name="dicom-class", path="ImagingStudy.series.instance.sopClass", description="The type of the instance", type="uri" )
3097  public static final String SP_DICOM_CLASS = "dicom-class";
3098 /**
3099   * <b>Fluent Client</b> search parameter constant for <b>dicom-class</b>
3100   * <p>
3101   * Description: <b>The type of the instance</b><br>
3102   * Type: <b>uri</b><br>
3103   * Path: <b>ImagingStudy.series.instance.sopClass</b><br>
3104   * </p>
3105   */
3106  public static final ca.uhn.fhir.rest.gclient.UriClientParam DICOM_CLASS = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_DICOM_CLASS);
3107
3108 /**
3109   * Search parameter: <b>modality</b>
3110   * <p>
3111   * Description: <b>The modality of the series</b><br>
3112   * Type: <b>token</b><br>
3113   * Path: <b>ImagingStudy.series.modality</b><br>
3114   * </p>
3115   */
3116  @SearchParamDefinition(name="modality", path="ImagingStudy.series.modality", description="The modality of the series", type="token" )
3117  public static final String SP_MODALITY = "modality";
3118 /**
3119   * <b>Fluent Client</b> search parameter constant for <b>modality</b>
3120   * <p>
3121   * Description: <b>The modality of the series</b><br>
3122   * Type: <b>token</b><br>
3123   * Path: <b>ImagingStudy.series.modality</b><br>
3124   * </p>
3125   */
3126  public static final ca.uhn.fhir.rest.gclient.TokenClientParam MODALITY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_MODALITY);
3127
3128 /**
3129   * Search parameter: <b>bodysite</b>
3130   * <p>
3131   * Description: <b>The body site studied</b><br>
3132   * Type: <b>token</b><br>
3133   * Path: <b>ImagingStudy.series.bodySite</b><br>
3134   * </p>
3135   */
3136  @SearchParamDefinition(name="bodysite", path="ImagingStudy.series.bodySite", description="The body site studied", type="token" )
3137  public static final String SP_BODYSITE = "bodysite";
3138 /**
3139   * <b>Fluent Client</b> search parameter constant for <b>bodysite</b>
3140   * <p>
3141   * Description: <b>The body site studied</b><br>
3142   * Type: <b>token</b><br>
3143   * Path: <b>ImagingStudy.series.bodySite</b><br>
3144   * </p>
3145   */
3146  public static final ca.uhn.fhir.rest.gclient.TokenClientParam BODYSITE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_BODYSITE);
3147
3148 /**
3149   * Search parameter: <b>performer</b>
3150   * <p>
3151   * Description: <b>The person who performed the study</b><br>
3152   * Type: <b>reference</b><br>
3153   * Path: <b>ImagingStudy.series.performer</b><br>
3154   * </p>
3155   */
3156  @SearchParamDefinition(name="performer", path="ImagingStudy.series.performer", description="The person who performed the study", type="reference", target={Practitioner.class } )
3157  public static final String SP_PERFORMER = "performer";
3158 /**
3159   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
3160   * <p>
3161   * Description: <b>The person who performed the study</b><br>
3162   * Type: <b>reference</b><br>
3163   * Path: <b>ImagingStudy.series.performer</b><br>
3164   * </p>
3165   */
3166  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
3167
3168/**
3169   * Constant for fluent queries to be used to add include statements. Specifies
3170   * the path value of "<b>ImagingStudy:performer</b>".
3171   */
3172  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("ImagingStudy:performer").toLocked();
3173
3174 /**
3175   * Search parameter: <b>started</b>
3176   * <p>
3177   * Description: <b>When the study was started</b><br>
3178   * Type: <b>date</b><br>
3179   * Path: <b>ImagingStudy.started</b><br>
3180   * </p>
3181   */
3182  @SearchParamDefinition(name="started", path="ImagingStudy.started", description="When the study was started", type="date" )
3183  public static final String SP_STARTED = "started";
3184 /**
3185   * <b>Fluent Client</b> search parameter constant for <b>started</b>
3186   * <p>
3187   * Description: <b>When the study was started</b><br>
3188   * Type: <b>date</b><br>
3189   * Path: <b>ImagingStudy.started</b><br>
3190   * </p>
3191   */
3192  public static final ca.uhn.fhir.rest.gclient.DateClientParam STARTED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_STARTED);
3193
3194 /**
3195   * Search parameter: <b>accession</b>
3196   * <p>
3197   * Description: <b>The accession identifier for the study</b><br>
3198   * Type: <b>token</b><br>
3199   * Path: <b>ImagingStudy.accession</b><br>
3200   * </p>
3201   */
3202  @SearchParamDefinition(name="accession", path="ImagingStudy.accession", description="The accession identifier for the study", type="token" )
3203  public static final String SP_ACCESSION = "accession";
3204 /**
3205   * <b>Fluent Client</b> search parameter constant for <b>accession</b>
3206   * <p>
3207   * Description: <b>The accession identifier for the study</b><br>
3208   * Type: <b>token</b><br>
3209   * Path: <b>ImagingStudy.accession</b><br>
3210   * </p>
3211   */
3212  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACCESSION = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACCESSION);
3213
3214 /**
3215   * Search parameter: <b>uid</b>
3216   * <p>
3217   * Description: <b>The instance unique identifier</b><br>
3218   * Type: <b>uri</b><br>
3219   * Path: <b>ImagingStudy.series.instance.uid</b><br>
3220   * </p>
3221   */
3222  @SearchParamDefinition(name="uid", path="ImagingStudy.series.instance.uid", description="The instance unique identifier", type="uri" )
3223  public static final String SP_UID = "uid";
3224 /**
3225   * <b>Fluent Client</b> search parameter constant for <b>uid</b>
3226   * <p>
3227   * Description: <b>The instance unique identifier</b><br>
3228   * Type: <b>uri</b><br>
3229   * Path: <b>ImagingStudy.series.instance.uid</b><br>
3230   * </p>
3231   */
3232  public static final ca.uhn.fhir.rest.gclient.UriClientParam UID = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_UID);
3233
3234 /**
3235   * Search parameter: <b>endpoint</b>
3236   * <p>
3237   * Description: <b>The endpoint for te study or series</b><br>
3238   * Type: <b>reference</b><br>
3239   * Path: <b>ImagingStudy.endpoint, ImagingStudy.series.endpoint</b><br>
3240   * </p>
3241   */
3242  @SearchParamDefinition(name="endpoint", path="ImagingStudy.endpoint | ImagingStudy.series.endpoint", description="The endpoint for te study or series", type="reference", target={Endpoint.class } )
3243  public static final String SP_ENDPOINT = "endpoint";
3244 /**
3245   * <b>Fluent Client</b> search parameter constant for <b>endpoint</b>
3246   * <p>
3247   * Description: <b>The endpoint for te study or series</b><br>
3248   * Type: <b>reference</b><br>
3249   * Path: <b>ImagingStudy.endpoint, ImagingStudy.series.endpoint</b><br>
3250   * </p>
3251   */
3252  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENDPOINT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENDPOINT);
3253
3254/**
3255   * Constant for fluent queries to be used to add include statements. Specifies
3256   * the path value of "<b>ImagingStudy:endpoint</b>".
3257   */
3258  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENDPOINT = new ca.uhn.fhir.model.api.Include("ImagingStudy:endpoint").toLocked();
3259
3260 /**
3261   * Search parameter: <b>patient</b>
3262   * <p>
3263   * Description: <b>Who the study is about</b><br>
3264   * Type: <b>reference</b><br>
3265   * Path: <b>ImagingStudy.patient</b><br>
3266   * </p>
3267   */
3268  @SearchParamDefinition(name="patient", path="ImagingStudy.patient", description="Who the study is about", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
3269  public static final String SP_PATIENT = "patient";
3270 /**
3271   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
3272   * <p>
3273   * Description: <b>Who the study is about</b><br>
3274   * Type: <b>reference</b><br>
3275   * Path: <b>ImagingStudy.patient</b><br>
3276   * </p>
3277   */
3278  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
3279
3280/**
3281   * Constant for fluent queries to be used to add include statements. Specifies
3282   * the path value of "<b>ImagingStudy:patient</b>".
3283   */
3284  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("ImagingStudy:patient").toLocked();
3285
3286 /**
3287   * Search parameter: <b>series</b>
3288   * <p>
3289   * Description: <b>The identifier of the series of images</b><br>
3290   * Type: <b>uri</b><br>
3291   * Path: <b>ImagingStudy.series.uid</b><br>
3292   * </p>
3293   */
3294  @SearchParamDefinition(name="series", path="ImagingStudy.series.uid", description="The identifier of the series of images", type="uri" )
3295  public static final String SP_SERIES = "series";
3296 /**
3297   * <b>Fluent Client</b> search parameter constant for <b>series</b>
3298   * <p>
3299   * Description: <b>The identifier of the series of images</b><br>
3300   * Type: <b>uri</b><br>
3301   * Path: <b>ImagingStudy.series.uid</b><br>
3302   * </p>
3303   */
3304  public static final ca.uhn.fhir.rest.gclient.UriClientParam SERIES = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_SERIES);
3305
3306 /**
3307   * Search parameter: <b>context</b>
3308   * <p>
3309   * Description: <b>The context of the study</b><br>
3310   * Type: <b>reference</b><br>
3311   * Path: <b>ImagingStudy.context</b><br>
3312   * </p>
3313   */
3314  @SearchParamDefinition(name="context", path="ImagingStudy.context", description="The context of the study", type="reference", target={Encounter.class, EpisodeOfCare.class } )
3315  public static final String SP_CONTEXT = "context";
3316 /**
3317   * <b>Fluent Client</b> search parameter constant for <b>context</b>
3318   * <p>
3319   * Description: <b>The context of the study</b><br>
3320   * Type: <b>reference</b><br>
3321   * Path: <b>ImagingStudy.context</b><br>
3322   * </p>
3323   */
3324  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONTEXT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONTEXT);
3325
3326/**
3327   * Constant for fluent queries to be used to add include statements. Specifies
3328   * the path value of "<b>ImagingStudy:context</b>".
3329   */
3330  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONTEXT = new ca.uhn.fhir.model.api.Include("ImagingStudy:context").toLocked();
3331
3332 /**
3333   * Search parameter: <b>basedon</b>
3334   * <p>
3335   * Description: <b>The order for the image</b><br>
3336   * Type: <b>reference</b><br>
3337   * Path: <b>ImagingStudy.basedOn</b><br>
3338   * </p>
3339   */
3340  @SearchParamDefinition(name="basedon", path="ImagingStudy.basedOn", description="The order for the image", type="reference", target={CarePlan.class, ProcedureRequest.class, ReferralRequest.class } )
3341  public static final String SP_BASEDON = "basedon";
3342 /**
3343   * <b>Fluent Client</b> search parameter constant for <b>basedon</b>
3344   * <p>
3345   * Description: <b>The order for the image</b><br>
3346   * Type: <b>reference</b><br>
3347   * Path: <b>ImagingStudy.basedOn</b><br>
3348   * </p>
3349   */
3350  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASEDON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASEDON);
3351
3352/**
3353   * Constant for fluent queries to be used to add include statements. Specifies
3354   * the path value of "<b>ImagingStudy:basedon</b>".
3355   */
3356  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASEDON = new ca.uhn.fhir.model.api.Include("ImagingStudy:basedon").toLocked();
3357
3358
3359}
3360