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