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