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