001package org.hl7.fhir.instance.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.*;
034
035import org.hl7.fhir.exceptions.FHIRException;
036import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
037import org.hl7.fhir.utilities.Utilities;
038
039import ca.uhn.fhir.model.api.annotation.*;
040/**
041 * Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, Ineffective treatment frequency, Procedure-condition conflict, etc.
042 */
043@ResourceDef(name="DetectedIssue", profile="http://hl7.org/fhir/Profile/DetectedIssue")
044public class DetectedIssue extends DomainResource {
045
046    public enum DetectedIssueSeverity {
047        /**
048         * Indicates the issue may be life-threatening or has the potential to cause permanent injury.
049         */
050        HIGH, 
051        /**
052         * Indicates the issue may result in noticeable adverse consequences but is unlikely to be life-threatening or cause permanent injury.
053         */
054        MODERATE, 
055        /**
056         * Indicates the issue may result in some adverse consequences but is unlikely to substantially affect the situation of the subject.
057         */
058        LOW, 
059        /**
060         * added to help the parsers
061         */
062        NULL;
063        public static DetectedIssueSeverity fromCode(String codeString) throws FHIRException {
064            if (codeString == null || "".equals(codeString))
065                return null;
066        if ("high".equals(codeString))
067          return HIGH;
068        if ("moderate".equals(codeString))
069          return MODERATE;
070        if ("low".equals(codeString))
071          return LOW;
072        throw new FHIRException("Unknown DetectedIssueSeverity code '"+codeString+"'");
073        }
074        public String toCode() {
075          switch (this) {
076            case HIGH: return "high";
077            case MODERATE: return "moderate";
078            case LOW: return "low";
079            default: return "?";
080          }
081        }
082        public String getSystem() {
083          switch (this) {
084            case HIGH: return "http://hl7.org/fhir/detectedissue-severity";
085            case MODERATE: return "http://hl7.org/fhir/detectedissue-severity";
086            case LOW: return "http://hl7.org/fhir/detectedissue-severity";
087            default: return "?";
088          }
089        }
090        public String getDefinition() {
091          switch (this) {
092            case HIGH: return "Indicates the issue may be life-threatening or has the potential to cause permanent injury.";
093            case MODERATE: return "Indicates the issue may result in noticeable adverse consequences but is unlikely to be life-threatening or cause permanent injury.";
094            case LOW: return "Indicates the issue may result in some adverse consequences but is unlikely to substantially affect the situation of the subject.";
095            default: return "?";
096          }
097        }
098        public String getDisplay() {
099          switch (this) {
100            case HIGH: return "High";
101            case MODERATE: return "Moderate";
102            case LOW: return "Low";
103            default: return "?";
104          }
105        }
106    }
107
108  public static class DetectedIssueSeverityEnumFactory implements EnumFactory<DetectedIssueSeverity> {
109    public DetectedIssueSeverity fromCode(String codeString) throws IllegalArgumentException {
110      if (codeString == null || "".equals(codeString))
111            if (codeString == null || "".equals(codeString))
112                return null;
113        if ("high".equals(codeString))
114          return DetectedIssueSeverity.HIGH;
115        if ("moderate".equals(codeString))
116          return DetectedIssueSeverity.MODERATE;
117        if ("low".equals(codeString))
118          return DetectedIssueSeverity.LOW;
119        throw new IllegalArgumentException("Unknown DetectedIssueSeverity code '"+codeString+"'");
120        }
121        public Enumeration<DetectedIssueSeverity> fromType(Base code) throws FHIRException {
122          if (code == null || code.isEmpty())
123            return null;
124          String codeString = ((PrimitiveType) code).asStringValue();
125          if (codeString == null || "".equals(codeString))
126            return null;
127        if ("high".equals(codeString))
128          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.HIGH);
129        if ("moderate".equals(codeString))
130          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.MODERATE);
131        if ("low".equals(codeString))
132          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.LOW);
133        throw new FHIRException("Unknown DetectedIssueSeverity code '"+codeString+"'");
134        }
135    public String toCode(DetectedIssueSeverity code) {
136      if (code == DetectedIssueSeverity.HIGH)
137        return "high";
138      if (code == DetectedIssueSeverity.MODERATE)
139        return "moderate";
140      if (code == DetectedIssueSeverity.LOW)
141        return "low";
142      return "?";
143      }
144    }
145
146    @Block()
147    public static class DetectedIssueMitigationComponent extends BackboneElement implements IBaseBackboneElement {
148        /**
149         * Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.
150         */
151        @Child(name = "action", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
152        @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." )
153        protected CodeableConcept action;
154
155        /**
156         * Indicates when the mitigating action was documented.
157         */
158        @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
159        @Description(shortDefinition="Date committed", formalDefinition="Indicates when the mitigating action was documented." )
160        protected DateTimeType date;
161
162        /**
163         * Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.
164         */
165        @Child(name = "author", type = {Practitioner.class}, order=3, min=0, max=1, modifier=false, summary=false)
166        @Description(shortDefinition="Who is committing?", formalDefinition="Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring." )
167        protected Reference author;
168
169        /**
170         * The actual object that is the target of the reference (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
171         */
172        protected Practitioner authorTarget;
173
174        private static final long serialVersionUID = -1994768436L;
175
176    /*
177     * Constructor
178     */
179      public DetectedIssueMitigationComponent() {
180        super();
181      }
182
183    /*
184     * Constructor
185     */
186      public DetectedIssueMitigationComponent(CodeableConcept action) {
187        super();
188        this.action = action;
189      }
190
191        /**
192         * @return {@link #action} (Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.)
193         */
194        public CodeableConcept getAction() { 
195          if (this.action == null)
196            if (Configuration.errorOnAutoCreate())
197              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.action");
198            else if (Configuration.doAutoCreate())
199              this.action = new CodeableConcept(); // cc
200          return this.action;
201        }
202
203        public boolean hasAction() { 
204          return this.action != null && !this.action.isEmpty();
205        }
206
207        /**
208         * @param value {@link #action} (Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.)
209         */
210        public DetectedIssueMitigationComponent setAction(CodeableConcept value) { 
211          this.action = value;
212          return this;
213        }
214
215        /**
216         * @return {@link #date} (Indicates when the mitigating action was documented.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
217         */
218        public DateTimeType getDateElement() { 
219          if (this.date == null)
220            if (Configuration.errorOnAutoCreate())
221              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.date");
222            else if (Configuration.doAutoCreate())
223              this.date = new DateTimeType(); // bb
224          return this.date;
225        }
226
227        public boolean hasDateElement() { 
228          return this.date != null && !this.date.isEmpty();
229        }
230
231        public boolean hasDate() { 
232          return this.date != null && !this.date.isEmpty();
233        }
234
235        /**
236         * @param value {@link #date} (Indicates when the mitigating action was documented.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
237         */
238        public DetectedIssueMitigationComponent setDateElement(DateTimeType value) { 
239          this.date = value;
240          return this;
241        }
242
243        /**
244         * @return Indicates when the mitigating action was documented.
245         */
246        public Date getDate() { 
247          return this.date == null ? null : this.date.getValue();
248        }
249
250        /**
251         * @param value Indicates when the mitigating action was documented.
252         */
253        public DetectedIssueMitigationComponent setDate(Date value) { 
254          if (value == null)
255            this.date = null;
256          else {
257            if (this.date == null)
258              this.date = new DateTimeType();
259            this.date.setValue(value);
260          }
261          return this;
262        }
263
264        /**
265         * @return {@link #author} (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
266         */
267        public Reference getAuthor() { 
268          if (this.author == null)
269            if (Configuration.errorOnAutoCreate())
270              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.author");
271            else if (Configuration.doAutoCreate())
272              this.author = new Reference(); // cc
273          return this.author;
274        }
275
276        public boolean hasAuthor() { 
277          return this.author != null && !this.author.isEmpty();
278        }
279
280        /**
281         * @param value {@link #author} (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
282         */
283        public DetectedIssueMitigationComponent setAuthor(Reference value) { 
284          this.author = value;
285          return this;
286        }
287
288        /**
289         * @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
290         */
291        public Practitioner getAuthorTarget() { 
292          if (this.authorTarget == null)
293            if (Configuration.errorOnAutoCreate())
294              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.author");
295            else if (Configuration.doAutoCreate())
296              this.authorTarget = new Practitioner(); // aa
297          return this.authorTarget;
298        }
299
300        /**
301         * @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
302         */
303        public DetectedIssueMitigationComponent setAuthorTarget(Practitioner value) { 
304          this.authorTarget = value;
305          return this;
306        }
307
308        protected void listChildren(List<Property> childrenList) {
309          super.listChildren(childrenList);
310          childrenList.add(new Property("action", "CodeableConcept", "Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.", 0, java.lang.Integer.MAX_VALUE, action));
311          childrenList.add(new Property("date", "dateTime", "Indicates when the mitigating action was documented.", 0, java.lang.Integer.MAX_VALUE, date));
312          childrenList.add(new Property("author", "Reference(Practitioner)", "Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.", 0, java.lang.Integer.MAX_VALUE, author));
313        }
314
315      @Override
316      public void setProperty(String name, Base value) throws FHIRException {
317        if (name.equals("action"))
318          this.action = castToCodeableConcept(value); // CodeableConcept
319        else if (name.equals("date"))
320          this.date = castToDateTime(value); // DateTimeType
321        else if (name.equals("author"))
322          this.author = castToReference(value); // Reference
323        else
324          super.setProperty(name, value);
325      }
326
327      @Override
328      public Base addChild(String name) throws FHIRException {
329        if (name.equals("action")) {
330          this.action = new CodeableConcept();
331          return this.action;
332        }
333        else if (name.equals("date")) {
334          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.date");
335        }
336        else if (name.equals("author")) {
337          this.author = new Reference();
338          return this.author;
339        }
340        else
341          return super.addChild(name);
342      }
343
344      public DetectedIssueMitigationComponent copy() {
345        DetectedIssueMitigationComponent dst = new DetectedIssueMitigationComponent();
346        copyValues(dst);
347        dst.action = action == null ? null : action.copy();
348        dst.date = date == null ? null : date.copy();
349        dst.author = author == null ? null : author.copy();
350        return dst;
351      }
352
353      @Override
354      public boolean equalsDeep(Base other) {
355        if (!super.equalsDeep(other))
356          return false;
357        if (!(other instanceof DetectedIssueMitigationComponent))
358          return false;
359        DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other;
360        return compareDeep(action, o.action, true) && compareDeep(date, o.date, true) && compareDeep(author, o.author, true)
361          ;
362      }
363
364      @Override
365      public boolean equalsShallow(Base other) {
366        if (!super.equalsShallow(other))
367          return false;
368        if (!(other instanceof DetectedIssueMitigationComponent))
369          return false;
370        DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other;
371        return compareValues(date, o.date, true);
372      }
373
374      public boolean isEmpty() {
375        return super.isEmpty() && (action == null || action.isEmpty()) && (date == null || date.isEmpty())
376           && (author == null || author.isEmpty());
377      }
378
379  public String fhirType() {
380    return "DetectedIssue.mitigation";
381
382  }
383
384  }
385
386    /**
387     * Indicates the patient whose record the detected issue is associated with.
388     */
389    @Child(name = "patient", type = {Patient.class}, order=0, min=0, max=1, modifier=false, summary=true)
390    @Description(shortDefinition="Associated patient", formalDefinition="Indicates the patient whose record the detected issue is associated with." )
391    protected Reference patient;
392
393    /**
394     * The actual object that is the target of the reference (Indicates the patient whose record the detected issue is associated with.)
395     */
396    protected Patient patientTarget;
397
398    /**
399     * Identifies the general type of issue identified.
400     */
401    @Child(name = "category", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
402    @Description(shortDefinition="Issue Category, e.g. drug-drug, duplicate therapy, etc.", formalDefinition="Identifies the general type of issue identified." )
403    protected CodeableConcept category;
404
405    /**
406     * Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
407     */
408    @Child(name = "severity", type = {CodeType.class}, order=2, min=0, max=1, modifier=false, summary=true)
409    @Description(shortDefinition="high | moderate | low", formalDefinition="Indicates the degree of importance associated with the identified issue based on the potential impact on the patient." )
410    protected Enumeration<DetectedIssueSeverity> severity;
411
412    /**
413     * Indicates the resource representing the current activity or proposed activity that is potentially problematic.
414     */
415    @Child(name = "implicated", type = {}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
416    @Description(shortDefinition="Problem resource", formalDefinition="Indicates the resource representing the current activity or proposed activity that is potentially problematic." )
417    protected List<Reference> implicated;
418    /**
419     * The actual objects that are the target of the reference (Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
420     */
421    protected List<Resource> implicatedTarget;
422
423
424    /**
425     * A textual explanation of the detected issue.
426     */
427    @Child(name = "detail", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=false)
428    @Description(shortDefinition="Description and context", formalDefinition="A textual explanation of the detected issue." )
429    protected StringType detail;
430
431    /**
432     * The date or date-time when the detected issue was initially identified.
433     */
434    @Child(name = "date", type = {DateTimeType.class}, order=5, min=0, max=1, modifier=false, summary=true)
435    @Description(shortDefinition="When identified", formalDefinition="The date or date-time when the detected issue was initially identified." )
436    protected DateTimeType date;
437
438    /**
439     * Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.
440     */
441    @Child(name = "author", type = {Practitioner.class, Device.class}, order=6, min=0, max=1, modifier=false, summary=true)
442    @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." )
443    protected Reference author;
444
445    /**
446     * The actual object that is the target of the reference (Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.)
447     */
448    protected Resource authorTarget;
449
450    /**
451     * Business identifier associated with the detected issue record.
452     */
453    @Child(name = "identifier", type = {Identifier.class}, order=7, min=0, max=1, modifier=false, summary=true)
454    @Description(shortDefinition="Unique id for the detected issue", formalDefinition="Business identifier associated with the detected issue record." )
455    protected Identifier identifier;
456
457    /**
458     * The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
459     */
460    @Child(name = "reference", type = {UriType.class}, order=8, min=0, max=1, modifier=false, summary=false)
461    @Description(shortDefinition="Authority for issue", formalDefinition="The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified." )
462    protected UriType reference;
463
464    /**
465     * 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.
466     */
467    @Child(name = "mitigation", type = {}, order=9, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
468    @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." )
469    protected List<DetectedIssueMitigationComponent> mitigation;
470
471    private static final long serialVersionUID = -403732234L;
472
473  /*
474   * Constructor
475   */
476    public DetectedIssue() {
477      super();
478    }
479
480    /**
481     * @return {@link #patient} (Indicates the patient whose record the detected issue is associated with.)
482     */
483    public Reference getPatient() { 
484      if (this.patient == null)
485        if (Configuration.errorOnAutoCreate())
486          throw new Error("Attempt to auto-create DetectedIssue.patient");
487        else if (Configuration.doAutoCreate())
488          this.patient = new Reference(); // cc
489      return this.patient;
490    }
491
492    public boolean hasPatient() { 
493      return this.patient != null && !this.patient.isEmpty();
494    }
495
496    /**
497     * @param value {@link #patient} (Indicates the patient whose record the detected issue is associated with.)
498     */
499    public DetectedIssue setPatient(Reference value) { 
500      this.patient = value;
501      return this;
502    }
503
504    /**
505     * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Indicates the patient whose record the detected issue is associated with.)
506     */
507    public Patient getPatientTarget() { 
508      if (this.patientTarget == null)
509        if (Configuration.errorOnAutoCreate())
510          throw new Error("Attempt to auto-create DetectedIssue.patient");
511        else if (Configuration.doAutoCreate())
512          this.patientTarget = new Patient(); // aa
513      return this.patientTarget;
514    }
515
516    /**
517     * @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Indicates the patient whose record the detected issue is associated with.)
518     */
519    public DetectedIssue setPatientTarget(Patient value) { 
520      this.patientTarget = value;
521      return this;
522    }
523
524    /**
525     * @return {@link #category} (Identifies the general type of issue identified.)
526     */
527    public CodeableConcept getCategory() { 
528      if (this.category == null)
529        if (Configuration.errorOnAutoCreate())
530          throw new Error("Attempt to auto-create DetectedIssue.category");
531        else if (Configuration.doAutoCreate())
532          this.category = new CodeableConcept(); // cc
533      return this.category;
534    }
535
536    public boolean hasCategory() { 
537      return this.category != null && !this.category.isEmpty();
538    }
539
540    /**
541     * @param value {@link #category} (Identifies the general type of issue identified.)
542     */
543    public DetectedIssue setCategory(CodeableConcept value) { 
544      this.category = value;
545      return this;
546    }
547
548    /**
549     * @return {@link #severity} (Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.). This is the underlying object with id, value and extensions. The accessor "getSeverity" gives direct access to the value
550     */
551    public Enumeration<DetectedIssueSeverity> getSeverityElement() { 
552      if (this.severity == null)
553        if (Configuration.errorOnAutoCreate())
554          throw new Error("Attempt to auto-create DetectedIssue.severity");
555        else if (Configuration.doAutoCreate())
556          this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory()); // bb
557      return this.severity;
558    }
559
560    public boolean hasSeverityElement() { 
561      return this.severity != null && !this.severity.isEmpty();
562    }
563
564    public boolean hasSeverity() { 
565      return this.severity != null && !this.severity.isEmpty();
566    }
567
568    /**
569     * @param value {@link #severity} (Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.). This is the underlying object with id, value and extensions. The accessor "getSeverity" gives direct access to the value
570     */
571    public DetectedIssue setSeverityElement(Enumeration<DetectedIssueSeverity> value) { 
572      this.severity = value;
573      return this;
574    }
575
576    /**
577     * @return Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
578     */
579    public DetectedIssueSeverity getSeverity() { 
580      return this.severity == null ? null : this.severity.getValue();
581    }
582
583    /**
584     * @param value Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
585     */
586    public DetectedIssue setSeverity(DetectedIssueSeverity value) { 
587      if (value == null)
588        this.severity = null;
589      else {
590        if (this.severity == null)
591          this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory());
592        this.severity.setValue(value);
593      }
594      return this;
595    }
596
597    /**
598     * @return {@link #implicated} (Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
599     */
600    public List<Reference> getImplicated() { 
601      if (this.implicated == null)
602        this.implicated = new ArrayList<Reference>();
603      return this.implicated;
604    }
605
606    public boolean hasImplicated() { 
607      if (this.implicated == null)
608        return false;
609      for (Reference item : this.implicated)
610        if (!item.isEmpty())
611          return true;
612      return false;
613    }
614
615    /**
616     * @return {@link #implicated} (Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
617     */
618    // syntactic sugar
619    public Reference addImplicated() { //3
620      Reference t = new Reference();
621      if (this.implicated == null)
622        this.implicated = new ArrayList<Reference>();
623      this.implicated.add(t);
624      return t;
625    }
626
627    // syntactic sugar
628    public DetectedIssue addImplicated(Reference t) { //3
629      if (t == null)
630        return this;
631      if (this.implicated == null)
632        this.implicated = new ArrayList<Reference>();
633      this.implicated.add(t);
634      return this;
635    }
636
637    /**
638     * @return {@link #implicated} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
639     */
640    public List<Resource> getImplicatedTarget() { 
641      if (this.implicatedTarget == null)
642        this.implicatedTarget = new ArrayList<Resource>();
643      return this.implicatedTarget;
644    }
645
646    /**
647     * @return {@link #detail} (A textual explanation of the detected issue.). This is the underlying object with id, value and extensions. The accessor "getDetail" gives direct access to the value
648     */
649    public StringType getDetailElement() { 
650      if (this.detail == null)
651        if (Configuration.errorOnAutoCreate())
652          throw new Error("Attempt to auto-create DetectedIssue.detail");
653        else if (Configuration.doAutoCreate())
654          this.detail = new StringType(); // bb
655      return this.detail;
656    }
657
658    public boolean hasDetailElement() { 
659      return this.detail != null && !this.detail.isEmpty();
660    }
661
662    public boolean hasDetail() { 
663      return this.detail != null && !this.detail.isEmpty();
664    }
665
666    /**
667     * @param value {@link #detail} (A textual explanation of the detected issue.). This is the underlying object with id, value and extensions. The accessor "getDetail" gives direct access to the value
668     */
669    public DetectedIssue setDetailElement(StringType value) { 
670      this.detail = value;
671      return this;
672    }
673
674    /**
675     * @return A textual explanation of the detected issue.
676     */
677    public String getDetail() { 
678      return this.detail == null ? null : this.detail.getValue();
679    }
680
681    /**
682     * @param value A textual explanation of the detected issue.
683     */
684    public DetectedIssue setDetail(String value) { 
685      if (Utilities.noString(value))
686        this.detail = null;
687      else {
688        if (this.detail == null)
689          this.detail = new StringType();
690        this.detail.setValue(value);
691      }
692      return this;
693    }
694
695    /**
696     * @return {@link #date} (The date or date-time when the detected issue was initially identified.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
697     */
698    public DateTimeType getDateElement() { 
699      if (this.date == null)
700        if (Configuration.errorOnAutoCreate())
701          throw new Error("Attempt to auto-create DetectedIssue.date");
702        else if (Configuration.doAutoCreate())
703          this.date = new DateTimeType(); // bb
704      return this.date;
705    }
706
707    public boolean hasDateElement() { 
708      return this.date != null && !this.date.isEmpty();
709    }
710
711    public boolean hasDate() { 
712      return this.date != null && !this.date.isEmpty();
713    }
714
715    /**
716     * @param value {@link #date} (The date or date-time when the detected issue was initially identified.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
717     */
718    public DetectedIssue setDateElement(DateTimeType value) { 
719      this.date = value;
720      return this;
721    }
722
723    /**
724     * @return The date or date-time when the detected issue was initially identified.
725     */
726    public Date getDate() { 
727      return this.date == null ? null : this.date.getValue();
728    }
729
730    /**
731     * @param value The date or date-time when the detected issue was initially identified.
732     */
733    public DetectedIssue setDate(Date value) { 
734      if (value == null)
735        this.date = null;
736      else {
737        if (this.date == null)
738          this.date = new DateTimeType();
739        this.date.setValue(value);
740      }
741      return this;
742    }
743
744    /**
745     * @return {@link #author} (Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.)
746     */
747    public Reference getAuthor() { 
748      if (this.author == null)
749        if (Configuration.errorOnAutoCreate())
750          throw new Error("Attempt to auto-create DetectedIssue.author");
751        else if (Configuration.doAutoCreate())
752          this.author = new Reference(); // cc
753      return this.author;
754    }
755
756    public boolean hasAuthor() { 
757      return this.author != null && !this.author.isEmpty();
758    }
759
760    /**
761     * @param value {@link #author} (Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.)
762     */
763    public DetectedIssue setAuthor(Reference value) { 
764      this.author = value;
765      return this;
766    }
767
768    /**
769     * @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.)
770     */
771    public Resource getAuthorTarget() { 
772      return this.authorTarget;
773    }
774
775    /**
776     * @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.)
777     */
778    public DetectedIssue setAuthorTarget(Resource value) { 
779      this.authorTarget = value;
780      return this;
781    }
782
783    /**
784     * @return {@link #identifier} (Business identifier associated with the detected issue record.)
785     */
786    public Identifier getIdentifier() { 
787      if (this.identifier == null)
788        if (Configuration.errorOnAutoCreate())
789          throw new Error("Attempt to auto-create DetectedIssue.identifier");
790        else if (Configuration.doAutoCreate())
791          this.identifier = new Identifier(); // cc
792      return this.identifier;
793    }
794
795    public boolean hasIdentifier() { 
796      return this.identifier != null && !this.identifier.isEmpty();
797    }
798
799    /**
800     * @param value {@link #identifier} (Business identifier associated with the detected issue record.)
801     */
802    public DetectedIssue setIdentifier(Identifier value) { 
803      this.identifier = value;
804      return this;
805    }
806
807    /**
808     * @return {@link #reference} (The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value
809     */
810    public UriType getReferenceElement() { 
811      if (this.reference == null)
812        if (Configuration.errorOnAutoCreate())
813          throw new Error("Attempt to auto-create DetectedIssue.reference");
814        else if (Configuration.doAutoCreate())
815          this.reference = new UriType(); // bb
816      return this.reference;
817    }
818
819    public boolean hasReferenceElement() { 
820      return this.reference != null && !this.reference.isEmpty();
821    }
822
823    public boolean hasReference() { 
824      return this.reference != null && !this.reference.isEmpty();
825    }
826
827    /**
828     * @param value {@link #reference} (The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.). This is the underlying object with id, value and extensions. The accessor "getReference" gives direct access to the value
829     */
830    public DetectedIssue setReferenceElement(UriType value) { 
831      this.reference = value;
832      return this;
833    }
834
835    /**
836     * @return The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
837     */
838    public String getReference() { 
839      return this.reference == null ? null : this.reference.getValue();
840    }
841
842    /**
843     * @param value The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
844     */
845    public DetectedIssue setReference(String value) { 
846      if (Utilities.noString(value))
847        this.reference = null;
848      else {
849        if (this.reference == null)
850          this.reference = new UriType();
851        this.reference.setValue(value);
852      }
853      return this;
854    }
855
856    /**
857     * @return {@link #mitigation} (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.)
858     */
859    public List<DetectedIssueMitigationComponent> getMitigation() { 
860      if (this.mitigation == null)
861        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
862      return this.mitigation;
863    }
864
865    public boolean hasMitigation() { 
866      if (this.mitigation == null)
867        return false;
868      for (DetectedIssueMitigationComponent item : this.mitigation)
869        if (!item.isEmpty())
870          return true;
871      return false;
872    }
873
874    /**
875     * @return {@link #mitigation} (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.)
876     */
877    // syntactic sugar
878    public DetectedIssueMitigationComponent addMitigation() { //3
879      DetectedIssueMitigationComponent t = new DetectedIssueMitigationComponent();
880      if (this.mitigation == null)
881        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
882      this.mitigation.add(t);
883      return t;
884    }
885
886    // syntactic sugar
887    public DetectedIssue addMitigation(DetectedIssueMitigationComponent t) { //3
888      if (t == null)
889        return this;
890      if (this.mitigation == null)
891        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
892      this.mitigation.add(t);
893      return this;
894    }
895
896      protected void listChildren(List<Property> childrenList) {
897        super.listChildren(childrenList);
898        childrenList.add(new Property("patient", "Reference(Patient)", "Indicates the patient whose record the detected issue is associated with.", 0, java.lang.Integer.MAX_VALUE, patient));
899        childrenList.add(new Property("category", "CodeableConcept", "Identifies the general type of issue identified.", 0, java.lang.Integer.MAX_VALUE, category));
900        childrenList.add(new Property("severity", "code", "Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.", 0, java.lang.Integer.MAX_VALUE, severity));
901        childrenList.add(new Property("implicated", "Reference(Any)", "Indicates the resource representing the current activity or proposed activity that is potentially problematic.", 0, java.lang.Integer.MAX_VALUE, implicated));
902        childrenList.add(new Property("detail", "string", "A textual explanation of the detected issue.", 0, java.lang.Integer.MAX_VALUE, detail));
903        childrenList.add(new Property("date", "dateTime", "The date or date-time when the detected issue was initially identified.", 0, java.lang.Integer.MAX_VALUE, date));
904        childrenList.add(new Property("author", "Reference(Practitioner|Device)", "Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.", 0, java.lang.Integer.MAX_VALUE, author));
905        childrenList.add(new Property("identifier", "Identifier", "Business identifier associated with the detected issue record.", 0, java.lang.Integer.MAX_VALUE, identifier));
906        childrenList.add(new Property("reference", "uri", "The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.", 0, java.lang.Integer.MAX_VALUE, reference));
907        childrenList.add(new Property("mitigation", "", "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.", 0, java.lang.Integer.MAX_VALUE, mitigation));
908      }
909
910      @Override
911      public void setProperty(String name, Base value) throws FHIRException {
912        if (name.equals("patient"))
913          this.patient = castToReference(value); // Reference
914        else if (name.equals("category"))
915          this.category = castToCodeableConcept(value); // CodeableConcept
916        else if (name.equals("severity"))
917          this.severity = new DetectedIssueSeverityEnumFactory().fromType(value); // Enumeration<DetectedIssueSeverity>
918        else if (name.equals("implicated"))
919          this.getImplicated().add(castToReference(value));
920        else if (name.equals("detail"))
921          this.detail = castToString(value); // StringType
922        else if (name.equals("date"))
923          this.date = castToDateTime(value); // DateTimeType
924        else if (name.equals("author"))
925          this.author = castToReference(value); // Reference
926        else if (name.equals("identifier"))
927          this.identifier = castToIdentifier(value); // Identifier
928        else if (name.equals("reference"))
929          this.reference = castToUri(value); // UriType
930        else if (name.equals("mitigation"))
931          this.getMitigation().add((DetectedIssueMitigationComponent) value);
932        else
933          super.setProperty(name, value);
934      }
935
936      @Override
937      public Base addChild(String name) throws FHIRException {
938        if (name.equals("patient")) {
939          this.patient = new Reference();
940          return this.patient;
941        }
942        else if (name.equals("category")) {
943          this.category = new CodeableConcept();
944          return this.category;
945        }
946        else if (name.equals("severity")) {
947          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.severity");
948        }
949        else if (name.equals("implicated")) {
950          return addImplicated();
951        }
952        else if (name.equals("detail")) {
953          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.detail");
954        }
955        else if (name.equals("date")) {
956          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.date");
957        }
958        else if (name.equals("author")) {
959          this.author = new Reference();
960          return this.author;
961        }
962        else if (name.equals("identifier")) {
963          this.identifier = new Identifier();
964          return this.identifier;
965        }
966        else if (name.equals("reference")) {
967          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.reference");
968        }
969        else if (name.equals("mitigation")) {
970          return addMitigation();
971        }
972        else
973          return super.addChild(name);
974      }
975
976  public String fhirType() {
977    return "DetectedIssue";
978
979  }
980
981      public DetectedIssue copy() {
982        DetectedIssue dst = new DetectedIssue();
983        copyValues(dst);
984        dst.patient = patient == null ? null : patient.copy();
985        dst.category = category == null ? null : category.copy();
986        dst.severity = severity == null ? null : severity.copy();
987        if (implicated != null) {
988          dst.implicated = new ArrayList<Reference>();
989          for (Reference i : implicated)
990            dst.implicated.add(i.copy());
991        };
992        dst.detail = detail == null ? null : detail.copy();
993        dst.date = date == null ? null : date.copy();
994        dst.author = author == null ? null : author.copy();
995        dst.identifier = identifier == null ? null : identifier.copy();
996        dst.reference = reference == null ? null : reference.copy();
997        if (mitigation != null) {
998          dst.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
999          for (DetectedIssueMitigationComponent i : mitigation)
1000            dst.mitigation.add(i.copy());
1001        };
1002        return dst;
1003      }
1004
1005      protected DetectedIssue typedCopy() {
1006        return copy();
1007      }
1008
1009      @Override
1010      public boolean equalsDeep(Base other) {
1011        if (!super.equalsDeep(other))
1012          return false;
1013        if (!(other instanceof DetectedIssue))
1014          return false;
1015        DetectedIssue o = (DetectedIssue) other;
1016        return compareDeep(patient, o.patient, true) && compareDeep(category, o.category, true) && compareDeep(severity, o.severity, true)
1017           && compareDeep(implicated, o.implicated, true) && compareDeep(detail, o.detail, true) && compareDeep(date, o.date, true)
1018           && compareDeep(author, o.author, true) && compareDeep(identifier, o.identifier, true) && compareDeep(reference, o.reference, true)
1019           && compareDeep(mitigation, o.mitigation, true);
1020      }
1021
1022      @Override
1023      public boolean equalsShallow(Base other) {
1024        if (!super.equalsShallow(other))
1025          return false;
1026        if (!(other instanceof DetectedIssue))
1027          return false;
1028        DetectedIssue o = (DetectedIssue) other;
1029        return compareValues(severity, o.severity, true) && compareValues(detail, o.detail, true) && compareValues(date, o.date, true)
1030           && compareValues(reference, o.reference, true);
1031      }
1032
1033      public boolean isEmpty() {
1034        return super.isEmpty() && (patient == null || patient.isEmpty()) && (category == null || category.isEmpty())
1035           && (severity == null || severity.isEmpty()) && (implicated == null || implicated.isEmpty())
1036           && (detail == null || detail.isEmpty()) && (date == null || date.isEmpty()) && (author == null || author.isEmpty())
1037           && (identifier == null || identifier.isEmpty()) && (reference == null || reference.isEmpty())
1038           && (mitigation == null || mitigation.isEmpty());
1039      }
1040
1041  @Override
1042  public ResourceType getResourceType() {
1043    return ResourceType.DetectedIssue;
1044   }
1045
1046  @SearchParamDefinition(name="date", path="DetectedIssue.date", description="When identified", type="date" )
1047  public static final String SP_DATE = "date";
1048  @SearchParamDefinition(name="identifier", path="DetectedIssue.identifier", description="Unique id for the detected issue", type="token" )
1049  public static final String SP_IDENTIFIER = "identifier";
1050  @SearchParamDefinition(name="patient", path="DetectedIssue.patient", description="Associated patient", type="reference" )
1051  public static final String SP_PATIENT = "patient";
1052  @SearchParamDefinition(name="author", path="DetectedIssue.author", description="The provider or device that identified the issue", type="reference" )
1053  public static final String SP_AUTHOR = "author";
1054  @SearchParamDefinition(name="implicated", path="DetectedIssue.implicated", description="Problem resource", type="reference" )
1055  public static final String SP_IMPLICATED = "implicated";
1056  @SearchParamDefinition(name="category", path="DetectedIssue.category", description="Issue Category, e.g. drug-drug, duplicate therapy, etc.", type="token" )
1057  public static final String SP_CATEGORY = "category";
1058
1059}
1060