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