001package org.hl7.fhir.dstu2.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
036import java.util.ArrayList;
037import java.util.Date;
038import java.util.List;
039
040import ca.uhn.fhir.model.api.annotation.Block;
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
046import org.hl7.fhir.exceptions.FHIRException;
047import org.hl7.fhir.utilities.Utilities;
048/**
049 * The findings and interpretation of diagnostic  tests performed on patients, groups of patients, devices, and locations, and/or specimens derived from these. The report includes clinical context such as requesting and provider information, and some mix of atomic results, images, textual and coded interpretations, and formatted representation of diagnostic reports.
050 */
051@ResourceDef(name="DiagnosticReport", profile="http://hl7.org/fhir/Profile/DiagnosticReport")
052public class DiagnosticReport extends DomainResource {
053
054    public enum DiagnosticReportStatus {
055        /**
056         * The existence of the report is registered, but there is nothing yet available.
057         */
058        REGISTERED, 
059        /**
060         * This is a partial (e.g. initial, interim or preliminary) report: data in the report may be incomplete or unverified.
061         */
062        PARTIAL, 
063        /**
064         * The report is complete and verified by an authorized person.
065         */
066        FINAL, 
067        /**
068         * The report has been modified subsequent to being Final, and is complete and verified by an authorized person. New content has been added, but existing content hasn't changed
069         */
070        CORRECTED, 
071        /**
072         * The report has been modified subsequent to being Final, and is complete and verified by an authorized person. New content has been added, but existing content hasn't changed.
073         */
074        APPENDED, 
075        /**
076         * The report is unavailable because the measurement was not started or not completed (also sometimes called "aborted").
077         */
078        CANCELLED, 
079        /**
080         * The report has been withdrawn following a previous final release.
081         */
082        ENTEREDINERROR, 
083        /**
084         * added to help the parsers
085         */
086        NULL;
087        public static DiagnosticReportStatus fromCode(String codeString) throws FHIRException {
088            if (codeString == null || "".equals(codeString))
089                return null;
090        if ("registered".equals(codeString))
091          return REGISTERED;
092        if ("partial".equals(codeString))
093          return PARTIAL;
094        if ("final".equals(codeString))
095          return FINAL;
096        if ("corrected".equals(codeString))
097          return CORRECTED;
098        if ("appended".equals(codeString))
099          return APPENDED;
100        if ("cancelled".equals(codeString))
101          return CANCELLED;
102        if ("entered-in-error".equals(codeString))
103          return ENTEREDINERROR;
104        throw new FHIRException("Unknown DiagnosticReportStatus code '"+codeString+"'");
105        }
106        public String toCode() {
107          switch (this) {
108            case REGISTERED: return "registered";
109            case PARTIAL: return "partial";
110            case FINAL: return "final";
111            case CORRECTED: return "corrected";
112            case APPENDED: return "appended";
113            case CANCELLED: return "cancelled";
114            case ENTEREDINERROR: return "entered-in-error";
115            default: return "?";
116          }
117        }
118        public String getSystem() {
119          switch (this) {
120            case REGISTERED: return "http://hl7.org/fhir/diagnostic-report-status";
121            case PARTIAL: return "http://hl7.org/fhir/diagnostic-report-status";
122            case FINAL: return "http://hl7.org/fhir/diagnostic-report-status";
123            case CORRECTED: return "http://hl7.org/fhir/diagnostic-report-status";
124            case APPENDED: return "http://hl7.org/fhir/diagnostic-report-status";
125            case CANCELLED: return "http://hl7.org/fhir/diagnostic-report-status";
126            case ENTEREDINERROR: return "http://hl7.org/fhir/diagnostic-report-status";
127            default: return "?";
128          }
129        }
130        public String getDefinition() {
131          switch (this) {
132            case REGISTERED: return "The existence of the report is registered, but there is nothing yet available.";
133            case PARTIAL: return "This is a partial (e.g. initial, interim or preliminary) report: data in the report may be incomplete or unverified.";
134            case FINAL: return "The report is complete and verified by an authorized person.";
135            case CORRECTED: return "The report has been modified subsequent to being Final, and is complete and verified by an authorized person. New content has been added, but existing content hasn't changed";
136            case APPENDED: return "The report has been modified subsequent to being Final, and is complete and verified by an authorized person. New content has been added, but existing content hasn't changed.";
137            case CANCELLED: return "The report is unavailable because the measurement was not started or not completed (also sometimes called \"aborted\").";
138            case ENTEREDINERROR: return "The report has been withdrawn following a previous final release.";
139            default: return "?";
140          }
141        }
142        public String getDisplay() {
143          switch (this) {
144            case REGISTERED: return "Registered";
145            case PARTIAL: return "Partial";
146            case FINAL: return "Final";
147            case CORRECTED: return "Corrected";
148            case APPENDED: return "Appended";
149            case CANCELLED: return "Cancelled";
150            case ENTEREDINERROR: return "Entered in Error";
151            default: return "?";
152          }
153        }
154    }
155
156  public static class DiagnosticReportStatusEnumFactory implements EnumFactory<DiagnosticReportStatus> {
157    public DiagnosticReportStatus fromCode(String codeString) throws IllegalArgumentException {
158      if (codeString == null || "".equals(codeString))
159            if (codeString == null || "".equals(codeString))
160                return null;
161        if ("registered".equals(codeString))
162          return DiagnosticReportStatus.REGISTERED;
163        if ("partial".equals(codeString))
164          return DiagnosticReportStatus.PARTIAL;
165        if ("final".equals(codeString))
166          return DiagnosticReportStatus.FINAL;
167        if ("corrected".equals(codeString))
168          return DiagnosticReportStatus.CORRECTED;
169        if ("appended".equals(codeString))
170          return DiagnosticReportStatus.APPENDED;
171        if ("cancelled".equals(codeString))
172          return DiagnosticReportStatus.CANCELLED;
173        if ("entered-in-error".equals(codeString))
174          return DiagnosticReportStatus.ENTEREDINERROR;
175        throw new IllegalArgumentException("Unknown DiagnosticReportStatus code '"+codeString+"'");
176        }
177        public Enumeration<DiagnosticReportStatus> fromType(Base code) throws FHIRException {
178          if (code == null || code.isEmpty())
179            return null;
180          String codeString = ((PrimitiveType) code).asStringValue();
181          if (codeString == null || "".equals(codeString))
182            return null;
183        if ("registered".equals(codeString))
184          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.REGISTERED);
185        if ("partial".equals(codeString))
186          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.PARTIAL);
187        if ("final".equals(codeString))
188          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.FINAL);
189        if ("corrected".equals(codeString))
190          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.CORRECTED);
191        if ("appended".equals(codeString))
192          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.APPENDED);
193        if ("cancelled".equals(codeString))
194          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.CANCELLED);
195        if ("entered-in-error".equals(codeString))
196          return new Enumeration<DiagnosticReportStatus>(this, DiagnosticReportStatus.ENTEREDINERROR);
197        throw new FHIRException("Unknown DiagnosticReportStatus code '"+codeString+"'");
198        }
199    public String toCode(DiagnosticReportStatus code) {
200      if (code == DiagnosticReportStatus.REGISTERED)
201        return "registered";
202      if (code == DiagnosticReportStatus.PARTIAL)
203        return "partial";
204      if (code == DiagnosticReportStatus.FINAL)
205        return "final";
206      if (code == DiagnosticReportStatus.CORRECTED)
207        return "corrected";
208      if (code == DiagnosticReportStatus.APPENDED)
209        return "appended";
210      if (code == DiagnosticReportStatus.CANCELLED)
211        return "cancelled";
212      if (code == DiagnosticReportStatus.ENTEREDINERROR)
213        return "entered-in-error";
214      return "?";
215      }
216    }
217
218    @Block()
219    public static class DiagnosticReportImageComponent extends BackboneElement implements IBaseBackboneElement {
220        /**
221         * A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.
222         */
223        @Child(name = "comment", type = {StringType.class}, order=1, min=0, max=1, modifier=false, summary=false)
224        @Description(shortDefinition="Comment about the image (e.g. explanation)", formalDefinition="A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features." )
225        protected StringType comment;
226
227        /**
228         * Reference to the image source.
229         */
230        @Child(name = "link", type = {Media.class}, order=2, min=1, max=1, modifier=false, summary=true)
231        @Description(shortDefinition="Reference to the image source", formalDefinition="Reference to the image source." )
232        protected Reference link;
233
234        /**
235         * The actual object that is the target of the reference (Reference to the image source.)
236         */
237        protected Media linkTarget;
238
239        private static final long serialVersionUID = 935791940L;
240
241    /*
242     * Constructor
243     */
244      public DiagnosticReportImageComponent() {
245        super();
246      }
247
248    /*
249     * Constructor
250     */
251      public DiagnosticReportImageComponent(Reference link) {
252        super();
253        this.link = link;
254      }
255
256        /**
257         * @return {@link #comment} (A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
258         */
259        public StringType getCommentElement() { 
260          if (this.comment == null)
261            if (Configuration.errorOnAutoCreate())
262              throw new Error("Attempt to auto-create DiagnosticReportImageComponent.comment");
263            else if (Configuration.doAutoCreate())
264              this.comment = new StringType(); // bb
265          return this.comment;
266        }
267
268        public boolean hasCommentElement() { 
269          return this.comment != null && !this.comment.isEmpty();
270        }
271
272        public boolean hasComment() { 
273          return this.comment != null && !this.comment.isEmpty();
274        }
275
276        /**
277         * @param value {@link #comment} (A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
278         */
279        public DiagnosticReportImageComponent setCommentElement(StringType value) { 
280          this.comment = value;
281          return this;
282        }
283
284        /**
285         * @return A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.
286         */
287        public String getComment() { 
288          return this.comment == null ? null : this.comment.getValue();
289        }
290
291        /**
292         * @param value A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.
293         */
294        public DiagnosticReportImageComponent setComment(String value) { 
295          if (Utilities.noString(value))
296            this.comment = null;
297          else {
298            if (this.comment == null)
299              this.comment = new StringType();
300            this.comment.setValue(value);
301          }
302          return this;
303        }
304
305        /**
306         * @return {@link #link} (Reference to the image source.)
307         */
308        public Reference getLink() { 
309          if (this.link == null)
310            if (Configuration.errorOnAutoCreate())
311              throw new Error("Attempt to auto-create DiagnosticReportImageComponent.link");
312            else if (Configuration.doAutoCreate())
313              this.link = new Reference(); // cc
314          return this.link;
315        }
316
317        public boolean hasLink() { 
318          return this.link != null && !this.link.isEmpty();
319        }
320
321        /**
322         * @param value {@link #link} (Reference to the image source.)
323         */
324        public DiagnosticReportImageComponent setLink(Reference value) { 
325          this.link = value;
326          return this;
327        }
328
329        /**
330         * @return {@link #link} 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. (Reference to the image source.)
331         */
332        public Media getLinkTarget() { 
333          if (this.linkTarget == null)
334            if (Configuration.errorOnAutoCreate())
335              throw new Error("Attempt to auto-create DiagnosticReportImageComponent.link");
336            else if (Configuration.doAutoCreate())
337              this.linkTarget = new Media(); // aa
338          return this.linkTarget;
339        }
340
341        /**
342         * @param value {@link #link} 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. (Reference to the image source.)
343         */
344        public DiagnosticReportImageComponent setLinkTarget(Media value) { 
345          this.linkTarget = value;
346          return this;
347        }
348
349        protected void listChildren(List<Property> childrenList) {
350          super.listChildren(childrenList);
351          childrenList.add(new Property("comment", "string", "A comment about the image. Typically, this is used to provide an explanation for why the image is included, or to draw the viewer's attention to important features.", 0, java.lang.Integer.MAX_VALUE, comment));
352          childrenList.add(new Property("link", "Reference(Media)", "Reference to the image source.", 0, java.lang.Integer.MAX_VALUE, link));
353        }
354
355      @Override
356      public void setProperty(String name, Base value) throws FHIRException {
357        if (name.equals("comment"))
358          this.comment = castToString(value); // StringType
359        else if (name.equals("link"))
360          this.link = castToReference(value); // Reference
361        else
362          super.setProperty(name, value);
363      }
364
365      @Override
366      public Base addChild(String name) throws FHIRException {
367        if (name.equals("comment")) {
368          throw new FHIRException("Cannot call addChild on a primitive type DiagnosticReport.comment");
369        }
370        else if (name.equals("link")) {
371          this.link = new Reference();
372          return this.link;
373        }
374        else
375          return super.addChild(name);
376      }
377
378      public DiagnosticReportImageComponent copy() {
379        DiagnosticReportImageComponent dst = new DiagnosticReportImageComponent();
380        copyValues(dst);
381        dst.comment = comment == null ? null : comment.copy();
382        dst.link = link == null ? null : link.copy();
383        return dst;
384      }
385
386      @Override
387      public boolean equalsDeep(Base other) {
388        if (!super.equalsDeep(other))
389          return false;
390        if (!(other instanceof DiagnosticReportImageComponent))
391          return false;
392        DiagnosticReportImageComponent o = (DiagnosticReportImageComponent) other;
393        return compareDeep(comment, o.comment, true) && compareDeep(link, o.link, true);
394      }
395
396      @Override
397      public boolean equalsShallow(Base other) {
398        if (!super.equalsShallow(other))
399          return false;
400        if (!(other instanceof DiagnosticReportImageComponent))
401          return false;
402        DiagnosticReportImageComponent o = (DiagnosticReportImageComponent) other;
403        return compareValues(comment, o.comment, true);
404      }
405
406      public boolean isEmpty() {
407        return super.isEmpty() && (comment == null || comment.isEmpty()) && (link == null || link.isEmpty())
408          ;
409      }
410
411  public String fhirType() {
412    return "DiagnosticReport.image";
413
414  }
415
416  }
417
418    /**
419     * The local ID assigned to the report by the order filler, usually by the Information System of the diagnostic service provider.
420     */
421    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
422    @Description(shortDefinition="Id for external references to this report", formalDefinition="The local ID assigned to the report by the order filler, usually by the Information System of the diagnostic service provider." )
423    protected List<Identifier> identifier;
424
425    /**
426     * The status of the diagnostic report as a whole.
427     */
428    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
429    @Description(shortDefinition="registered | partial | final | corrected | appended | cancelled | entered-in-error", formalDefinition="The status of the diagnostic report as a whole." )
430    protected Enumeration<DiagnosticReportStatus> status;
431
432    /**
433     * A code that classifies the clinical discipline, department or diagnostic service that created the report (e.g. cardiology, biochemistry, hematology, MRI). This is used for searching, sorting and display purposes.
434     */
435    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
436    @Description(shortDefinition="Service category", formalDefinition="A code that classifies the clinical discipline, department or diagnostic service that created the report (e.g. cardiology, biochemistry, hematology, MRI). This is used for searching, sorting and display purposes." )
437    protected CodeableConcept category;
438
439    /**
440     * A code or name that describes this diagnostic report.
441     */
442    @Child(name = "code", type = {CodeableConcept.class}, order=3, min=1, max=1, modifier=false, summary=true)
443    @Description(shortDefinition="Name/Code for this diagnostic report", formalDefinition="A code or name that describes this diagnostic report." )
444    protected CodeableConcept code;
445
446    /**
447     * The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.
448     */
449    @Child(name = "subject", type = {Patient.class, Group.class, Device.class, Location.class}, order=4, min=1, max=1, modifier=false, summary=true)
450    @Description(shortDefinition="The subject of the report, usually, but not always, the patient", formalDefinition="The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources." )
451    protected Reference subject;
452
453    /**
454     * The actual object that is the target of the reference (The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.)
455     */
456    protected Resource subjectTarget;
457
458    /**
459     * The link to the health care event (encounter) when the order was made.
460     */
461    @Child(name = "encounter", type = {Encounter.class}, order=5, min=0, max=1, modifier=false, summary=true)
462    @Description(shortDefinition="Health care event when test ordered", formalDefinition="The link to the health care event (encounter) when the order was made." )
463    protected Reference encounter;
464
465    /**
466     * The actual object that is the target of the reference (The link to the health care event (encounter) when the order was made.)
467     */
468    protected Encounter encounterTarget;
469
470    /**
471     * The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.
472     */
473    @Child(name = "effective", type = {DateTimeType.class, Period.class}, order=6, min=1, max=1, modifier=false, summary=true)
474    @Description(shortDefinition="Clinically Relevant time/time-period for report", formalDefinition="The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself." )
475    protected Type effective;
476
477    /**
478     * The date and time that this version of the report was released from the source diagnostic service.
479     */
480    @Child(name = "issued", type = {InstantType.class}, order=7, min=1, max=1, modifier=false, summary=true)
481    @Description(shortDefinition="DateTime this version was released", formalDefinition="The date and time that this version of the report was released from the source diagnostic service." )
482    protected InstantType issued;
483
484    /**
485     * The diagnostic service that is responsible for issuing the report.
486     */
487    @Child(name = "performer", type = {Practitioner.class, Organization.class}, order=8, min=1, max=1, modifier=false, summary=true)
488    @Description(shortDefinition="Responsible Diagnostic Service", formalDefinition="The diagnostic service that is responsible for issuing the report." )
489    protected Reference performer;
490
491    /**
492     * The actual object that is the target of the reference (The diagnostic service that is responsible for issuing the report.)
493     */
494    protected Resource performerTarget;
495
496    /**
497     * Details concerning a test or procedure requested.
498     */
499    @Child(name = "request", type = {DiagnosticOrder.class, ProcedureRequest.class, ReferralRequest.class}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
500    @Description(shortDefinition="What was requested", formalDefinition="Details concerning a test or procedure requested." )
501    protected List<Reference> request;
502    /**
503     * The actual objects that are the target of the reference (Details concerning a test or procedure requested.)
504     */
505    protected List<Resource> requestTarget;
506
507
508    /**
509     * Details about the specimens on which this diagnostic report is based.
510     */
511    @Child(name = "specimen", type = {Specimen.class}, order=10, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
512    @Description(shortDefinition="Specimens this report is based on", formalDefinition="Details about the specimens on which this diagnostic report is based." )
513    protected List<Reference> specimen;
514    /**
515     * The actual objects that are the target of the reference (Details about the specimens on which this diagnostic report is based.)
516     */
517    protected List<Specimen> specimenTarget;
518
519
520    /**
521     * Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").
522     */
523    @Child(name = "result", type = {Observation.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
524    @Description(shortDefinition="Observations - simple, or complex nested groups", formalDefinition="Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. \"atomic\" results), or they can be grouping observations that include references to other members of the group (e.g. \"panels\")." )
525    protected List<Reference> result;
526    /**
527     * The actual objects that are the target of the reference (Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").)
528     */
529    protected List<Observation> resultTarget;
530
531
532    /**
533     * One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.
534     */
535    @Child(name = "imagingStudy", type = {ImagingStudy.class, ImagingObjectSelection.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
536    @Description(shortDefinition="Reference to full details of imaging associated with the diagnostic report", formalDefinition="One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images." )
537    protected List<Reference> imagingStudy;
538    /**
539     * The actual objects that are the target of the reference (One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.)
540     */
541    protected List<Resource> imagingStudyTarget;
542
543
544    /**
545     * A list of key images associated with this report. The images are generally created during the diagnostic process, and may be directly of the patient, or of treated specimens (i.e. slides of interest).
546     */
547    @Child(name = "image", type = {}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
548    @Description(shortDefinition="Key images associated with this report", formalDefinition="A list of key images associated with this report. The images are generally created during the diagnostic process, and may be directly of the patient, or of treated specimens (i.e. slides of interest)." )
549    protected List<DiagnosticReportImageComponent> image;
550
551    /**
552     * Concise and clinically contextualized narrative interpretation of the diagnostic report.
553     */
554    @Child(name = "conclusion", type = {StringType.class}, order=14, min=0, max=1, modifier=false, summary=false)
555    @Description(shortDefinition="Clinical Interpretation of test results", formalDefinition="Concise and clinically contextualized narrative interpretation of the diagnostic report." )
556    protected StringType conclusion;
557
558    /**
559     * Codes for the conclusion.
560     */
561    @Child(name = "codedDiagnosis", type = {CodeableConcept.class}, order=15, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
562    @Description(shortDefinition="Codes for the conclusion", formalDefinition="Codes for the conclusion." )
563    protected List<CodeableConcept> codedDiagnosis;
564
565    /**
566     * Rich text representation of the entire result as issued by the diagnostic service. Multiple formats are allowed but they SHALL be semantically equivalent.
567     */
568    @Child(name = "presentedForm", type = {Attachment.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
569    @Description(shortDefinition="Entire report as issued", formalDefinition="Rich text representation of the entire result as issued by the diagnostic service. Multiple formats are allowed but they SHALL be semantically equivalent." )
570    protected List<Attachment> presentedForm;
571
572    private static final long serialVersionUID = 920334551L;
573
574  /*
575   * Constructor
576   */
577    public DiagnosticReport() {
578      super();
579    }
580
581  /*
582   * Constructor
583   */
584    public DiagnosticReport(Enumeration<DiagnosticReportStatus> status, CodeableConcept code, Reference subject, Type effective, InstantType issued, Reference performer) {
585      super();
586      this.status = status;
587      this.code = code;
588      this.subject = subject;
589      this.effective = effective;
590      this.issued = issued;
591      this.performer = performer;
592    }
593
594    /**
595     * @return {@link #identifier} (The local ID assigned to the report by the order filler, usually by the Information System of the diagnostic service provider.)
596     */
597    public List<Identifier> getIdentifier() { 
598      if (this.identifier == null)
599        this.identifier = new ArrayList<Identifier>();
600      return this.identifier;
601    }
602
603    public boolean hasIdentifier() { 
604      if (this.identifier == null)
605        return false;
606      for (Identifier item : this.identifier)
607        if (!item.isEmpty())
608          return true;
609      return false;
610    }
611
612    /**
613     * @return {@link #identifier} (The local ID assigned to the report by the order filler, usually by the Information System of the diagnostic service provider.)
614     */
615    // syntactic sugar
616    public Identifier addIdentifier() { //3
617      Identifier t = new Identifier();
618      if (this.identifier == null)
619        this.identifier = new ArrayList<Identifier>();
620      this.identifier.add(t);
621      return t;
622    }
623
624    // syntactic sugar
625    public DiagnosticReport addIdentifier(Identifier t) { //3
626      if (t == null)
627        return this;
628      if (this.identifier == null)
629        this.identifier = new ArrayList<Identifier>();
630      this.identifier.add(t);
631      return this;
632    }
633
634    /**
635     * @return {@link #status} (The status of the diagnostic report as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
636     */
637    public Enumeration<DiagnosticReportStatus> getStatusElement() { 
638      if (this.status == null)
639        if (Configuration.errorOnAutoCreate())
640          throw new Error("Attempt to auto-create DiagnosticReport.status");
641        else if (Configuration.doAutoCreate())
642          this.status = new Enumeration<DiagnosticReportStatus>(new DiagnosticReportStatusEnumFactory()); // bb
643      return this.status;
644    }
645
646    public boolean hasStatusElement() { 
647      return this.status != null && !this.status.isEmpty();
648    }
649
650    public boolean hasStatus() { 
651      return this.status != null && !this.status.isEmpty();
652    }
653
654    /**
655     * @param value {@link #status} (The status of the diagnostic report as a whole.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
656     */
657    public DiagnosticReport setStatusElement(Enumeration<DiagnosticReportStatus> value) { 
658      this.status = value;
659      return this;
660    }
661
662    /**
663     * @return The status of the diagnostic report as a whole.
664     */
665    public DiagnosticReportStatus getStatus() { 
666      return this.status == null ? null : this.status.getValue();
667    }
668
669    /**
670     * @param value The status of the diagnostic report as a whole.
671     */
672    public DiagnosticReport setStatus(DiagnosticReportStatus value) { 
673        if (this.status == null)
674          this.status = new Enumeration<DiagnosticReportStatus>(new DiagnosticReportStatusEnumFactory());
675        this.status.setValue(value);
676      return this;
677    }
678
679    /**
680     * @return {@link #category} (A code that classifies the clinical discipline, department or diagnostic service that created the report (e.g. cardiology, biochemistry, hematology, MRI). This is used for searching, sorting and display purposes.)
681     */
682    public CodeableConcept getCategory() { 
683      if (this.category == null)
684        if (Configuration.errorOnAutoCreate())
685          throw new Error("Attempt to auto-create DiagnosticReport.category");
686        else if (Configuration.doAutoCreate())
687          this.category = new CodeableConcept(); // cc
688      return this.category;
689    }
690
691    public boolean hasCategory() { 
692      return this.category != null && !this.category.isEmpty();
693    }
694
695    /**
696     * @param value {@link #category} (A code that classifies the clinical discipline, department or diagnostic service that created the report (e.g. cardiology, biochemistry, hematology, MRI). This is used for searching, sorting and display purposes.)
697     */
698    public DiagnosticReport setCategory(CodeableConcept value) { 
699      this.category = value;
700      return this;
701    }
702
703    /**
704     * @return {@link #code} (A code or name that describes this diagnostic report.)
705     */
706    public CodeableConcept getCode() { 
707      if (this.code == null)
708        if (Configuration.errorOnAutoCreate())
709          throw new Error("Attempt to auto-create DiagnosticReport.code");
710        else if (Configuration.doAutoCreate())
711          this.code = new CodeableConcept(); // cc
712      return this.code;
713    }
714
715    public boolean hasCode() { 
716      return this.code != null && !this.code.isEmpty();
717    }
718
719    /**
720     * @param value {@link #code} (A code or name that describes this diagnostic report.)
721     */
722    public DiagnosticReport setCode(CodeableConcept value) { 
723      this.code = value;
724      return this;
725    }
726
727    /**
728     * @return {@link #subject} (The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.)
729     */
730    public Reference getSubject() { 
731      if (this.subject == null)
732        if (Configuration.errorOnAutoCreate())
733          throw new Error("Attempt to auto-create DiagnosticReport.subject");
734        else if (Configuration.doAutoCreate())
735          this.subject = new Reference(); // cc
736      return this.subject;
737    }
738
739    public boolean hasSubject() { 
740      return this.subject != null && !this.subject.isEmpty();
741    }
742
743    /**
744     * @param value {@link #subject} (The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.)
745     */
746    public DiagnosticReport setSubject(Reference value) { 
747      this.subject = value;
748      return this;
749    }
750
751    /**
752     * @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 of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.)
753     */
754    public Resource getSubjectTarget() { 
755      return this.subjectTarget;
756    }
757
758    /**
759     * @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 of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.)
760     */
761    public DiagnosticReport setSubjectTarget(Resource value) { 
762      this.subjectTarget = value;
763      return this;
764    }
765
766    /**
767     * @return {@link #encounter} (The link to the health care event (encounter) when the order was made.)
768     */
769    public Reference getEncounter() { 
770      if (this.encounter == null)
771        if (Configuration.errorOnAutoCreate())
772          throw new Error("Attempt to auto-create DiagnosticReport.encounter");
773        else if (Configuration.doAutoCreate())
774          this.encounter = new Reference(); // cc
775      return this.encounter;
776    }
777
778    public boolean hasEncounter() { 
779      return this.encounter != null && !this.encounter.isEmpty();
780    }
781
782    /**
783     * @param value {@link #encounter} (The link to the health care event (encounter) when the order was made.)
784     */
785    public DiagnosticReport setEncounter(Reference value) { 
786      this.encounter = value;
787      return this;
788    }
789
790    /**
791     * @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 link to the health care event (encounter) when the order was made.)
792     */
793    public Encounter getEncounterTarget() { 
794      if (this.encounterTarget == null)
795        if (Configuration.errorOnAutoCreate())
796          throw new Error("Attempt to auto-create DiagnosticReport.encounter");
797        else if (Configuration.doAutoCreate())
798          this.encounterTarget = new Encounter(); // aa
799      return this.encounterTarget;
800    }
801
802    /**
803     * @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 link to the health care event (encounter) when the order was made.)
804     */
805    public DiagnosticReport setEncounterTarget(Encounter value) { 
806      this.encounterTarget = value;
807      return this;
808    }
809
810    /**
811     * @return {@link #effective} (The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.)
812     */
813    public Type getEffective() { 
814      return this.effective;
815    }
816
817    /**
818     * @return {@link #effective} (The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.)
819     */
820    public DateTimeType getEffectiveDateTimeType() throws FHIRException { 
821      if (!(this.effective instanceof DateTimeType))
822        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.effective.getClass().getName()+" was encountered");
823      return (DateTimeType) this.effective;
824    }
825
826    public boolean hasEffectiveDateTimeType() { 
827      return this.effective instanceof DateTimeType;
828    }
829
830    /**
831     * @return {@link #effective} (The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.)
832     */
833    public Period getEffectivePeriod() throws FHIRException { 
834      if (!(this.effective instanceof Period))
835        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.effective.getClass().getName()+" was encountered");
836      return (Period) this.effective;
837    }
838
839    public boolean hasEffectivePeriod() { 
840      return this.effective instanceof Period;
841    }
842
843    public boolean hasEffective() { 
844      return this.effective != null && !this.effective.isEmpty();
845    }
846
847    /**
848     * @param value {@link #effective} (The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.)
849     */
850    public DiagnosticReport setEffective(Type value) { 
851      this.effective = value;
852      return this;
853    }
854
855    /**
856     * @return {@link #issued} (The date and time that this version of the report was released from the source diagnostic service.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
857     */
858    public InstantType getIssuedElement() { 
859      if (this.issued == null)
860        if (Configuration.errorOnAutoCreate())
861          throw new Error("Attempt to auto-create DiagnosticReport.issued");
862        else if (Configuration.doAutoCreate())
863          this.issued = new InstantType(); // bb
864      return this.issued;
865    }
866
867    public boolean hasIssuedElement() { 
868      return this.issued != null && !this.issued.isEmpty();
869    }
870
871    public boolean hasIssued() { 
872      return this.issued != null && !this.issued.isEmpty();
873    }
874
875    /**
876     * @param value {@link #issued} (The date and time that this version of the report was released from the source diagnostic service.). This is the underlying object with id, value and extensions. The accessor "getIssued" gives direct access to the value
877     */
878    public DiagnosticReport setIssuedElement(InstantType value) { 
879      this.issued = value;
880      return this;
881    }
882
883    /**
884     * @return The date and time that this version of the report was released from the source diagnostic service.
885     */
886    public Date getIssued() { 
887      return this.issued == null ? null : this.issued.getValue();
888    }
889
890    /**
891     * @param value The date and time that this version of the report was released from the source diagnostic service.
892     */
893    public DiagnosticReport setIssued(Date value) { 
894        if (this.issued == null)
895          this.issued = new InstantType();
896        this.issued.setValue(value);
897      return this;
898    }
899
900    /**
901     * @return {@link #performer} (The diagnostic service that is responsible for issuing the report.)
902     */
903    public Reference getPerformer() { 
904      if (this.performer == null)
905        if (Configuration.errorOnAutoCreate())
906          throw new Error("Attempt to auto-create DiagnosticReport.performer");
907        else if (Configuration.doAutoCreate())
908          this.performer = new Reference(); // cc
909      return this.performer;
910    }
911
912    public boolean hasPerformer() { 
913      return this.performer != null && !this.performer.isEmpty();
914    }
915
916    /**
917     * @param value {@link #performer} (The diagnostic service that is responsible for issuing the report.)
918     */
919    public DiagnosticReport setPerformer(Reference value) { 
920      this.performer = value;
921      return this;
922    }
923
924    /**
925     * @return {@link #performer} 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 diagnostic service that is responsible for issuing the report.)
926     */
927    public Resource getPerformerTarget() { 
928      return this.performerTarget;
929    }
930
931    /**
932     * @param value {@link #performer} 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 diagnostic service that is responsible for issuing the report.)
933     */
934    public DiagnosticReport setPerformerTarget(Resource value) { 
935      this.performerTarget = value;
936      return this;
937    }
938
939    /**
940     * @return {@link #request} (Details concerning a test or procedure requested.)
941     */
942    public List<Reference> getRequest() { 
943      if (this.request == null)
944        this.request = new ArrayList<Reference>();
945      return this.request;
946    }
947
948    public boolean hasRequest() { 
949      if (this.request == null)
950        return false;
951      for (Reference item : this.request)
952        if (!item.isEmpty())
953          return true;
954      return false;
955    }
956
957    /**
958     * @return {@link #request} (Details concerning a test or procedure requested.)
959     */
960    // syntactic sugar
961    public Reference addRequest() { //3
962      Reference t = new Reference();
963      if (this.request == null)
964        this.request = new ArrayList<Reference>();
965      this.request.add(t);
966      return t;
967    }
968
969    // syntactic sugar
970    public DiagnosticReport addRequest(Reference t) { //3
971      if (t == null)
972        return this;
973      if (this.request == null)
974        this.request = new ArrayList<Reference>();
975      this.request.add(t);
976      return this;
977    }
978
979    /**
980     * @return {@link #request} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Details concerning a test or procedure requested.)
981     */
982    public List<Resource> getRequestTarget() { 
983      if (this.requestTarget == null)
984        this.requestTarget = new ArrayList<Resource>();
985      return this.requestTarget;
986    }
987
988    /**
989     * @return {@link #specimen} (Details about the specimens on which this diagnostic report is based.)
990     */
991    public List<Reference> getSpecimen() { 
992      if (this.specimen == null)
993        this.specimen = new ArrayList<Reference>();
994      return this.specimen;
995    }
996
997    public boolean hasSpecimen() { 
998      if (this.specimen == null)
999        return false;
1000      for (Reference item : this.specimen)
1001        if (!item.isEmpty())
1002          return true;
1003      return false;
1004    }
1005
1006    /**
1007     * @return {@link #specimen} (Details about the specimens on which this diagnostic report is based.)
1008     */
1009    // syntactic sugar
1010    public Reference addSpecimen() { //3
1011      Reference t = new Reference();
1012      if (this.specimen == null)
1013        this.specimen = new ArrayList<Reference>();
1014      this.specimen.add(t);
1015      return t;
1016    }
1017
1018    // syntactic sugar
1019    public DiagnosticReport addSpecimen(Reference t) { //3
1020      if (t == null)
1021        return this;
1022      if (this.specimen == null)
1023        this.specimen = new ArrayList<Reference>();
1024      this.specimen.add(t);
1025      return this;
1026    }
1027
1028    /**
1029     * @return {@link #specimen} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Details about the specimens on which this diagnostic report is based.)
1030     */
1031    public List<Specimen> getSpecimenTarget() { 
1032      if (this.specimenTarget == null)
1033        this.specimenTarget = new ArrayList<Specimen>();
1034      return this.specimenTarget;
1035    }
1036
1037    // syntactic sugar
1038    /**
1039     * @return {@link #specimen} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Details about the specimens on which this diagnostic report is based.)
1040     */
1041    public Specimen addSpecimenTarget() { 
1042      Specimen r = new Specimen();
1043      if (this.specimenTarget == null)
1044        this.specimenTarget = new ArrayList<Specimen>();
1045      this.specimenTarget.add(r);
1046      return r;
1047    }
1048
1049    /**
1050     * @return {@link #result} (Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").)
1051     */
1052    public List<Reference> getResult() { 
1053      if (this.result == null)
1054        this.result = new ArrayList<Reference>();
1055      return this.result;
1056    }
1057
1058    public boolean hasResult() { 
1059      if (this.result == null)
1060        return false;
1061      for (Reference item : this.result)
1062        if (!item.isEmpty())
1063          return true;
1064      return false;
1065    }
1066
1067    /**
1068     * @return {@link #result} (Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").)
1069     */
1070    // syntactic sugar
1071    public Reference addResult() { //3
1072      Reference t = new Reference();
1073      if (this.result == null)
1074        this.result = new ArrayList<Reference>();
1075      this.result.add(t);
1076      return t;
1077    }
1078
1079    // syntactic sugar
1080    public DiagnosticReport addResult(Reference t) { //3
1081      if (t == null)
1082        return this;
1083      if (this.result == null)
1084        this.result = new ArrayList<Reference>();
1085      this.result.add(t);
1086      return this;
1087    }
1088
1089    /**
1090     * @return {@link #result} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").)
1091     */
1092    public List<Observation> getResultTarget() { 
1093      if (this.resultTarget == null)
1094        this.resultTarget = new ArrayList<Observation>();
1095      return this.resultTarget;
1096    }
1097
1098    // syntactic sugar
1099    /**
1100     * @return {@link #result} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. "atomic" results), or they can be grouping observations that include references to other members of the group (e.g. "panels").)
1101     */
1102    public Observation addResultTarget() { 
1103      Observation r = new Observation();
1104      if (this.resultTarget == null)
1105        this.resultTarget = new ArrayList<Observation>();
1106      this.resultTarget.add(r);
1107      return r;
1108    }
1109
1110    /**
1111     * @return {@link #imagingStudy} (One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.)
1112     */
1113    public List<Reference> getImagingStudy() { 
1114      if (this.imagingStudy == null)
1115        this.imagingStudy = new ArrayList<Reference>();
1116      return this.imagingStudy;
1117    }
1118
1119    public boolean hasImagingStudy() { 
1120      if (this.imagingStudy == null)
1121        return false;
1122      for (Reference item : this.imagingStudy)
1123        if (!item.isEmpty())
1124          return true;
1125      return false;
1126    }
1127
1128    /**
1129     * @return {@link #imagingStudy} (One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.)
1130     */
1131    // syntactic sugar
1132    public Reference addImagingStudy() { //3
1133      Reference t = new Reference();
1134      if (this.imagingStudy == null)
1135        this.imagingStudy = new ArrayList<Reference>();
1136      this.imagingStudy.add(t);
1137      return t;
1138    }
1139
1140    // syntactic sugar
1141    public DiagnosticReport addImagingStudy(Reference t) { //3
1142      if (t == null)
1143        return this;
1144      if (this.imagingStudy == null)
1145        this.imagingStudy = new ArrayList<Reference>();
1146      this.imagingStudy.add(t);
1147      return this;
1148    }
1149
1150    /**
1151     * @return {@link #imagingStudy} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.)
1152     */
1153    public List<Resource> getImagingStudyTarget() { 
1154      if (this.imagingStudyTarget == null)
1155        this.imagingStudyTarget = new ArrayList<Resource>();
1156      return this.imagingStudyTarget;
1157    }
1158
1159    /**
1160     * @return {@link #image} (A list of key images associated with this report. The images are generally created during the diagnostic process, and may be directly of the patient, or of treated specimens (i.e. slides of interest).)
1161     */
1162    public List<DiagnosticReportImageComponent> getImage() { 
1163      if (this.image == null)
1164        this.image = new ArrayList<DiagnosticReportImageComponent>();
1165      return this.image;
1166    }
1167
1168    public boolean hasImage() { 
1169      if (this.image == null)
1170        return false;
1171      for (DiagnosticReportImageComponent item : this.image)
1172        if (!item.isEmpty())
1173          return true;
1174      return false;
1175    }
1176
1177    /**
1178     * @return {@link #image} (A list of key images associated with this report. The images are generally created during the diagnostic process, and may be directly of the patient, or of treated specimens (i.e. slides of interest).)
1179     */
1180    // syntactic sugar
1181    public DiagnosticReportImageComponent addImage() { //3
1182      DiagnosticReportImageComponent t = new DiagnosticReportImageComponent();
1183      if (this.image == null)
1184        this.image = new ArrayList<DiagnosticReportImageComponent>();
1185      this.image.add(t);
1186      return t;
1187    }
1188
1189    // syntactic sugar
1190    public DiagnosticReport addImage(DiagnosticReportImageComponent t) { //3
1191      if (t == null)
1192        return this;
1193      if (this.image == null)
1194        this.image = new ArrayList<DiagnosticReportImageComponent>();
1195      this.image.add(t);
1196      return this;
1197    }
1198
1199    /**
1200     * @return {@link #conclusion} (Concise and clinically contextualized narrative interpretation of the diagnostic report.). This is the underlying object with id, value and extensions. The accessor "getConclusion" gives direct access to the value
1201     */
1202    public StringType getConclusionElement() { 
1203      if (this.conclusion == null)
1204        if (Configuration.errorOnAutoCreate())
1205          throw new Error("Attempt to auto-create DiagnosticReport.conclusion");
1206        else if (Configuration.doAutoCreate())
1207          this.conclusion = new StringType(); // bb
1208      return this.conclusion;
1209    }
1210
1211    public boolean hasConclusionElement() { 
1212      return this.conclusion != null && !this.conclusion.isEmpty();
1213    }
1214
1215    public boolean hasConclusion() { 
1216      return this.conclusion != null && !this.conclusion.isEmpty();
1217    }
1218
1219    /**
1220     * @param value {@link #conclusion} (Concise and clinically contextualized narrative interpretation of the diagnostic report.). This is the underlying object with id, value and extensions. The accessor "getConclusion" gives direct access to the value
1221     */
1222    public DiagnosticReport setConclusionElement(StringType value) { 
1223      this.conclusion = value;
1224      return this;
1225    }
1226
1227    /**
1228     * @return Concise and clinically contextualized narrative interpretation of the diagnostic report.
1229     */
1230    public String getConclusion() { 
1231      return this.conclusion == null ? null : this.conclusion.getValue();
1232    }
1233
1234    /**
1235     * @param value Concise and clinically contextualized narrative interpretation of the diagnostic report.
1236     */
1237    public DiagnosticReport setConclusion(String value) { 
1238      if (Utilities.noString(value))
1239        this.conclusion = null;
1240      else {
1241        if (this.conclusion == null)
1242          this.conclusion = new StringType();
1243        this.conclusion.setValue(value);
1244      }
1245      return this;
1246    }
1247
1248    /**
1249     * @return {@link #codedDiagnosis} (Codes for the conclusion.)
1250     */
1251    public List<CodeableConcept> getCodedDiagnosis() { 
1252      if (this.codedDiagnosis == null)
1253        this.codedDiagnosis = new ArrayList<CodeableConcept>();
1254      return this.codedDiagnosis;
1255    }
1256
1257    public boolean hasCodedDiagnosis() { 
1258      if (this.codedDiagnosis == null)
1259        return false;
1260      for (CodeableConcept item : this.codedDiagnosis)
1261        if (!item.isEmpty())
1262          return true;
1263      return false;
1264    }
1265
1266    /**
1267     * @return {@link #codedDiagnosis} (Codes for the conclusion.)
1268     */
1269    // syntactic sugar
1270    public CodeableConcept addCodedDiagnosis() { //3
1271      CodeableConcept t = new CodeableConcept();
1272      if (this.codedDiagnosis == null)
1273        this.codedDiagnosis = new ArrayList<CodeableConcept>();
1274      this.codedDiagnosis.add(t);
1275      return t;
1276    }
1277
1278    // syntactic sugar
1279    public DiagnosticReport addCodedDiagnosis(CodeableConcept t) { //3
1280      if (t == null)
1281        return this;
1282      if (this.codedDiagnosis == null)
1283        this.codedDiagnosis = new ArrayList<CodeableConcept>();
1284      this.codedDiagnosis.add(t);
1285      return this;
1286    }
1287
1288    /**
1289     * @return {@link #presentedForm} (Rich text representation of the entire result as issued by the diagnostic service. Multiple formats are allowed but they SHALL be semantically equivalent.)
1290     */
1291    public List<Attachment> getPresentedForm() { 
1292      if (this.presentedForm == null)
1293        this.presentedForm = new ArrayList<Attachment>();
1294      return this.presentedForm;
1295    }
1296
1297    public boolean hasPresentedForm() { 
1298      if (this.presentedForm == null)
1299        return false;
1300      for (Attachment item : this.presentedForm)
1301        if (!item.isEmpty())
1302          return true;
1303      return false;
1304    }
1305
1306    /**
1307     * @return {@link #presentedForm} (Rich text representation of the entire result as issued by the diagnostic service. Multiple formats are allowed but they SHALL be semantically equivalent.)
1308     */
1309    // syntactic sugar
1310    public Attachment addPresentedForm() { //3
1311      Attachment t = new Attachment();
1312      if (this.presentedForm == null)
1313        this.presentedForm = new ArrayList<Attachment>();
1314      this.presentedForm.add(t);
1315      return t;
1316    }
1317
1318    // syntactic sugar
1319    public DiagnosticReport addPresentedForm(Attachment t) { //3
1320      if (t == null)
1321        return this;
1322      if (this.presentedForm == null)
1323        this.presentedForm = new ArrayList<Attachment>();
1324      this.presentedForm.add(t);
1325      return this;
1326    }
1327
1328      protected void listChildren(List<Property> childrenList) {
1329        super.listChildren(childrenList);
1330        childrenList.add(new Property("identifier", "Identifier", "The local ID assigned to the report by the order filler, usually by the Information System of the diagnostic service provider.", 0, java.lang.Integer.MAX_VALUE, identifier));
1331        childrenList.add(new Property("status", "code", "The status of the diagnostic report as a whole.", 0, java.lang.Integer.MAX_VALUE, status));
1332        childrenList.add(new Property("category", "CodeableConcept", "A code that classifies the clinical discipline, department or diagnostic service that created the report (e.g. cardiology, biochemistry, hematology, MRI). This is used for searching, sorting and display purposes.", 0, java.lang.Integer.MAX_VALUE, category));
1333        childrenList.add(new Property("code", "CodeableConcept", "A code or name that describes this diagnostic report.", 0, java.lang.Integer.MAX_VALUE, code));
1334        childrenList.add(new Property("subject", "Reference(Patient|Group|Device|Location)", "The subject of the report. Usually, but not always, this is a patient. However diagnostic services also perform analyses on specimens collected from a variety of other sources.", 0, java.lang.Integer.MAX_VALUE, subject));
1335        childrenList.add(new Property("encounter", "Reference(Encounter)", "The link to the health care event (encounter) when the order was made.", 0, java.lang.Integer.MAX_VALUE, encounter));
1336        childrenList.add(new Property("effective[x]", "dateTime|Period", "The time or time-period the observed values are related to. When the subject of the report is a patient, this is usually either the time of the procedure or of specimen collection(s), but very often the source of the date/time is not known, only the date/time itself.", 0, java.lang.Integer.MAX_VALUE, effective));
1337        childrenList.add(new Property("issued", "instant", "The date and time that this version of the report was released from the source diagnostic service.", 0, java.lang.Integer.MAX_VALUE, issued));
1338        childrenList.add(new Property("performer", "Reference(Practitioner|Organization)", "The diagnostic service that is responsible for issuing the report.", 0, java.lang.Integer.MAX_VALUE, performer));
1339        childrenList.add(new Property("request", "Reference(DiagnosticOrder|ProcedureRequest|ReferralRequest)", "Details concerning a test or procedure requested.", 0, java.lang.Integer.MAX_VALUE, request));
1340        childrenList.add(new Property("specimen", "Reference(Specimen)", "Details about the specimens on which this diagnostic report is based.", 0, java.lang.Integer.MAX_VALUE, specimen));
1341        childrenList.add(new Property("result", "Reference(Observation)", "Observations that are part of this diagnostic report. Observations can be simple name/value pairs (e.g. \"atomic\" results), or they can be grouping observations that include references to other members of the group (e.g. \"panels\").", 0, java.lang.Integer.MAX_VALUE, result));
1342        childrenList.add(new Property("imagingStudy", "Reference(ImagingStudy|ImagingObjectSelection)", "One or more links to full details of any imaging performed during the diagnostic investigation. Typically, this is imaging performed by DICOM enabled modalities, but this is not required. A fully enabled PACS viewer can use this information to provide views of the source images.", 0, java.lang.Integer.MAX_VALUE, imagingStudy));
1343        childrenList.add(new Property("image", "", "A list of key images associated with this report. The images are generally created during the diagnostic process, and may be directly of the patient, or of treated specimens (i.e. slides of interest).", 0, java.lang.Integer.MAX_VALUE, image));
1344        childrenList.add(new Property("conclusion", "string", "Concise and clinically contextualized narrative interpretation of the diagnostic report.", 0, java.lang.Integer.MAX_VALUE, conclusion));
1345        childrenList.add(new Property("codedDiagnosis", "CodeableConcept", "Codes for the conclusion.", 0, java.lang.Integer.MAX_VALUE, codedDiagnosis));
1346        childrenList.add(new Property("presentedForm", "Attachment", "Rich text representation of the entire result as issued by the diagnostic service. Multiple formats are allowed but they SHALL be semantically equivalent.", 0, java.lang.Integer.MAX_VALUE, presentedForm));
1347      }
1348
1349      @Override
1350      public void setProperty(String name, Base value) throws FHIRException {
1351        if (name.equals("identifier"))
1352          this.getIdentifier().add(castToIdentifier(value));
1353        else if (name.equals("status"))
1354          this.status = new DiagnosticReportStatusEnumFactory().fromType(value); // Enumeration<DiagnosticReportStatus>
1355        else if (name.equals("category"))
1356          this.category = castToCodeableConcept(value); // CodeableConcept
1357        else if (name.equals("code"))
1358          this.code = castToCodeableConcept(value); // CodeableConcept
1359        else if (name.equals("subject"))
1360          this.subject = castToReference(value); // Reference
1361        else if (name.equals("encounter"))
1362          this.encounter = castToReference(value); // Reference
1363        else if (name.equals("effective[x]"))
1364          this.effective = (Type) value; // Type
1365        else if (name.equals("issued"))
1366          this.issued = castToInstant(value); // InstantType
1367        else if (name.equals("performer"))
1368          this.performer = castToReference(value); // Reference
1369        else if (name.equals("request"))
1370          this.getRequest().add(castToReference(value));
1371        else if (name.equals("specimen"))
1372          this.getSpecimen().add(castToReference(value));
1373        else if (name.equals("result"))
1374          this.getResult().add(castToReference(value));
1375        else if (name.equals("imagingStudy"))
1376          this.getImagingStudy().add(castToReference(value));
1377        else if (name.equals("image"))
1378          this.getImage().add((DiagnosticReportImageComponent) value);
1379        else if (name.equals("conclusion"))
1380          this.conclusion = castToString(value); // StringType
1381        else if (name.equals("codedDiagnosis"))
1382          this.getCodedDiagnosis().add(castToCodeableConcept(value));
1383        else if (name.equals("presentedForm"))
1384          this.getPresentedForm().add(castToAttachment(value));
1385        else
1386          super.setProperty(name, value);
1387      }
1388
1389      @Override
1390      public Base addChild(String name) throws FHIRException {
1391        if (name.equals("identifier")) {
1392          return addIdentifier();
1393        }
1394        else if (name.equals("status")) {
1395          throw new FHIRException("Cannot call addChild on a primitive type DiagnosticReport.status");
1396        }
1397        else if (name.equals("category")) {
1398          this.category = new CodeableConcept();
1399          return this.category;
1400        }
1401        else if (name.equals("code")) {
1402          this.code = new CodeableConcept();
1403          return this.code;
1404        }
1405        else if (name.equals("subject")) {
1406          this.subject = new Reference();
1407          return this.subject;
1408        }
1409        else if (name.equals("encounter")) {
1410          this.encounter = new Reference();
1411          return this.encounter;
1412        }
1413        else if (name.equals("effectiveDateTime")) {
1414          this.effective = new DateTimeType();
1415          return this.effective;
1416        }
1417        else if (name.equals("effectivePeriod")) {
1418          this.effective = new Period();
1419          return this.effective;
1420        }
1421        else if (name.equals("issued")) {
1422          throw new FHIRException("Cannot call addChild on a primitive type DiagnosticReport.issued");
1423        }
1424        else if (name.equals("performer")) {
1425          this.performer = new Reference();
1426          return this.performer;
1427        }
1428        else if (name.equals("request")) {
1429          return addRequest();
1430        }
1431        else if (name.equals("specimen")) {
1432          return addSpecimen();
1433        }
1434        else if (name.equals("result")) {
1435          return addResult();
1436        }
1437        else if (name.equals("imagingStudy")) {
1438          return addImagingStudy();
1439        }
1440        else if (name.equals("image")) {
1441          return addImage();
1442        }
1443        else if (name.equals("conclusion")) {
1444          throw new FHIRException("Cannot call addChild on a primitive type DiagnosticReport.conclusion");
1445        }
1446        else if (name.equals("codedDiagnosis")) {
1447          return addCodedDiagnosis();
1448        }
1449        else if (name.equals("presentedForm")) {
1450          return addPresentedForm();
1451        }
1452        else
1453          return super.addChild(name);
1454      }
1455
1456  public String fhirType() {
1457    return "DiagnosticReport";
1458
1459  }
1460
1461      public DiagnosticReport copy() {
1462        DiagnosticReport dst = new DiagnosticReport();
1463        copyValues(dst);
1464        if (identifier != null) {
1465          dst.identifier = new ArrayList<Identifier>();
1466          for (Identifier i : identifier)
1467            dst.identifier.add(i.copy());
1468        };
1469        dst.status = status == null ? null : status.copy();
1470        dst.category = category == null ? null : category.copy();
1471        dst.code = code == null ? null : code.copy();
1472        dst.subject = subject == null ? null : subject.copy();
1473        dst.encounter = encounter == null ? null : encounter.copy();
1474        dst.effective = effective == null ? null : effective.copy();
1475        dst.issued = issued == null ? null : issued.copy();
1476        dst.performer = performer == null ? null : performer.copy();
1477        if (request != null) {
1478          dst.request = new ArrayList<Reference>();
1479          for (Reference i : request)
1480            dst.request.add(i.copy());
1481        };
1482        if (specimen != null) {
1483          dst.specimen = new ArrayList<Reference>();
1484          for (Reference i : specimen)
1485            dst.specimen.add(i.copy());
1486        };
1487        if (result != null) {
1488          dst.result = new ArrayList<Reference>();
1489          for (Reference i : result)
1490            dst.result.add(i.copy());
1491        };
1492        if (imagingStudy != null) {
1493          dst.imagingStudy = new ArrayList<Reference>();
1494          for (Reference i : imagingStudy)
1495            dst.imagingStudy.add(i.copy());
1496        };
1497        if (image != null) {
1498          dst.image = new ArrayList<DiagnosticReportImageComponent>();
1499          for (DiagnosticReportImageComponent i : image)
1500            dst.image.add(i.copy());
1501        };
1502        dst.conclusion = conclusion == null ? null : conclusion.copy();
1503        if (codedDiagnosis != null) {
1504          dst.codedDiagnosis = new ArrayList<CodeableConcept>();
1505          for (CodeableConcept i : codedDiagnosis)
1506            dst.codedDiagnosis.add(i.copy());
1507        };
1508        if (presentedForm != null) {
1509          dst.presentedForm = new ArrayList<Attachment>();
1510          for (Attachment i : presentedForm)
1511            dst.presentedForm.add(i.copy());
1512        };
1513        return dst;
1514      }
1515
1516      protected DiagnosticReport typedCopy() {
1517        return copy();
1518      }
1519
1520      @Override
1521      public boolean equalsDeep(Base other) {
1522        if (!super.equalsDeep(other))
1523          return false;
1524        if (!(other instanceof DiagnosticReport))
1525          return false;
1526        DiagnosticReport o = (DiagnosticReport) other;
1527        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
1528           && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
1529           && compareDeep(effective, o.effective, true) && compareDeep(issued, o.issued, true) && compareDeep(performer, o.performer, true)
1530           && compareDeep(request, o.request, true) && compareDeep(specimen, o.specimen, true) && compareDeep(result, o.result, true)
1531           && compareDeep(imagingStudy, o.imagingStudy, true) && compareDeep(image, o.image, true) && compareDeep(conclusion, o.conclusion, true)
1532           && compareDeep(codedDiagnosis, o.codedDiagnosis, true) && compareDeep(presentedForm, o.presentedForm, true)
1533          ;
1534      }
1535
1536      @Override
1537      public boolean equalsShallow(Base other) {
1538        if (!super.equalsShallow(other))
1539          return false;
1540        if (!(other instanceof DiagnosticReport))
1541          return false;
1542        DiagnosticReport o = (DiagnosticReport) other;
1543        return compareValues(status, o.status, true) && compareValues(issued, o.issued, true) && compareValues(conclusion, o.conclusion, true)
1544          ;
1545      }
1546
1547      public boolean isEmpty() {
1548        return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (status == null || status.isEmpty())
1549           && (category == null || category.isEmpty()) && (code == null || code.isEmpty()) && (subject == null || subject.isEmpty())
1550           && (encounter == null || encounter.isEmpty()) && (effective == null || effective.isEmpty())
1551           && (issued == null || issued.isEmpty()) && (performer == null || performer.isEmpty()) && (request == null || request.isEmpty())
1552           && (specimen == null || specimen.isEmpty()) && (result == null || result.isEmpty()) && (imagingStudy == null || imagingStudy.isEmpty())
1553           && (image == null || image.isEmpty()) && (conclusion == null || conclusion.isEmpty()) && (codedDiagnosis == null || codedDiagnosis.isEmpty())
1554           && (presentedForm == null || presentedForm.isEmpty());
1555      }
1556
1557  @Override
1558  public ResourceType getResourceType() {
1559    return ResourceType.DiagnosticReport;
1560   }
1561
1562  @SearchParamDefinition(name="date", path="DiagnosticReport.effective[x]", description="The clinically relevant time of the report", type="date" )
1563  public static final String SP_DATE = "date";
1564  @SearchParamDefinition(name="identifier", path="DiagnosticReport.identifier", description="An identifier for the report", type="token" )
1565  public static final String SP_IDENTIFIER = "identifier";
1566  @SearchParamDefinition(name="image", path="DiagnosticReport.image.link", description="A reference to the image source.", type="reference" )
1567  public static final String SP_IMAGE = "image";
1568  @SearchParamDefinition(name="request", path="DiagnosticReport.request", description="Reference to the test or procedure request.", type="reference" )
1569  public static final String SP_REQUEST = "request";
1570  @SearchParamDefinition(name="performer", path="DiagnosticReport.performer", description="Who was the source of the report (organization)", type="reference" )
1571  public static final String SP_PERFORMER = "performer";
1572  @SearchParamDefinition(name="code", path="DiagnosticReport.code", description="The code for the report as a whole, as opposed to codes for the atomic results, which are the names on the observation resource referred to from the result", type="token" )
1573  public static final String SP_CODE = "code";
1574  @SearchParamDefinition(name="subject", path="DiagnosticReport.subject", description="The subject of the report", type="reference" )
1575  public static final String SP_SUBJECT = "subject";
1576  @SearchParamDefinition(name="diagnosis", path="DiagnosticReport.codedDiagnosis", description="A coded diagnosis on the report", type="token" )
1577  public static final String SP_DIAGNOSIS = "diagnosis";
1578  @SearchParamDefinition(name="encounter", path="DiagnosticReport.encounter", description="The Encounter when the order was made", type="reference" )
1579  public static final String SP_ENCOUNTER = "encounter";
1580  @SearchParamDefinition(name="result", path="DiagnosticReport.result", description="Link to an atomic result (observation resource)", type="reference" )
1581  public static final String SP_RESULT = "result";
1582  @SearchParamDefinition(name="patient", path="DiagnosticReport.subject", description="The subject of the report if a patient", type="reference" )
1583  public static final String SP_PATIENT = "patient";
1584  @SearchParamDefinition(name="specimen", path="DiagnosticReport.specimen", description="The specimen details", type="reference" )
1585  public static final String SP_SPECIMEN = "specimen";
1586  @SearchParamDefinition(name="issued", path="DiagnosticReport.issued", description="When the report was issued", type="date" )
1587  public static final String SP_ISSUED = "issued";
1588  @SearchParamDefinition(name="category", path="DiagnosticReport.category", description="Which diagnostic discipline/department created the report", type="token" )
1589  public static final String SP_CATEGORY = "category";
1590  @SearchParamDefinition(name="status", path="DiagnosticReport.status", description="The status of the report", type="token" )
1591  public static final String SP_STATUS = "status";
1592
1593}