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