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