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