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 * Indicates an actual or potential clinical issue with or between one or more
048 * active or proposed clinical actions for a patient; e.g. Drug-drug
049 * interaction, Ineffective treatment frequency, Procedure-condition conflict,
050 * etc.
051 */
052@ResourceDef(name = "DetectedIssue", profile = "http://hl7.org/fhir/Profile/DetectedIssue")
053public class DetectedIssue extends DomainResource {
054
055  public enum DetectedIssueSeverity {
056    /**
057     * Indicates the issue may be life-threatening or has the potential to cause
058     * permanent injury.
059     */
060    HIGH,
061    /**
062     * Indicates the issue may result in noticeable adverse consequences but is
063     * unlikely to be life-threatening or cause permanent injury.
064     */
065    MODERATE,
066    /**
067     * Indicates the issue may result in some adverse consequences but is unlikely
068     * to substantially affect the situation of the subject.
069     */
070    LOW,
071    /**
072     * added to help the parsers
073     */
074    NULL;
075
076    public static DetectedIssueSeverity fromCode(String codeString) throws FHIRException {
077      if (codeString == null || "".equals(codeString))
078        return null;
079      if ("high".equals(codeString))
080        return HIGH;
081      if ("moderate".equals(codeString))
082        return MODERATE;
083      if ("low".equals(codeString))
084        return LOW;
085      throw new FHIRException("Unknown DetectedIssueSeverity code '" + codeString + "'");
086    }
087
088    public String toCode() {
089      switch (this) {
090      case HIGH:
091        return "high";
092      case MODERATE:
093        return "moderate";
094      case LOW:
095        return "low";
096      case NULL:
097        return null;
098      default:
099        return "?";
100      }
101    }
102
103    public String getSystem() {
104      switch (this) {
105      case HIGH:
106        return "http://hl7.org/fhir/detectedissue-severity";
107      case MODERATE:
108        return "http://hl7.org/fhir/detectedissue-severity";
109      case LOW:
110        return "http://hl7.org/fhir/detectedissue-severity";
111      case NULL:
112        return null;
113      default:
114        return "?";
115      }
116    }
117
118    public String getDefinition() {
119      switch (this) {
120      case HIGH:
121        return "Indicates the issue may be life-threatening or has the potential to cause permanent injury.";
122      case MODERATE:
123        return "Indicates the issue may result in noticeable adverse consequences but is unlikely to be life-threatening or cause permanent injury.";
124      case LOW:
125        return "Indicates the issue may result in some adverse consequences but is unlikely to substantially affect the situation of the subject.";
126      case NULL:
127        return null;
128      default:
129        return "?";
130      }
131    }
132
133    public String getDisplay() {
134      switch (this) {
135      case HIGH:
136        return "High";
137      case MODERATE:
138        return "Moderate";
139      case LOW:
140        return "Low";
141      case NULL:
142        return null;
143      default:
144        return "?";
145      }
146    }
147  }
148
149  public static class DetectedIssueSeverityEnumFactory implements EnumFactory<DetectedIssueSeverity> {
150    public DetectedIssueSeverity fromCode(String codeString) throws IllegalArgumentException {
151      if (codeString == null || "".equals(codeString))
152        if (codeString == null || "".equals(codeString))
153          return null;
154      if ("high".equals(codeString))
155        return DetectedIssueSeverity.HIGH;
156      if ("moderate".equals(codeString))
157        return DetectedIssueSeverity.MODERATE;
158      if ("low".equals(codeString))
159        return DetectedIssueSeverity.LOW;
160      throw new IllegalArgumentException("Unknown DetectedIssueSeverity code '" + codeString + "'");
161    }
162
163    public Enumeration<DetectedIssueSeverity> fromType(Base code) throws FHIRException {
164      if (code == null || code.isEmpty())
165        return null;
166      String codeString = ((PrimitiveType) code).asStringValue();
167      if (codeString == null || "".equals(codeString))
168        return null;
169      if ("high".equals(codeString))
170        return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.HIGH);
171      if ("moderate".equals(codeString))
172        return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.MODERATE);
173      if ("low".equals(codeString))
174        return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.LOW);
175      throw new FHIRException("Unknown DetectedIssueSeverity code '" + codeString + "'");
176    }
177
178    public String toCode(DetectedIssueSeverity code) {
179      if (code == DetectedIssueSeverity.HIGH)
180        return "high";
181      if (code == DetectedIssueSeverity.MODERATE)
182        return "moderate";
183      if (code == DetectedIssueSeverity.LOW)
184        return "low";
185      return "?";
186    }
187  }
188
189  @Block()
190  public static class DetectedIssueMitigationComponent extends BackboneElement implements IBaseBackboneElement {
191    /**
192     * Describes the action that was taken or the observation that was made that
193     * reduces/eliminates the risk associated with the identified issue.
194     */
195    @Child(name = "action", type = {
196        CodeableConcept.class }, order = 1, min = 1, max = 1, modifier = false, summary = false)
197    @Description(shortDefinition = "What mitigation?", formalDefinition = "Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.")
198    protected CodeableConcept action;
199
200    /**
201     * Indicates when the mitigating action was documented.
202     */
203    @Child(name = "date", type = { DateTimeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
204    @Description(shortDefinition = "Date committed", formalDefinition = "Indicates when the mitigating action was documented.")
205    protected DateTimeType date;
206
207    /**
208     * Identifies the practitioner who determined the mitigation and takes
209     * responsibility for the mitigation step occurring.
210     */
211    @Child(name = "author", type = {
212        Practitioner.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
213    @Description(shortDefinition = "Who is committing?", formalDefinition = "Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.")
214    protected Reference author;
215
216    /**
217     * The actual object that is the target of the reference (Identifies the
218     * practitioner who determined the mitigation and takes responsibility for the
219     * mitigation step occurring.)
220     */
221    protected Practitioner authorTarget;
222
223    private static final long serialVersionUID = -1994768436L;
224
225    /*
226     * Constructor
227     */
228    public DetectedIssueMitigationComponent() {
229      super();
230    }
231
232    /*
233     * Constructor
234     */
235    public DetectedIssueMitigationComponent(CodeableConcept action) {
236      super();
237      this.action = action;
238    }
239
240    /**
241     * @return {@link #action} (Describes the action that was taken or the
242     *         observation that was made that reduces/eliminates the risk associated
243     *         with the identified issue.)
244     */
245    public CodeableConcept getAction() {
246      if (this.action == null)
247        if (Configuration.errorOnAutoCreate())
248          throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.action");
249        else if (Configuration.doAutoCreate())
250          this.action = new CodeableConcept(); // cc
251      return this.action;
252    }
253
254    public boolean hasAction() {
255      return this.action != null && !this.action.isEmpty();
256    }
257
258    /**
259     * @param value {@link #action} (Describes the action that was taken or the
260     *              observation that was made that reduces/eliminates the risk
261     *              associated with the identified issue.)
262     */
263    public DetectedIssueMitigationComponent setAction(CodeableConcept value) {
264      this.action = value;
265      return this;
266    }
267
268    /**
269     * @return {@link #date} (Indicates when the mitigating action was documented.).
270     *         This is the underlying object with id, value and extensions. The
271     *         accessor "getDate" gives direct access to the value
272     */
273    public DateTimeType getDateElement() {
274      if (this.date == null)
275        if (Configuration.errorOnAutoCreate())
276          throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.date");
277        else if (Configuration.doAutoCreate())
278          this.date = new DateTimeType(); // bb
279      return this.date;
280    }
281
282    public boolean hasDateElement() {
283      return this.date != null && !this.date.isEmpty();
284    }
285
286    public boolean hasDate() {
287      return this.date != null && !this.date.isEmpty();
288    }
289
290    /**
291     * @param value {@link #date} (Indicates when the mitigating action was
292     *              documented.). This is the underlying object with id, value and
293     *              extensions. The accessor "getDate" gives direct access to the
294     *              value
295     */
296    public DetectedIssueMitigationComponent setDateElement(DateTimeType value) {
297      this.date = value;
298      return this;
299    }
300
301    /**
302     * @return Indicates when the mitigating action was documented.
303     */
304    public Date getDate() {
305      return this.date == null ? null : this.date.getValue();
306    }
307
308    /**
309     * @param value Indicates when the mitigating action was documented.
310     */
311    public DetectedIssueMitigationComponent setDate(Date value) {
312      if (value == null)
313        this.date = null;
314      else {
315        if (this.date == null)
316          this.date = new DateTimeType();
317        this.date.setValue(value);
318      }
319      return this;
320    }
321
322    /**
323     * @return {@link #author} (Identifies the practitioner who determined the
324     *         mitigation and takes responsibility for the mitigation step
325     *         occurring.)
326     */
327    public Reference getAuthor() {
328      if (this.author == null)
329        if (Configuration.errorOnAutoCreate())
330          throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.author");
331        else if (Configuration.doAutoCreate())
332          this.author = new Reference(); // cc
333      return this.author;
334    }
335
336    public boolean hasAuthor() {
337      return this.author != null && !this.author.isEmpty();
338    }
339
340    /**
341     * @param value {@link #author} (Identifies the practitioner who determined the
342     *              mitigation and takes responsibility for the mitigation step
343     *              occurring.)
344     */
345    public DetectedIssueMitigationComponent setAuthor(Reference value) {
346      this.author = value;
347      return this;
348    }
349
350    /**
351     * @return {@link #author} The actual object that is the target of the
352     *         reference. The reference library doesn't populate this, but you can
353     *         use it to hold the resource if you resolve it. (Identifies the
354     *         practitioner who determined the mitigation and takes responsibility
355     *         for the mitigation step occurring.)
356     */
357    public Practitioner getAuthorTarget() {
358      if (this.authorTarget == null)
359        if (Configuration.errorOnAutoCreate())
360          throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.author");
361        else if (Configuration.doAutoCreate())
362          this.authorTarget = new Practitioner(); // aa
363      return this.authorTarget;
364    }
365
366    /**
367     * @param value {@link #author} The actual object that is the target of the
368     *              reference. The reference library doesn't use these, but you can
369     *              use it to hold the resource if you resolve it. (Identifies the
370     *              practitioner who determined the mitigation and takes
371     *              responsibility for the mitigation step occurring.)
372     */
373    public DetectedIssueMitigationComponent setAuthorTarget(Practitioner value) {
374      this.authorTarget = value;
375      return this;
376    }
377
378    protected void listChildren(List<Property> childrenList) {
379      super.listChildren(childrenList);
380      childrenList.add(new Property("action", "CodeableConcept",
381          "Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.",
382          0, java.lang.Integer.MAX_VALUE, action));
383      childrenList.add(new Property("date", "dateTime", "Indicates when the mitigating action was documented.", 0,
384          java.lang.Integer.MAX_VALUE, date));
385      childrenList.add(new Property("author", "Reference(Practitioner)",
386          "Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.",
387          0, java.lang.Integer.MAX_VALUE, author));
388    }
389
390    @Override
391    public void setProperty(String name, Base value) throws FHIRException {
392      if (name.equals("action"))
393        this.action = castToCodeableConcept(value); // CodeableConcept
394      else if (name.equals("date"))
395        this.date = castToDateTime(value); // DateTimeType
396      else if (name.equals("author"))
397        this.author = castToReference(value); // Reference
398      else
399        super.setProperty(name, value);
400    }
401
402    @Override
403    public Base addChild(String name) throws FHIRException {
404      if (name.equals("action")) {
405        this.action = new CodeableConcept();
406        return this.action;
407      } else if (name.equals("date")) {
408        throw new FHIRException("Cannot call addChild on a singleton property DetectedIssue.date");
409      } else if (name.equals("author")) {
410        this.author = new Reference();
411        return this.author;
412      } else
413        return super.addChild(name);
414    }
415
416    public DetectedIssueMitigationComponent copy() {
417      DetectedIssueMitigationComponent dst = new DetectedIssueMitigationComponent();
418      copyValues(dst);
419      dst.action = action == null ? null : action.copy();
420      dst.date = date == null ? null : date.copy();
421      dst.author = author == null ? null : author.copy();
422      return dst;
423    }
424
425    @Override
426    public boolean equalsDeep(Base other) {
427      if (!super.equalsDeep(other))
428        return false;
429      if (!(other instanceof DetectedIssueMitigationComponent))
430        return false;
431      DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other;
432      return compareDeep(action, o.action, true) && compareDeep(date, o.date, true)
433          && compareDeep(author, o.author, true);
434    }
435
436    @Override
437    public boolean equalsShallow(Base other) {
438      if (!super.equalsShallow(other))
439        return false;
440      if (!(other instanceof DetectedIssueMitigationComponent))
441        return false;
442      DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other;
443      return compareValues(date, o.date, true);
444    }
445
446    public boolean isEmpty() {
447      return super.isEmpty() && (action == null || action.isEmpty()) && (date == null || date.isEmpty())
448          && (author == null || author.isEmpty());
449    }
450
451    public String fhirType() {
452      return "DetectedIssue.mitigation";
453
454    }
455
456  }
457
458  /**
459   * Indicates the patient whose record the detected issue is associated with.
460   */
461  @Child(name = "patient", type = { Patient.class }, order = 0, min = 0, max = 1, modifier = false, summary = true)
462  @Description(shortDefinition = "Associated patient", formalDefinition = "Indicates the patient whose record the detected issue is associated with.")
463  protected Reference patient;
464
465  /**
466   * The actual object that is the target of the reference (Indicates the patient
467   * whose record the detected issue is associated with.)
468   */
469  protected Patient patientTarget;
470
471  /**
472   * Identifies the general type of issue identified.
473   */
474  @Child(name = "category", type = {
475      CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
476  @Description(shortDefinition = "Issue Category, e.g. drug-drug, duplicate therapy, etc.", formalDefinition = "Identifies the general type of issue identified.")
477  protected CodeableConcept category;
478
479  /**
480   * Indicates the degree of importance associated with the identified issue based
481   * on the potential impact on the patient.
482   */
483  @Child(name = "severity", type = { CodeType.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
484  @Description(shortDefinition = "high | moderate | low", formalDefinition = "Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.")
485  protected Enumeration<DetectedIssueSeverity> severity;
486
487  /**
488   * Indicates the resource representing the current activity or proposed activity
489   * that is potentially problematic.
490   */
491  @Child(name = "implicated", type = {}, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
492  @Description(shortDefinition = "Problem resource", formalDefinition = "Indicates the resource representing the current activity or proposed activity that is potentially problematic.")
493  protected List<Reference> implicated;
494  /**
495   * The actual objects that are the target of the reference (Indicates the
496   * resource representing the current activity or proposed activity that is
497   * potentially problematic.)
498   */
499  protected List<Resource> implicatedTarget;
500
501  /**
502   * A textual explanation of the detected issue.
503   */
504  @Child(name = "detail", type = { StringType.class }, order = 4, min = 0, max = 1, modifier = false, summary = false)
505  @Description(shortDefinition = "Description and context", formalDefinition = "A textual explanation of the detected issue.")
506  protected StringType detail;
507
508  /**
509   * The date or date-time when the detected issue was initially identified.
510   */
511  @Child(name = "date", type = { DateTimeType.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
512  @Description(shortDefinition = "When identified", formalDefinition = "The date or date-time when the detected issue was initially identified.")
513  protected DateTimeType date;
514
515  /**
516   * Individual or device responsible for the issue being raised. For example, a
517   * decision support application or a pharmacist conducting a medication review.
518   */
519  @Child(name = "author", type = { Practitioner.class,
520      Device.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
521  @Description(shortDefinition = "The provider or device that identified the issue", formalDefinition = "Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.")
522  protected Reference author;
523
524  /**
525   * The actual object that is the target of the reference (Individual or device
526   * responsible for the issue being raised. For example, a decision support
527   * application or a pharmacist conducting a medication review.)
528   */
529  protected Resource authorTarget;
530
531  /**
532   * Business identifier associated with the detected issue record.
533   */
534  @Child(name = "identifier", type = {
535      Identifier.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
536  @Description(shortDefinition = "Unique id for the detected issue", formalDefinition = "Business identifier associated with the detected issue record.")
537  protected Identifier identifier;
538
539  /**
540   * The literature, knowledge-base or similar reference that describes the
541   * propensity for the detected issue identified.
542   */
543  @Child(name = "reference", type = { UriType.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
544  @Description(shortDefinition = "Authority for issue", formalDefinition = "The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.")
545  protected UriType reference;
546
547  /**
548   * Indicates an action that has been taken or is committed to to reduce or
549   * eliminate the likelihood of the risk identified by the detected issue from
550   * manifesting. Can also reflect an observation of known mitigating factors that
551   * may reduce/eliminate the need for any action.
552   */
553  @Child(name = "mitigation", type = {}, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
554  @Description(shortDefinition = "Step taken to address", formalDefinition = "Indicates an action that has been taken or is committed to to reduce or eliminate the likelihood of the risk identified by the detected issue from manifesting.  Can also reflect an observation of known mitigating factors that may reduce/eliminate the need for any action.")
555  protected List<DetectedIssueMitigationComponent> mitigation;
556
557  private static final long serialVersionUID = -403732234L;
558
559  /*
560   * Constructor
561   */
562  public DetectedIssue() {
563    super();
564  }
565
566  /**
567   * @return {@link #patient} (Indicates the patient whose record the detected
568   *         issue is associated with.)
569   */
570  public Reference getPatient() {
571    if (this.patient == null)
572      if (Configuration.errorOnAutoCreate())
573        throw new Error("Attempt to auto-create DetectedIssue.patient");
574      else if (Configuration.doAutoCreate())
575        this.patient = new Reference(); // cc
576    return this.patient;
577  }
578
579  public boolean hasPatient() {
580    return this.patient != null && !this.patient.isEmpty();
581  }
582
583  /**
584   * @param value {@link #patient} (Indicates the patient whose record the
585   *              detected issue is associated with.)
586   */
587  public DetectedIssue setPatient(Reference value) {
588    this.patient = value;
589    return this;
590  }
591
592  /**
593   * @return {@link #patient} The actual object that is the target of the
594   *         reference. The reference library doesn't populate this, but you can
595   *         use it to hold the resource if you resolve it. (Indicates the patient
596   *         whose record the detected issue is associated with.)
597   */
598  public Patient getPatientTarget() {
599    if (this.patientTarget == null)
600      if (Configuration.errorOnAutoCreate())
601        throw new Error("Attempt to auto-create DetectedIssue.patient");
602      else if (Configuration.doAutoCreate())
603        this.patientTarget = new Patient(); // aa
604    return this.patientTarget;
605  }
606
607  /**
608   * @param value {@link #patient} The actual object that is the target of the
609   *              reference. The reference library doesn't use these, but you can
610   *              use it to hold the resource if you resolve it. (Indicates the
611   *              patient whose record the detected issue is associated with.)
612   */
613  public DetectedIssue setPatientTarget(Patient value) {
614    this.patientTarget = value;
615    return this;
616  }
617
618  /**
619   * @return {@link #category} (Identifies the general type of issue identified.)
620   */
621  public CodeableConcept getCategory() {
622    if (this.category == null)
623      if (Configuration.errorOnAutoCreate())
624        throw new Error("Attempt to auto-create DetectedIssue.category");
625      else if (Configuration.doAutoCreate())
626        this.category = new CodeableConcept(); // cc
627    return this.category;
628  }
629
630  public boolean hasCategory() {
631    return this.category != null && !this.category.isEmpty();
632  }
633
634  /**
635   * @param value {@link #category} (Identifies the general type of issue
636   *              identified.)
637   */
638  public DetectedIssue setCategory(CodeableConcept value) {
639    this.category = value;
640    return this;
641  }
642
643  /**
644   * @return {@link #severity} (Indicates the degree of importance associated with
645   *         the identified issue based on the potential impact on the patient.).
646   *         This is the underlying object with id, value and extensions. The
647   *         accessor "getSeverity" gives direct access to the value
648   */
649  public Enumeration<DetectedIssueSeverity> getSeverityElement() {
650    if (this.severity == null)
651      if (Configuration.errorOnAutoCreate())
652        throw new Error("Attempt to auto-create DetectedIssue.severity");
653      else if (Configuration.doAutoCreate())
654        this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory()); // bb
655    return this.severity;
656  }
657
658  public boolean hasSeverityElement() {
659    return this.severity != null && !this.severity.isEmpty();
660  }
661
662  public boolean hasSeverity() {
663    return this.severity != null && !this.severity.isEmpty();
664  }
665
666  /**
667   * @param value {@link #severity} (Indicates the degree of importance associated
668   *              with the identified issue based on the potential impact on the
669   *              patient.). This is the underlying object with id, value and
670   *              extensions. The accessor "getSeverity" gives direct access to
671   *              the value
672   */
673  public DetectedIssue setSeverityElement(Enumeration<DetectedIssueSeverity> value) {
674    this.severity = value;
675    return this;
676  }
677
678  /**
679   * @return Indicates the degree of importance associated with the identified
680   *         issue based on the potential impact on the patient.
681   */
682  public DetectedIssueSeverity getSeverity() {
683    return this.severity == null ? null : this.severity.getValue();
684  }
685
686  /**
687   * @param value Indicates the degree of importance associated with the
688   *              identified issue based on the potential impact on the patient.
689   */
690  public DetectedIssue setSeverity(DetectedIssueSeverity value) {
691    if (value == null)
692      this.severity = null;
693    else {
694      if (this.severity == null)
695        this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory());
696      this.severity.setValue(value);
697    }
698    return this;
699  }
700
701  /**
702   * @return {@link #implicated} (Indicates the resource representing the current
703   *         activity or proposed activity that is potentially problematic.)
704   */
705  public List<Reference> getImplicated() {
706    if (this.implicated == null)
707      this.implicated = new ArrayList<Reference>();
708    return this.implicated;
709  }
710
711  public boolean hasImplicated() {
712    if (this.implicated == null)
713      return false;
714    for (Reference item : this.implicated)
715      if (!item.isEmpty())
716        return true;
717    return false;
718  }
719
720  /**
721   * @return {@link #implicated} (Indicates the resource representing the current
722   *         activity or proposed activity that is potentially problematic.)
723   */
724  // syntactic sugar
725  public Reference addImplicated() { // 3
726    Reference t = new Reference();
727    if (this.implicated == null)
728      this.implicated = new ArrayList<Reference>();
729    this.implicated.add(t);
730    return t;
731  }
732
733  // syntactic sugar
734  public DetectedIssue addImplicated(Reference t) { // 3
735    if (t == null)
736      return this;
737    if (this.implicated == null)
738      this.implicated = new ArrayList<Reference>();
739    this.implicated.add(t);
740    return this;
741  }
742
743  /**
744   * @return {@link #implicated} (The actual objects that are the target of the
745   *         reference. The reference library doesn't populate this, but you can
746   *         use this to hold the resources if you resolvethemt. Indicates the
747   *         resource representing the current activity or proposed activity that
748   *         is potentially problematic.)
749   */
750  public List<Resource> getImplicatedTarget() {
751    if (this.implicatedTarget == null)
752      this.implicatedTarget = new ArrayList<Resource>();
753    return this.implicatedTarget;
754  }
755
756  /**
757   * @return {@link #detail} (A textual explanation of the detected issue.). This
758   *         is the underlying object with id, value and extensions. The accessor
759   *         "getDetail" gives direct access to the value
760   */
761  public StringType getDetailElement() {
762    if (this.detail == null)
763      if (Configuration.errorOnAutoCreate())
764        throw new Error("Attempt to auto-create DetectedIssue.detail");
765      else if (Configuration.doAutoCreate())
766        this.detail = new StringType(); // bb
767    return this.detail;
768  }
769
770  public boolean hasDetailElement() {
771    return this.detail != null && !this.detail.isEmpty();
772  }
773
774  public boolean hasDetail() {
775    return this.detail != null && !this.detail.isEmpty();
776  }
777
778  /**
779   * @param value {@link #detail} (A textual explanation of the detected issue.).
780   *              This is the underlying object with id, value and extensions. The
781   *              accessor "getDetail" gives direct access to the value
782   */
783  public DetectedIssue setDetailElement(StringType value) {
784    this.detail = value;
785    return this;
786  }
787
788  /**
789   * @return A textual explanation of the detected issue.
790   */
791  public String getDetail() {
792    return this.detail == null ? null : this.detail.getValue();
793  }
794
795  /**
796   * @param value A textual explanation of the detected issue.
797   */
798  public DetectedIssue setDetail(String value) {
799    if (Utilities.noString(value))
800      this.detail = null;
801    else {
802      if (this.detail == null)
803        this.detail = new StringType();
804      this.detail.setValue(value);
805    }
806    return this;
807  }
808
809  /**
810   * @return {@link #date} (The date or date-time when the detected issue was
811   *         initially identified.). This is the underlying object with id, value
812   *         and extensions. The accessor "getDate" gives direct access to the
813   *         value
814   */
815  public DateTimeType getDateElement() {
816    if (this.date == null)
817      if (Configuration.errorOnAutoCreate())
818        throw new Error("Attempt to auto-create DetectedIssue.date");
819      else if (Configuration.doAutoCreate())
820        this.date = new DateTimeType(); // bb
821    return this.date;
822  }
823
824  public boolean hasDateElement() {
825    return this.date != null && !this.date.isEmpty();
826  }
827
828  public boolean hasDate() {
829    return this.date != null && !this.date.isEmpty();
830  }
831
832  /**
833   * @param value {@link #date} (The date or date-time when the detected issue was
834   *              initially identified.). This is the underlying object with id,
835   *              value and extensions. The accessor "getDate" gives direct access
836   *              to the value
837   */
838  public DetectedIssue setDateElement(DateTimeType value) {
839    this.date = value;
840    return this;
841  }
842
843  /**
844   * @return The date or date-time when the detected issue was initially
845   *         identified.
846   */
847  public Date getDate() {
848    return this.date == null ? null : this.date.getValue();
849  }
850
851  /**
852   * @param value The date or date-time when the detected issue was initially
853   *              identified.
854   */
855  public DetectedIssue setDate(Date value) {
856    if (value == null)
857      this.date = null;
858    else {
859      if (this.date == null)
860        this.date = new DateTimeType();
861      this.date.setValue(value);
862    }
863    return this;
864  }
865
866  /**
867   * @return {@link #author} (Individual or device responsible for the issue being
868   *         raised. For example, a decision support application or a pharmacist
869   *         conducting a medication review.)
870   */
871  public Reference getAuthor() {
872    if (this.author == null)
873      if (Configuration.errorOnAutoCreate())
874        throw new Error("Attempt to auto-create DetectedIssue.author");
875      else if (Configuration.doAutoCreate())
876        this.author = new Reference(); // cc
877    return this.author;
878  }
879
880  public boolean hasAuthor() {
881    return this.author != null && !this.author.isEmpty();
882  }
883
884  /**
885   * @param value {@link #author} (Individual or device responsible for the issue
886   *              being raised. For example, a decision support application or a
887   *              pharmacist conducting a medication review.)
888   */
889  public DetectedIssue setAuthor(Reference value) {
890    this.author = value;
891    return this;
892  }
893
894  /**
895   * @return {@link #author} The actual object that is the target of the
896   *         reference. The reference library doesn't populate this, but you can
897   *         use it to hold the resource if you resolve it. (Individual or device
898   *         responsible for the issue being raised. For example, a decision
899   *         support application or a pharmacist conducting a medication review.)
900   */
901  public Resource getAuthorTarget() {
902    return this.authorTarget;
903  }
904
905  /**
906   * @param value {@link #author} The actual object that is the target of the
907   *              reference. The reference library doesn't use these, but you can
908   *              use it to hold the resource if you resolve it. (Individual or
909   *              device responsible for the issue being raised. For example, a
910   *              decision support application or a pharmacist conducting a
911   *              medication review.)
912   */
913  public DetectedIssue setAuthorTarget(Resource value) {
914    this.authorTarget = value;
915    return this;
916  }
917
918  /**
919   * @return {@link #identifier} (Business identifier associated with the detected
920   *         issue record.)
921   */
922  public Identifier getIdentifier() {
923    if (this.identifier == null)
924      if (Configuration.errorOnAutoCreate())
925        throw new Error("Attempt to auto-create DetectedIssue.identifier");
926      else if (Configuration.doAutoCreate())
927        this.identifier = new Identifier(); // cc
928    return this.identifier;
929  }
930
931  public boolean hasIdentifier() {
932    return this.identifier != null && !this.identifier.isEmpty();
933  }
934
935  /**
936   * @param value {@link #identifier} (Business identifier associated with the
937   *              detected issue record.)
938   */
939  public DetectedIssue setIdentifier(Identifier value) {
940    this.identifier = value;
941    return this;
942  }
943
944  /**
945   * @return {@link #reference} (The literature, knowledge-base or similar
946   *         reference that describes the propensity for the detected issue
947   *         identified.). This is the underlying object with id, value and
948   *         extensions. The accessor "getReference" gives direct access to the
949   *         value
950   */
951  public UriType getReferenceElement() {
952    if (this.reference == null)
953      if (Configuration.errorOnAutoCreate())
954        throw new Error("Attempt to auto-create DetectedIssue.reference");
955      else if (Configuration.doAutoCreate())
956        this.reference = new UriType(); // bb
957    return this.reference;
958  }
959
960  public boolean hasReferenceElement() {
961    return this.reference != null && !this.reference.isEmpty();
962  }
963
964  public boolean hasReference() {
965    return this.reference != null && !this.reference.isEmpty();
966  }
967
968  /**
969   * @param value {@link #reference} (The literature, knowledge-base or similar
970   *              reference that describes the propensity for the detected issue
971   *              identified.). This is the underlying object with id, value and
972   *              extensions. The accessor "getReference" gives direct access to
973   *              the value
974   */
975  public DetectedIssue setReferenceElement(UriType value) {
976    this.reference = value;
977    return this;
978  }
979
980  /**
981   * @return The literature, knowledge-base or similar reference that describes
982   *         the propensity for the detected issue identified.
983   */
984  public String getReference() {
985    return this.reference == null ? null : this.reference.getValue();
986  }
987
988  /**
989   * @param value The literature, knowledge-base or similar reference that
990   *              describes the propensity for the detected issue identified.
991   */
992  public DetectedIssue setReference(String value) {
993    if (Utilities.noString(value))
994      this.reference = null;
995    else {
996      if (this.reference == null)
997        this.reference = new UriType();
998      this.reference.setValue(value);
999    }
1000    return this;
1001  }
1002
1003  /**
1004   * @return {@link #mitigation} (Indicates an action that has been taken or is
1005   *         committed to to reduce or eliminate the likelihood of the risk
1006   *         identified by the detected issue from manifesting. Can also reflect
1007   *         an observation of known mitigating factors that may reduce/eliminate
1008   *         the need for any action.)
1009   */
1010  public List<DetectedIssueMitigationComponent> getMitigation() {
1011    if (this.mitigation == null)
1012      this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1013    return this.mitigation;
1014  }
1015
1016  public boolean hasMitigation() {
1017    if (this.mitigation == null)
1018      return false;
1019    for (DetectedIssueMitigationComponent item : this.mitigation)
1020      if (!item.isEmpty())
1021        return true;
1022    return false;
1023  }
1024
1025  /**
1026   * @return {@link #mitigation} (Indicates an action that has been taken or is
1027   *         committed to to reduce or eliminate the likelihood of the risk
1028   *         identified by the detected issue from manifesting. Can also reflect
1029   *         an observation of known mitigating factors that may reduce/eliminate
1030   *         the need for any action.)
1031   */
1032  // syntactic sugar
1033  public DetectedIssueMitigationComponent addMitigation() { // 3
1034    DetectedIssueMitigationComponent t = new DetectedIssueMitigationComponent();
1035    if (this.mitigation == null)
1036      this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1037    this.mitigation.add(t);
1038    return t;
1039  }
1040
1041  // syntactic sugar
1042  public DetectedIssue addMitigation(DetectedIssueMitigationComponent t) { // 3
1043    if (t == null)
1044      return this;
1045    if (this.mitigation == null)
1046      this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1047    this.mitigation.add(t);
1048    return this;
1049  }
1050
1051  protected void listChildren(List<Property> childrenList) {
1052    super.listChildren(childrenList);
1053    childrenList.add(new Property("patient", "Reference(Patient)",
1054        "Indicates the patient whose record the detected issue is associated with.", 0, java.lang.Integer.MAX_VALUE,
1055        patient));
1056    childrenList.add(new Property("category", "CodeableConcept", "Identifies the general type of issue identified.", 0,
1057        java.lang.Integer.MAX_VALUE, category));
1058    childrenList.add(new Property("severity", "code",
1059        "Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.",
1060        0, java.lang.Integer.MAX_VALUE, severity));
1061    childrenList.add(new Property("implicated", "Reference(Any)",
1062        "Indicates the resource representing the current activity or proposed activity that is potentially problematic.",
1063        0, java.lang.Integer.MAX_VALUE, implicated));
1064    childrenList.add(new Property("detail", "string", "A textual explanation of the detected issue.", 0,
1065        java.lang.Integer.MAX_VALUE, detail));
1066    childrenList
1067        .add(new Property("date", "dateTime", "The date or date-time when the detected issue was initially identified.",
1068            0, java.lang.Integer.MAX_VALUE, date));
1069    childrenList.add(new Property("author", "Reference(Practitioner|Device)",
1070        "Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.",
1071        0, java.lang.Integer.MAX_VALUE, author));
1072    childrenList.add(new Property("identifier", "Identifier",
1073        "Business identifier associated with the detected issue record.", 0, java.lang.Integer.MAX_VALUE, identifier));
1074    childrenList.add(new Property("reference", "uri",
1075        "The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.",
1076        0, java.lang.Integer.MAX_VALUE, reference));
1077    childrenList.add(new Property("mitigation", "",
1078        "Indicates an action that has been taken or is committed to to reduce or eliminate the likelihood of the risk identified by the detected issue from manifesting.  Can also reflect an observation of known mitigating factors that may reduce/eliminate the need for any action.",
1079        0, java.lang.Integer.MAX_VALUE, mitigation));
1080  }
1081
1082  @Override
1083  public void setProperty(String name, Base value) throws FHIRException {
1084    if (name.equals("patient"))
1085      this.patient = castToReference(value); // Reference
1086    else if (name.equals("category"))
1087      this.category = castToCodeableConcept(value); // CodeableConcept
1088    else if (name.equals("severity"))
1089      this.severity = new DetectedIssueSeverityEnumFactory().fromType(value); // Enumeration<DetectedIssueSeverity>
1090    else if (name.equals("implicated"))
1091      this.getImplicated().add(castToReference(value));
1092    else if (name.equals("detail"))
1093      this.detail = castToString(value); // StringType
1094    else if (name.equals("date"))
1095      this.date = castToDateTime(value); // DateTimeType
1096    else if (name.equals("author"))
1097      this.author = castToReference(value); // Reference
1098    else if (name.equals("identifier"))
1099      this.identifier = castToIdentifier(value); // Identifier
1100    else if (name.equals("reference"))
1101      this.reference = castToUri(value); // UriType
1102    else if (name.equals("mitigation"))
1103      this.getMitigation().add((DetectedIssueMitigationComponent) value);
1104    else
1105      super.setProperty(name, value);
1106  }
1107
1108  @Override
1109  public Base addChild(String name) throws FHIRException {
1110    if (name.equals("patient")) {
1111      this.patient = new Reference();
1112      return this.patient;
1113    } else if (name.equals("category")) {
1114      this.category = new CodeableConcept();
1115      return this.category;
1116    } else if (name.equals("severity")) {
1117      throw new FHIRException("Cannot call addChild on a singleton property DetectedIssue.severity");
1118    } else if (name.equals("implicated")) {
1119      return addImplicated();
1120    } else if (name.equals("detail")) {
1121      throw new FHIRException("Cannot call addChild on a singleton property DetectedIssue.detail");
1122    } else if (name.equals("date")) {
1123      throw new FHIRException("Cannot call addChild on a singleton property DetectedIssue.date");
1124    } else if (name.equals("author")) {
1125      this.author = new Reference();
1126      return this.author;
1127    } else if (name.equals("identifier")) {
1128      this.identifier = new Identifier();
1129      return this.identifier;
1130    } else if (name.equals("reference")) {
1131      throw new FHIRException("Cannot call addChild on a singleton property DetectedIssue.reference");
1132    } else if (name.equals("mitigation")) {
1133      return addMitigation();
1134    } else
1135      return super.addChild(name);
1136  }
1137
1138  public String fhirType() {
1139    return "DetectedIssue";
1140
1141  }
1142
1143  public DetectedIssue copy() {
1144    DetectedIssue dst = new DetectedIssue();
1145    copyValues(dst);
1146    dst.patient = patient == null ? null : patient.copy();
1147    dst.category = category == null ? null : category.copy();
1148    dst.severity = severity == null ? null : severity.copy();
1149    if (implicated != null) {
1150      dst.implicated = new ArrayList<Reference>();
1151      for (Reference i : implicated)
1152        dst.implicated.add(i.copy());
1153    }
1154    ;
1155    dst.detail = detail == null ? null : detail.copy();
1156    dst.date = date == null ? null : date.copy();
1157    dst.author = author == null ? null : author.copy();
1158    dst.identifier = identifier == null ? null : identifier.copy();
1159    dst.reference = reference == null ? null : reference.copy();
1160    if (mitigation != null) {
1161      dst.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1162      for (DetectedIssueMitigationComponent i : mitigation)
1163        dst.mitigation.add(i.copy());
1164    }
1165    ;
1166    return dst;
1167  }
1168
1169  protected DetectedIssue typedCopy() {
1170    return copy();
1171  }
1172
1173  @Override
1174  public boolean equalsDeep(Base other) {
1175    if (!super.equalsDeep(other))
1176      return false;
1177    if (!(other instanceof DetectedIssue))
1178      return false;
1179    DetectedIssue o = (DetectedIssue) other;
1180    return compareDeep(patient, o.patient, true) && compareDeep(category, o.category, true)
1181        && compareDeep(severity, o.severity, true) && compareDeep(implicated, o.implicated, true)
1182        && compareDeep(detail, o.detail, true) && compareDeep(date, o.date, true) && compareDeep(author, o.author, true)
1183        && compareDeep(identifier, o.identifier, true) && compareDeep(reference, o.reference, true)
1184        && compareDeep(mitigation, o.mitigation, true);
1185  }
1186
1187  @Override
1188  public boolean equalsShallow(Base other) {
1189    if (!super.equalsShallow(other))
1190      return false;
1191    if (!(other instanceof DetectedIssue))
1192      return false;
1193    DetectedIssue o = (DetectedIssue) other;
1194    return compareValues(severity, o.severity, true) && compareValues(detail, o.detail, true)
1195        && compareValues(date, o.date, true) && compareValues(reference, o.reference, true);
1196  }
1197
1198  public boolean isEmpty() {
1199    return super.isEmpty() && (patient == null || patient.isEmpty()) && (category == null || category.isEmpty())
1200        && (severity == null || severity.isEmpty()) && (implicated == null || implicated.isEmpty())
1201        && (detail == null || detail.isEmpty()) && (date == null || date.isEmpty())
1202        && (author == null || author.isEmpty()) && (identifier == null || identifier.isEmpty())
1203        && (reference == null || reference.isEmpty()) && (mitigation == null || mitigation.isEmpty());
1204  }
1205
1206  @Override
1207  public ResourceType getResourceType() {
1208    return ResourceType.DetectedIssue;
1209  }
1210
1211  @SearchParamDefinition(name = "date", path = "DetectedIssue.date", description = "When identified", type = "date")
1212  public static final String SP_DATE = "date";
1213  @SearchParamDefinition(name = "identifier", path = "DetectedIssue.identifier", description = "Unique id for the detected issue", type = "token")
1214  public static final String SP_IDENTIFIER = "identifier";
1215  @SearchParamDefinition(name = "patient", path = "DetectedIssue.patient", description = "Associated patient", type = "reference")
1216  public static final String SP_PATIENT = "patient";
1217  @SearchParamDefinition(name = "author", path = "DetectedIssue.author", description = "The provider or device that identified the issue", type = "reference")
1218  public static final String SP_AUTHOR = "author";
1219  @SearchParamDefinition(name = "implicated", path = "DetectedIssue.implicated", description = "Problem resource", type = "reference")
1220  public static final String SP_IMPLICATED = "implicated";
1221  @SearchParamDefinition(name = "category", path = "DetectedIssue.category", description = "Issue Category, e.g. drug-drug, duplicate therapy, etc.", type = "token")
1222  public static final String SP_CATEGORY = "category";
1223
1224}