001package org.hl7.fhir.r4.model;
002
003
004
005/*
006  Copyright (c) 2011+, HL7, Inc.
007  All rights reserved.
008  
009  Redistribution and use in source and binary forms, with or without modification, 
010  are permitted provided that the following conditions are met:
011  
012   * Redistributions of source code must retain the above copyright notice, this 
013     list of conditions and the following disclaimer.
014   * Redistributions in binary form must reproduce the above copyright notice, 
015     this list of conditions and the following disclaimer in the documentation 
016     and/or other materials provided with the distribution.
017   * Neither the name of HL7 nor the names of its contributors may be used to 
018     endorse or promote products derived from this software without specific 
019     prior written permission.
020  
021  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
022  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
023  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
024  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
025  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
026  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
027  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
028  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
029  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
030  POSSIBILITY OF SUCH DAMAGE.
031  
032*/
033
034
035// Generated on Tue, May 12, 2020 07:26+1000 for FHIR v4.0.1
036
037import java.util.*;
038
039import org.hl7.fhir.utilities.Utilities;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import ca.uhn.fhir.model.api.annotation.Child;
043import ca.uhn.fhir.model.api.annotation.ChildOrder;
044import ca.uhn.fhir.model.api.annotation.Description;
045import ca.uhn.fhir.model.api.annotation.Block;
046import org.hl7.fhir.instance.model.api.*;
047import org.hl7.fhir.exceptions.FHIRException;
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/StructureDefinition/DetectedIssue")
052public class DetectedIssue extends DomainResource {
053
054    public enum DetectedIssueStatus {
055        /**
056         * The existence of the observation is registered, but there is no result yet available.
057         */
058        REGISTERED, 
059        /**
060         * This is an initial or interim observation: data may be incomplete or unverified.
061         */
062        PRELIMINARY, 
063        /**
064         * The observation is complete and there are no further actions needed. Additional information such "released", "signed", etc would be represented using [Provenance](provenance.html) which provides not only the act but also the actors and dates and other related data. These act states would be associated with an observation status of `preliminary` until they are all completed and then a status of `final` would be applied.
065         */
066        FINAL, 
067        /**
068         * Subsequent to being Final, the observation has been modified subsequent.  This includes updates/new information and corrections.
069         */
070        AMENDED, 
071        /**
072         * Subsequent to being Final, the observation has been modified to correct an error in the test result.
073         */
074        CORRECTED, 
075        /**
076         * The observation is unavailable because the measurement was not started or not completed (also sometimes called "aborted").
077         */
078        CANCELLED, 
079        /**
080         * The observation has been withdrawn following previous final release.  This electronic record should never have existed, though it is possible that real-world decisions were based on it. (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).
081         */
082        ENTEREDINERROR, 
083        /**
084         * The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.
085         */
086        UNKNOWN, 
087        /**
088         * added to help the parsers with the generic types
089         */
090        NULL;
091        public static DetectedIssueStatus fromCode(String codeString) throws FHIRException {
092            if (codeString == null || "".equals(codeString))
093                return null;
094        if ("registered".equals(codeString))
095          return REGISTERED;
096        if ("preliminary".equals(codeString))
097          return PRELIMINARY;
098        if ("final".equals(codeString))
099          return FINAL;
100        if ("amended".equals(codeString))
101          return AMENDED;
102        if ("corrected".equals(codeString))
103          return CORRECTED;
104        if ("cancelled".equals(codeString))
105          return CANCELLED;
106        if ("entered-in-error".equals(codeString))
107          return ENTEREDINERROR;
108        if ("unknown".equals(codeString))
109          return UNKNOWN;
110        if (Configuration.isAcceptInvalidEnums())
111          return null;
112        else
113          throw new FHIRException("Unknown DetectedIssueStatus code '"+codeString+"'");
114        }
115        public String toCode() {
116          switch (this) {
117            case REGISTERED: return "registered";
118            case PRELIMINARY: return "preliminary";
119            case FINAL: return "final";
120            case AMENDED: return "amended";
121            case CORRECTED: return "corrected";
122            case CANCELLED: return "cancelled";
123            case ENTEREDINERROR: return "entered-in-error";
124            case UNKNOWN: return "unknown";
125            case NULL: return null;
126            default: return "?";
127          }
128        }
129        public String getSystem() {
130          switch (this) {
131            case REGISTERED: return "http://hl7.org/fhir/observation-status";
132            case PRELIMINARY: return "http://hl7.org/fhir/observation-status";
133            case FINAL: return "http://hl7.org/fhir/observation-status";
134            case AMENDED: return "http://hl7.org/fhir/observation-status";
135            case CORRECTED: return "http://hl7.org/fhir/observation-status";
136            case CANCELLED: return "http://hl7.org/fhir/observation-status";
137            case ENTEREDINERROR: return "http://hl7.org/fhir/observation-status";
138            case UNKNOWN: return "http://hl7.org/fhir/observation-status";
139            case NULL: return null;
140            default: return "?";
141          }
142        }
143        public String getDefinition() {
144          switch (this) {
145            case REGISTERED: return "The existence of the observation is registered, but there is no result yet available.";
146            case PRELIMINARY: return "This is an initial or interim observation: data may be incomplete or unverified.";
147            case FINAL: return "The observation is complete and there are no further actions needed. Additional information such \"released\", \"signed\", etc would be represented using [Provenance](provenance.html) which provides not only the act but also the actors and dates and other related data. These act states would be associated with an observation status of `preliminary` until they are all completed and then a status of `final` would be applied.";
148            case AMENDED: return "Subsequent to being Final, the observation has been modified subsequent.  This includes updates/new information and corrections.";
149            case CORRECTED: return "Subsequent to being Final, the observation has been modified to correct an error in the test result.";
150            case CANCELLED: return "The observation is unavailable because the measurement was not started or not completed (also sometimes called \"aborted\").";
151            case ENTEREDINERROR: return "The observation has been withdrawn following previous final release.  This electronic record should never have existed, though it is possible that real-world decisions were based on it. (If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".).";
152            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.";
153            case NULL: return null;
154            default: return "?";
155          }
156        }
157        public String getDisplay() {
158          switch (this) {
159            case REGISTERED: return "Registered";
160            case PRELIMINARY: return "Preliminary";
161            case FINAL: return "Final";
162            case AMENDED: return "Amended";
163            case CORRECTED: return "Corrected";
164            case CANCELLED: return "Cancelled";
165            case ENTEREDINERROR: return "Entered in Error";
166            case UNKNOWN: return "Unknown";
167            case NULL: return null;
168            default: return "?";
169          }
170        }
171    }
172
173  public static class DetectedIssueStatusEnumFactory implements EnumFactory<DetectedIssueStatus> {
174    public DetectedIssueStatus fromCode(String codeString) throws IllegalArgumentException {
175      if (codeString == null || "".equals(codeString))
176            if (codeString == null || "".equals(codeString))
177                return null;
178        if ("registered".equals(codeString))
179          return DetectedIssueStatus.REGISTERED;
180        if ("preliminary".equals(codeString))
181          return DetectedIssueStatus.PRELIMINARY;
182        if ("final".equals(codeString))
183          return DetectedIssueStatus.FINAL;
184        if ("amended".equals(codeString))
185          return DetectedIssueStatus.AMENDED;
186        if ("corrected".equals(codeString))
187          return DetectedIssueStatus.CORRECTED;
188        if ("cancelled".equals(codeString))
189          return DetectedIssueStatus.CANCELLED;
190        if ("entered-in-error".equals(codeString))
191          return DetectedIssueStatus.ENTEREDINERROR;
192        if ("unknown".equals(codeString))
193          return DetectedIssueStatus.UNKNOWN;
194        throw new IllegalArgumentException("Unknown DetectedIssueStatus code '"+codeString+"'");
195        }
196        public Enumeration<DetectedIssueStatus> fromType(Base code) throws FHIRException {
197          if (code == null)
198            return null;
199          if (code.isEmpty())
200            return new Enumeration<DetectedIssueStatus>(this);
201          String codeString = ((PrimitiveType) code).asStringValue();
202          if (codeString == null || "".equals(codeString))
203            return null;
204        if ("registered".equals(codeString))
205          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.REGISTERED);
206        if ("preliminary".equals(codeString))
207          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.PRELIMINARY);
208        if ("final".equals(codeString))
209          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.FINAL);
210        if ("amended".equals(codeString))
211          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.AMENDED);
212        if ("corrected".equals(codeString))
213          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.CORRECTED);
214        if ("cancelled".equals(codeString))
215          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.CANCELLED);
216        if ("entered-in-error".equals(codeString))
217          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.ENTEREDINERROR);
218        if ("unknown".equals(codeString))
219          return new Enumeration<DetectedIssueStatus>(this, DetectedIssueStatus.UNKNOWN);
220        throw new FHIRException("Unknown DetectedIssueStatus code '"+codeString+"'");
221        }
222    public String toCode(DetectedIssueStatus code) {
223      if (code == DetectedIssueStatus.REGISTERED)
224        return "registered";
225      if (code == DetectedIssueStatus.PRELIMINARY)
226        return "preliminary";
227      if (code == DetectedIssueStatus.FINAL)
228        return "final";
229      if (code == DetectedIssueStatus.AMENDED)
230        return "amended";
231      if (code == DetectedIssueStatus.CORRECTED)
232        return "corrected";
233      if (code == DetectedIssueStatus.CANCELLED)
234        return "cancelled";
235      if (code == DetectedIssueStatus.ENTEREDINERROR)
236        return "entered-in-error";
237      if (code == DetectedIssueStatus.UNKNOWN)
238        return "unknown";
239      return "?";
240      }
241    public String toSystem(DetectedIssueStatus code) {
242      return code.getSystem();
243      }
244    }
245
246    public enum DetectedIssueSeverity {
247        /**
248         * Indicates the issue may be life-threatening or has the potential to cause permanent injury.
249         */
250        HIGH, 
251        /**
252         * Indicates the issue may result in noticeable adverse consequences but is unlikely to be life-threatening or cause permanent injury.
253         */
254        MODERATE, 
255        /**
256         * Indicates the issue may result in some adverse consequences but is unlikely to substantially affect the situation of the subject.
257         */
258        LOW, 
259        /**
260         * added to help the parsers with the generic types
261         */
262        NULL;
263        public static DetectedIssueSeverity fromCode(String codeString) throws FHIRException {
264            if (codeString == null || "".equals(codeString))
265                return null;
266        if ("high".equals(codeString))
267          return HIGH;
268        if ("moderate".equals(codeString))
269          return MODERATE;
270        if ("low".equals(codeString))
271          return LOW;
272        if (Configuration.isAcceptInvalidEnums())
273          return null;
274        else
275          throw new FHIRException("Unknown DetectedIssueSeverity code '"+codeString+"'");
276        }
277        public String toCode() {
278          switch (this) {
279            case HIGH: return "high";
280            case MODERATE: return "moderate";
281            case LOW: return "low";
282            case NULL: return null;
283            default: return "?";
284          }
285        }
286        public String getSystem() {
287          switch (this) {
288            case HIGH: return "http://hl7.org/fhir/detectedissue-severity";
289            case MODERATE: return "http://hl7.org/fhir/detectedissue-severity";
290            case LOW: return "http://hl7.org/fhir/detectedissue-severity";
291            case NULL: return null;
292            default: return "?";
293          }
294        }
295        public String getDefinition() {
296          switch (this) {
297            case HIGH: return "Indicates the issue may be life-threatening or has the potential to cause permanent injury.";
298            case MODERATE: return "Indicates the issue may result in noticeable adverse consequences but is unlikely to be life-threatening or cause permanent injury.";
299            case LOW: return "Indicates the issue may result in some adverse consequences but is unlikely to substantially affect the situation of the subject.";
300            case NULL: return null;
301            default: return "?";
302          }
303        }
304        public String getDisplay() {
305          switch (this) {
306            case HIGH: return "High";
307            case MODERATE: return "Moderate";
308            case LOW: return "Low";
309            case NULL: return null;
310            default: return "?";
311          }
312        }
313    }
314
315  public static class DetectedIssueSeverityEnumFactory implements EnumFactory<DetectedIssueSeverity> {
316    public DetectedIssueSeverity fromCode(String codeString) throws IllegalArgumentException {
317      if (codeString == null || "".equals(codeString))
318            if (codeString == null || "".equals(codeString))
319                return null;
320        if ("high".equals(codeString))
321          return DetectedIssueSeverity.HIGH;
322        if ("moderate".equals(codeString))
323          return DetectedIssueSeverity.MODERATE;
324        if ("low".equals(codeString))
325          return DetectedIssueSeverity.LOW;
326        throw new IllegalArgumentException("Unknown DetectedIssueSeverity code '"+codeString+"'");
327        }
328        public Enumeration<DetectedIssueSeverity> fromType(Base code) throws FHIRException {
329          if (code == null)
330            return null;
331          if (code.isEmpty())
332            return new Enumeration<DetectedIssueSeverity>(this);
333          String codeString = ((PrimitiveType) code).asStringValue();
334          if (codeString == null || "".equals(codeString))
335            return null;
336        if ("high".equals(codeString))
337          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.HIGH);
338        if ("moderate".equals(codeString))
339          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.MODERATE);
340        if ("low".equals(codeString))
341          return new Enumeration<DetectedIssueSeverity>(this, DetectedIssueSeverity.LOW);
342        throw new FHIRException("Unknown DetectedIssueSeverity code '"+codeString+"'");
343        }
344    public String toCode(DetectedIssueSeverity code) {
345      if (code == DetectedIssueSeverity.HIGH)
346        return "high";
347      if (code == DetectedIssueSeverity.MODERATE)
348        return "moderate";
349      if (code == DetectedIssueSeverity.LOW)
350        return "low";
351      return "?";
352      }
353    public String toSystem(DetectedIssueSeverity code) {
354      return code.getSystem();
355      }
356    }
357
358    @Block()
359    public static class DetectedIssueEvidenceComponent extends BackboneElement implements IBaseBackboneElement {
360        /**
361         * A manifestation that led to the recording of this detected issue.
362         */
363        @Child(name = "code", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
364        @Description(shortDefinition="Manifestation", formalDefinition="A manifestation that led to the recording of this detected issue." )
365        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/manifestation-or-symptom")
366        protected List<CodeableConcept> code;
367
368        /**
369         * Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport.
370         */
371        @Child(name = "detail", type = {Reference.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
372        @Description(shortDefinition="Supporting information", formalDefinition="Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport." )
373        protected List<Reference> detail;
374        /**
375         * The actual objects that are the target of the reference (Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport.)
376         */
377        protected List<Resource> detailTarget;
378
379
380        private static final long serialVersionUID = 1135831276L;
381
382    /**
383     * Constructor
384     */
385      public DetectedIssueEvidenceComponent() {
386        super();
387      }
388
389        /**
390         * @return {@link #code} (A manifestation that led to the recording of this detected issue.)
391         */
392        public List<CodeableConcept> getCode() { 
393          if (this.code == null)
394            this.code = new ArrayList<CodeableConcept>();
395          return this.code;
396        }
397
398        /**
399         * @return Returns a reference to <code>this</code> for easy method chaining
400         */
401        public DetectedIssueEvidenceComponent setCode(List<CodeableConcept> theCode) { 
402          this.code = theCode;
403          return this;
404        }
405
406        public boolean hasCode() { 
407          if (this.code == null)
408            return false;
409          for (CodeableConcept item : this.code)
410            if (!item.isEmpty())
411              return true;
412          return false;
413        }
414
415        public CodeableConcept addCode() { //3
416          CodeableConcept t = new CodeableConcept();
417          if (this.code == null)
418            this.code = new ArrayList<CodeableConcept>();
419          this.code.add(t);
420          return t;
421        }
422
423        public DetectedIssueEvidenceComponent addCode(CodeableConcept t) { //3
424          if (t == null)
425            return this;
426          if (this.code == null)
427            this.code = new ArrayList<CodeableConcept>();
428          this.code.add(t);
429          return this;
430        }
431
432        /**
433         * @return The first repetition of repeating field {@link #code}, creating it if it does not already exist
434         */
435        public CodeableConcept getCodeFirstRep() { 
436          if (getCode().isEmpty()) {
437            addCode();
438          }
439          return getCode().get(0);
440        }
441
442        /**
443         * @return {@link #detail} (Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport.)
444         */
445        public List<Reference> getDetail() { 
446          if (this.detail == null)
447            this.detail = new ArrayList<Reference>();
448          return this.detail;
449        }
450
451        /**
452         * @return Returns a reference to <code>this</code> for easy method chaining
453         */
454        public DetectedIssueEvidenceComponent setDetail(List<Reference> theDetail) { 
455          this.detail = theDetail;
456          return this;
457        }
458
459        public boolean hasDetail() { 
460          if (this.detail == null)
461            return false;
462          for (Reference item : this.detail)
463            if (!item.isEmpty())
464              return true;
465          return false;
466        }
467
468        public Reference addDetail() { //3
469          Reference t = new Reference();
470          if (this.detail == null)
471            this.detail = new ArrayList<Reference>();
472          this.detail.add(t);
473          return t;
474        }
475
476        public DetectedIssueEvidenceComponent addDetail(Reference t) { //3
477          if (t == null)
478            return this;
479          if (this.detail == null)
480            this.detail = new ArrayList<Reference>();
481          this.detail.add(t);
482          return this;
483        }
484
485        /**
486         * @return The first repetition of repeating field {@link #detail}, creating it if it does not already exist
487         */
488        public Reference getDetailFirstRep() { 
489          if (getDetail().isEmpty()) {
490            addDetail();
491          }
492          return getDetail().get(0);
493        }
494
495        /**
496         * @deprecated Use Reference#setResource(IBaseResource) instead
497         */
498        @Deprecated
499        public List<Resource> getDetailTarget() { 
500          if (this.detailTarget == null)
501            this.detailTarget = new ArrayList<Resource>();
502          return this.detailTarget;
503        }
504
505        protected void listChildren(List<Property> children) {
506          super.listChildren(children);
507          children.add(new Property("code", "CodeableConcept", "A manifestation that led to the recording of this detected issue.", 0, java.lang.Integer.MAX_VALUE, code));
508          children.add(new Property("detail", "Reference(Any)", "Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport.", 0, java.lang.Integer.MAX_VALUE, detail));
509        }
510
511        @Override
512        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
513          switch (_hash) {
514          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "A manifestation that led to the recording of this detected issue.", 0, java.lang.Integer.MAX_VALUE, code);
515          case -1335224239: /*detail*/  return new Property("detail", "Reference(Any)", "Links to resources that constitute evidence for the detected issue such as a GuidanceResponse or MeasureReport.", 0, java.lang.Integer.MAX_VALUE, detail);
516          default: return super.getNamedProperty(_hash, _name, _checkValid);
517          }
518
519        }
520
521      @Override
522      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
523        switch (hash) {
524        case 3059181: /*code*/ return this.code == null ? new Base[0] : this.code.toArray(new Base[this.code.size()]); // CodeableConcept
525        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : this.detail.toArray(new Base[this.detail.size()]); // Reference
526        default: return super.getProperty(hash, name, checkValid);
527        }
528
529      }
530
531      @Override
532      public Base setProperty(int hash, String name, Base value) throws FHIRException {
533        switch (hash) {
534        case 3059181: // code
535          this.getCode().add(castToCodeableConcept(value)); // CodeableConcept
536          return value;
537        case -1335224239: // detail
538          this.getDetail().add(castToReference(value)); // Reference
539          return value;
540        default: return super.setProperty(hash, name, value);
541        }
542
543      }
544
545      @Override
546      public Base setProperty(String name, Base value) throws FHIRException {
547        if (name.equals("code")) {
548          this.getCode().add(castToCodeableConcept(value));
549        } else if (name.equals("detail")) {
550          this.getDetail().add(castToReference(value));
551        } else
552          return super.setProperty(name, value);
553        return value;
554      }
555
556      @Override
557      public Base makeProperty(int hash, String name) throws FHIRException {
558        switch (hash) {
559        case 3059181:  return addCode(); 
560        case -1335224239:  return addDetail(); 
561        default: return super.makeProperty(hash, name);
562        }
563
564      }
565
566      @Override
567      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
568        switch (hash) {
569        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
570        case -1335224239: /*detail*/ return new String[] {"Reference"};
571        default: return super.getTypesForProperty(hash, name);
572        }
573
574      }
575
576      @Override
577      public Base addChild(String name) throws FHIRException {
578        if (name.equals("code")) {
579          return addCode();
580        }
581        else if (name.equals("detail")) {
582          return addDetail();
583        }
584        else
585          return super.addChild(name);
586      }
587
588      public DetectedIssueEvidenceComponent copy() {
589        DetectedIssueEvidenceComponent dst = new DetectedIssueEvidenceComponent();
590        copyValues(dst);
591        return dst;
592      }
593
594      public void copyValues(DetectedIssueEvidenceComponent dst) {
595        super.copyValues(dst);
596        if (code != null) {
597          dst.code = new ArrayList<CodeableConcept>();
598          for (CodeableConcept i : code)
599            dst.code.add(i.copy());
600        };
601        if (detail != null) {
602          dst.detail = new ArrayList<Reference>();
603          for (Reference i : detail)
604            dst.detail.add(i.copy());
605        };
606      }
607
608      @Override
609      public boolean equalsDeep(Base other_) {
610        if (!super.equalsDeep(other_))
611          return false;
612        if (!(other_ instanceof DetectedIssueEvidenceComponent))
613          return false;
614        DetectedIssueEvidenceComponent o = (DetectedIssueEvidenceComponent) other_;
615        return compareDeep(code, o.code, true) && compareDeep(detail, o.detail, true);
616      }
617
618      @Override
619      public boolean equalsShallow(Base other_) {
620        if (!super.equalsShallow(other_))
621          return false;
622        if (!(other_ instanceof DetectedIssueEvidenceComponent))
623          return false;
624        DetectedIssueEvidenceComponent o = (DetectedIssueEvidenceComponent) other_;
625        return true;
626      }
627
628      public boolean isEmpty() {
629        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(code, detail);
630      }
631
632  public String fhirType() {
633    return "DetectedIssue.evidence";
634
635  }
636
637  }
638
639    @Block()
640    public static class DetectedIssueMitigationComponent extends BackboneElement implements IBaseBackboneElement {
641        /**
642         * Describes the action that was taken or the observation that was made that reduces/eliminates the risk associated with the identified issue.
643         */
644        @Child(name = "action", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
645        @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." )
646        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/detectedissue-mitigation-action")
647        protected CodeableConcept action;
648
649        /**
650         * Indicates when the mitigating action was documented.
651         */
652        @Child(name = "date", type = {DateTimeType.class}, order=2, min=0, max=1, modifier=false, summary=false)
653        @Description(shortDefinition="Date committed", formalDefinition="Indicates when the mitigating action was documented." )
654        protected DateTimeType date;
655
656        /**
657         * Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.
658         */
659        @Child(name = "author", type = {Practitioner.class, PractitionerRole.class}, order=3, min=0, max=1, modifier=false, summary=false)
660        @Description(shortDefinition="Who is committing?", formalDefinition="Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring." )
661        protected Reference author;
662
663        /**
664         * 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.)
665         */
666        protected Resource authorTarget;
667
668        private static final long serialVersionUID = -1928864832L;
669
670    /**
671     * Constructor
672     */
673      public DetectedIssueMitigationComponent() {
674        super();
675      }
676
677    /**
678     * Constructor
679     */
680      public DetectedIssueMitigationComponent(CodeableConcept action) {
681        super();
682        this.action = action;
683      }
684
685        /**
686         * @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.)
687         */
688        public CodeableConcept getAction() { 
689          if (this.action == null)
690            if (Configuration.errorOnAutoCreate())
691              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.action");
692            else if (Configuration.doAutoCreate())
693              this.action = new CodeableConcept(); // cc
694          return this.action;
695        }
696
697        public boolean hasAction() { 
698          return this.action != null && !this.action.isEmpty();
699        }
700
701        /**
702         * @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.)
703         */
704        public DetectedIssueMitigationComponent setAction(CodeableConcept value) { 
705          this.action = value;
706          return this;
707        }
708
709        /**
710         * @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
711         */
712        public DateTimeType getDateElement() { 
713          if (this.date == null)
714            if (Configuration.errorOnAutoCreate())
715              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.date");
716            else if (Configuration.doAutoCreate())
717              this.date = new DateTimeType(); // bb
718          return this.date;
719        }
720
721        public boolean hasDateElement() { 
722          return this.date != null && !this.date.isEmpty();
723        }
724
725        public boolean hasDate() { 
726          return this.date != null && !this.date.isEmpty();
727        }
728
729        /**
730         * @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
731         */
732        public DetectedIssueMitigationComponent setDateElement(DateTimeType value) { 
733          this.date = value;
734          return this;
735        }
736
737        /**
738         * @return Indicates when the mitigating action was documented.
739         */
740        public Date getDate() { 
741          return this.date == null ? null : this.date.getValue();
742        }
743
744        /**
745         * @param value Indicates when the mitigating action was documented.
746         */
747        public DetectedIssueMitigationComponent setDate(Date value) { 
748          if (value == null)
749            this.date = null;
750          else {
751            if (this.date == null)
752              this.date = new DateTimeType();
753            this.date.setValue(value);
754          }
755          return this;
756        }
757
758        /**
759         * @return {@link #author} (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
760         */
761        public Reference getAuthor() { 
762          if (this.author == null)
763            if (Configuration.errorOnAutoCreate())
764              throw new Error("Attempt to auto-create DetectedIssueMitigationComponent.author");
765            else if (Configuration.doAutoCreate())
766              this.author = new Reference(); // cc
767          return this.author;
768        }
769
770        public boolean hasAuthor() { 
771          return this.author != null && !this.author.isEmpty();
772        }
773
774        /**
775         * @param value {@link #author} (Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.)
776         */
777        public DetectedIssueMitigationComponent setAuthor(Reference value) { 
778          this.author = value;
779          return this;
780        }
781
782        /**
783         * @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.)
784         */
785        public Resource getAuthorTarget() { 
786          return this.authorTarget;
787        }
788
789        /**
790         * @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.)
791         */
792        public DetectedIssueMitigationComponent setAuthorTarget(Resource value) { 
793          this.authorTarget = value;
794          return this;
795        }
796
797        protected void listChildren(List<Property> children) {
798          super.listChildren(children);
799          children.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, 1, action));
800          children.add(new Property("date", "dateTime", "Indicates when the mitigating action was documented.", 0, 1, date));
801          children.add(new Property("author", "Reference(Practitioner|PractitionerRole)", "Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.", 0, 1, author));
802        }
803
804        @Override
805        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
806          switch (_hash) {
807          case -1422950858: /*action*/  return 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, 1, action);
808          case 3076014: /*date*/  return new Property("date", "dateTime", "Indicates when the mitigating action was documented.", 0, 1, date);
809          case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole)", "Identifies the practitioner who determined the mitigation and takes responsibility for the mitigation step occurring.", 0, 1, author);
810          default: return super.getNamedProperty(_hash, _name, _checkValid);
811          }
812
813        }
814
815      @Override
816      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
817        switch (hash) {
818        case -1422950858: /*action*/ return this.action == null ? new Base[0] : new Base[] {this.action}; // CodeableConcept
819        case 3076014: /*date*/ return this.date == null ? new Base[0] : new Base[] {this.date}; // DateTimeType
820        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
821        default: return super.getProperty(hash, name, checkValid);
822        }
823
824      }
825
826      @Override
827      public Base setProperty(int hash, String name, Base value) throws FHIRException {
828        switch (hash) {
829        case -1422950858: // action
830          this.action = castToCodeableConcept(value); // CodeableConcept
831          return value;
832        case 3076014: // date
833          this.date = castToDateTime(value); // DateTimeType
834          return value;
835        case -1406328437: // author
836          this.author = castToReference(value); // Reference
837          return value;
838        default: return super.setProperty(hash, name, value);
839        }
840
841      }
842
843      @Override
844      public Base setProperty(String name, Base value) throws FHIRException {
845        if (name.equals("action")) {
846          this.action = castToCodeableConcept(value); // CodeableConcept
847        } else if (name.equals("date")) {
848          this.date = castToDateTime(value); // DateTimeType
849        } else if (name.equals("author")) {
850          this.author = castToReference(value); // Reference
851        } else
852          return super.setProperty(name, value);
853        return value;
854      }
855
856      @Override
857      public Base makeProperty(int hash, String name) throws FHIRException {
858        switch (hash) {
859        case -1422950858:  return getAction(); 
860        case 3076014:  return getDateElement();
861        case -1406328437:  return getAuthor(); 
862        default: return super.makeProperty(hash, name);
863        }
864
865      }
866
867      @Override
868      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
869        switch (hash) {
870        case -1422950858: /*action*/ return new String[] {"CodeableConcept"};
871        case 3076014: /*date*/ return new String[] {"dateTime"};
872        case -1406328437: /*author*/ return new String[] {"Reference"};
873        default: return super.getTypesForProperty(hash, name);
874        }
875
876      }
877
878      @Override
879      public Base addChild(String name) throws FHIRException {
880        if (name.equals("action")) {
881          this.action = new CodeableConcept();
882          return this.action;
883        }
884        else if (name.equals("date")) {
885          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.date");
886        }
887        else if (name.equals("author")) {
888          this.author = new Reference();
889          return this.author;
890        }
891        else
892          return super.addChild(name);
893      }
894
895      public DetectedIssueMitigationComponent copy() {
896        DetectedIssueMitigationComponent dst = new DetectedIssueMitigationComponent();
897        copyValues(dst);
898        return dst;
899      }
900
901      public void copyValues(DetectedIssueMitigationComponent dst) {
902        super.copyValues(dst);
903        dst.action = action == null ? null : action.copy();
904        dst.date = date == null ? null : date.copy();
905        dst.author = author == null ? null : author.copy();
906      }
907
908      @Override
909      public boolean equalsDeep(Base other_) {
910        if (!super.equalsDeep(other_))
911          return false;
912        if (!(other_ instanceof DetectedIssueMitigationComponent))
913          return false;
914        DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other_;
915        return compareDeep(action, o.action, true) && compareDeep(date, o.date, true) && compareDeep(author, o.author, true)
916          ;
917      }
918
919      @Override
920      public boolean equalsShallow(Base other_) {
921        if (!super.equalsShallow(other_))
922          return false;
923        if (!(other_ instanceof DetectedIssueMitigationComponent))
924          return false;
925        DetectedIssueMitigationComponent o = (DetectedIssueMitigationComponent) other_;
926        return compareValues(date, o.date, true);
927      }
928
929      public boolean isEmpty() {
930        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(action, date, author);
931      }
932
933  public String fhirType() {
934    return "DetectedIssue.mitigation";
935
936  }
937
938  }
939
940    /**
941     * Business identifier associated with the detected issue record.
942     */
943    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
944    @Description(shortDefinition="Unique id for the detected issue", formalDefinition="Business identifier associated with the detected issue record." )
945    protected List<Identifier> identifier;
946
947    /**
948     * Indicates the status of the detected issue.
949     */
950    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
951    @Description(shortDefinition="registered | preliminary | final | amended +", formalDefinition="Indicates the status of the detected issue." )
952    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-status")
953    protected Enumeration<DetectedIssueStatus> status;
954
955    /**
956     * Identifies the general type of issue identified.
957     */
958    @Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
959    @Description(shortDefinition="Issue Category, e.g. drug-drug, duplicate therapy, etc.", formalDefinition="Identifies the general type of issue identified." )
960    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/detectedissue-category")
961    protected CodeableConcept code;
962
963    /**
964     * Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
965     */
966    @Child(name = "severity", type = {CodeType.class}, order=3, min=0, max=1, modifier=false, summary=true)
967    @Description(shortDefinition="high | moderate | low", formalDefinition="Indicates the degree of importance associated with the identified issue based on the potential impact on the patient." )
968    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/detectedissue-severity")
969    protected Enumeration<DetectedIssueSeverity> severity;
970
971    /**
972     * Indicates the patient whose record the detected issue is associated with.
973     */
974    @Child(name = "patient", type = {Patient.class}, order=4, min=0, max=1, modifier=false, summary=true)
975    @Description(shortDefinition="Associated patient", formalDefinition="Indicates the patient whose record the detected issue is associated with." )
976    protected Reference patient;
977
978    /**
979     * The actual object that is the target of the reference (Indicates the patient whose record the detected issue is associated with.)
980     */
981    protected Patient patientTarget;
982
983    /**
984     * The date or period when the detected issue was initially identified.
985     */
986    @Child(name = "identified", type = {DateTimeType.class, Period.class}, order=5, min=0, max=1, modifier=false, summary=true)
987    @Description(shortDefinition="When identified", formalDefinition="The date or period when the detected issue was initially identified." )
988    protected Type identified;
989
990    /**
991     * Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.
992     */
993    @Child(name = "author", type = {Practitioner.class, PractitionerRole.class, Device.class}, order=6, min=0, max=1, modifier=false, summary=true)
994    @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." )
995    protected Reference author;
996
997    /**
998     * 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.)
999     */
1000    protected Resource authorTarget;
1001
1002    /**
1003     * Indicates the resource representing the current activity or proposed activity that is potentially problematic.
1004     */
1005    @Child(name = "implicated", type = {Reference.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
1006    @Description(shortDefinition="Problem resource", formalDefinition="Indicates the resource representing the current activity or proposed activity that is potentially problematic." )
1007    protected List<Reference> implicated;
1008    /**
1009     * The actual objects that are the target of the reference (Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
1010     */
1011    protected List<Resource> implicatedTarget;
1012
1013
1014    /**
1015     * Supporting evidence or manifestations that provide the basis for identifying the detected issue such as a GuidanceResponse or MeasureReport.
1016     */
1017    @Child(name = "evidence", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1018    @Description(shortDefinition="Supporting evidence", formalDefinition="Supporting evidence or manifestations that provide the basis for identifying the detected issue such as a GuidanceResponse or MeasureReport." )
1019    protected List<DetectedIssueEvidenceComponent> evidence;
1020
1021    /**
1022     * A textual explanation of the detected issue.
1023     */
1024    @Child(name = "detail", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=false)
1025    @Description(shortDefinition="Description and context", formalDefinition="A textual explanation of the detected issue." )
1026    protected StringType detail;
1027
1028    /**
1029     * The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
1030     */
1031    @Child(name = "reference", type = {UriType.class}, order=10, min=0, max=1, modifier=false, summary=false)
1032    @Description(shortDefinition="Authority for issue", formalDefinition="The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified." )
1033    protected UriType reference;
1034
1035    /**
1036     * Indicates an action that has been taken or is committed 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.
1037     */
1038    @Child(name = "mitigation", type = {}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1039    @Description(shortDefinition="Step taken to address", formalDefinition="Indicates an action that has been taken or is committed 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." )
1040    protected List<DetectedIssueMitigationComponent> mitigation;
1041
1042    private static final long serialVersionUID = 1404426283L;
1043
1044  /**
1045   * Constructor
1046   */
1047    public DetectedIssue() {
1048      super();
1049    }
1050
1051  /**
1052   * Constructor
1053   */
1054    public DetectedIssue(Enumeration<DetectedIssueStatus> status) {
1055      super();
1056      this.status = status;
1057    }
1058
1059    /**
1060     * @return {@link #identifier} (Business identifier associated with the detected issue record.)
1061     */
1062    public List<Identifier> getIdentifier() { 
1063      if (this.identifier == null)
1064        this.identifier = new ArrayList<Identifier>();
1065      return this.identifier;
1066    }
1067
1068    /**
1069     * @return Returns a reference to <code>this</code> for easy method chaining
1070     */
1071    public DetectedIssue setIdentifier(List<Identifier> theIdentifier) { 
1072      this.identifier = theIdentifier;
1073      return this;
1074    }
1075
1076    public boolean hasIdentifier() { 
1077      if (this.identifier == null)
1078        return false;
1079      for (Identifier item : this.identifier)
1080        if (!item.isEmpty())
1081          return true;
1082      return false;
1083    }
1084
1085    public Identifier addIdentifier() { //3
1086      Identifier t = new Identifier();
1087      if (this.identifier == null)
1088        this.identifier = new ArrayList<Identifier>();
1089      this.identifier.add(t);
1090      return t;
1091    }
1092
1093    public DetectedIssue addIdentifier(Identifier t) { //3
1094      if (t == null)
1095        return this;
1096      if (this.identifier == null)
1097        this.identifier = new ArrayList<Identifier>();
1098      this.identifier.add(t);
1099      return this;
1100    }
1101
1102    /**
1103     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
1104     */
1105    public Identifier getIdentifierFirstRep() { 
1106      if (getIdentifier().isEmpty()) {
1107        addIdentifier();
1108      }
1109      return getIdentifier().get(0);
1110    }
1111
1112    /**
1113     * @return {@link #status} (Indicates the status of the detected issue.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1114     */
1115    public Enumeration<DetectedIssueStatus> getStatusElement() { 
1116      if (this.status == null)
1117        if (Configuration.errorOnAutoCreate())
1118          throw new Error("Attempt to auto-create DetectedIssue.status");
1119        else if (Configuration.doAutoCreate())
1120          this.status = new Enumeration<DetectedIssueStatus>(new DetectedIssueStatusEnumFactory()); // bb
1121      return this.status;
1122    }
1123
1124    public boolean hasStatusElement() { 
1125      return this.status != null && !this.status.isEmpty();
1126    }
1127
1128    public boolean hasStatus() { 
1129      return this.status != null && !this.status.isEmpty();
1130    }
1131
1132    /**
1133     * @param value {@link #status} (Indicates the status of the detected issue.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
1134     */
1135    public DetectedIssue setStatusElement(Enumeration<DetectedIssueStatus> value) { 
1136      this.status = value;
1137      return this;
1138    }
1139
1140    /**
1141     * @return Indicates the status of the detected issue.
1142     */
1143    public DetectedIssueStatus getStatus() { 
1144      return this.status == null ? null : this.status.getValue();
1145    }
1146
1147    /**
1148     * @param value Indicates the status of the detected issue.
1149     */
1150    public DetectedIssue setStatus(DetectedIssueStatus value) { 
1151        if (this.status == null)
1152          this.status = new Enumeration<DetectedIssueStatus>(new DetectedIssueStatusEnumFactory());
1153        this.status.setValue(value);
1154      return this;
1155    }
1156
1157    /**
1158     * @return {@link #code} (Identifies the general type of issue identified.)
1159     */
1160    public CodeableConcept getCode() { 
1161      if (this.code == null)
1162        if (Configuration.errorOnAutoCreate())
1163          throw new Error("Attempt to auto-create DetectedIssue.code");
1164        else if (Configuration.doAutoCreate())
1165          this.code = new CodeableConcept(); // cc
1166      return this.code;
1167    }
1168
1169    public boolean hasCode() { 
1170      return this.code != null && !this.code.isEmpty();
1171    }
1172
1173    /**
1174     * @param value {@link #code} (Identifies the general type of issue identified.)
1175     */
1176    public DetectedIssue setCode(CodeableConcept value) { 
1177      this.code = value;
1178      return this;
1179    }
1180
1181    /**
1182     * @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
1183     */
1184    public Enumeration<DetectedIssueSeverity> getSeverityElement() { 
1185      if (this.severity == null)
1186        if (Configuration.errorOnAutoCreate())
1187          throw new Error("Attempt to auto-create DetectedIssue.severity");
1188        else if (Configuration.doAutoCreate())
1189          this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory()); // bb
1190      return this.severity;
1191    }
1192
1193    public boolean hasSeverityElement() { 
1194      return this.severity != null && !this.severity.isEmpty();
1195    }
1196
1197    public boolean hasSeverity() { 
1198      return this.severity != null && !this.severity.isEmpty();
1199    }
1200
1201    /**
1202     * @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
1203     */
1204    public DetectedIssue setSeverityElement(Enumeration<DetectedIssueSeverity> value) { 
1205      this.severity = value;
1206      return this;
1207    }
1208
1209    /**
1210     * @return Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
1211     */
1212    public DetectedIssueSeverity getSeverity() { 
1213      return this.severity == null ? null : this.severity.getValue();
1214    }
1215
1216    /**
1217     * @param value Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.
1218     */
1219    public DetectedIssue setSeverity(DetectedIssueSeverity value) { 
1220      if (value == null)
1221        this.severity = null;
1222      else {
1223        if (this.severity == null)
1224          this.severity = new Enumeration<DetectedIssueSeverity>(new DetectedIssueSeverityEnumFactory());
1225        this.severity.setValue(value);
1226      }
1227      return this;
1228    }
1229
1230    /**
1231     * @return {@link #patient} (Indicates the patient whose record the detected issue is associated with.)
1232     */
1233    public Reference getPatient() { 
1234      if (this.patient == null)
1235        if (Configuration.errorOnAutoCreate())
1236          throw new Error("Attempt to auto-create DetectedIssue.patient");
1237        else if (Configuration.doAutoCreate())
1238          this.patient = new Reference(); // cc
1239      return this.patient;
1240    }
1241
1242    public boolean hasPatient() { 
1243      return this.patient != null && !this.patient.isEmpty();
1244    }
1245
1246    /**
1247     * @param value {@link #patient} (Indicates the patient whose record the detected issue is associated with.)
1248     */
1249    public DetectedIssue setPatient(Reference value) { 
1250      this.patient = value;
1251      return this;
1252    }
1253
1254    /**
1255     * @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.)
1256     */
1257    public Patient getPatientTarget() { 
1258      if (this.patientTarget == null)
1259        if (Configuration.errorOnAutoCreate())
1260          throw new Error("Attempt to auto-create DetectedIssue.patient");
1261        else if (Configuration.doAutoCreate())
1262          this.patientTarget = new Patient(); // aa
1263      return this.patientTarget;
1264    }
1265
1266    /**
1267     * @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.)
1268     */
1269    public DetectedIssue setPatientTarget(Patient value) { 
1270      this.patientTarget = value;
1271      return this;
1272    }
1273
1274    /**
1275     * @return {@link #identified} (The date or period when the detected issue was initially identified.)
1276     */
1277    public Type getIdentified() { 
1278      return this.identified;
1279    }
1280
1281    /**
1282     * @return {@link #identified} (The date or period when the detected issue was initially identified.)
1283     */
1284    public DateTimeType getIdentifiedDateTimeType() throws FHIRException { 
1285      if (this.identified == null)
1286        this.identified = new DateTimeType();
1287      if (!(this.identified instanceof DateTimeType))
1288        throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "+this.identified.getClass().getName()+" was encountered");
1289      return (DateTimeType) this.identified;
1290    }
1291
1292    public boolean hasIdentifiedDateTimeType() { 
1293      return this != null && this.identified instanceof DateTimeType;
1294    }
1295
1296    /**
1297     * @return {@link #identified} (The date or period when the detected issue was initially identified.)
1298     */
1299    public Period getIdentifiedPeriod() throws FHIRException { 
1300      if (this.identified == null)
1301        this.identified = new Period();
1302      if (!(this.identified instanceof Period))
1303        throw new FHIRException("Type mismatch: the type Period was expected, but "+this.identified.getClass().getName()+" was encountered");
1304      return (Period) this.identified;
1305    }
1306
1307    public boolean hasIdentifiedPeriod() { 
1308      return this != null && this.identified instanceof Period;
1309    }
1310
1311    public boolean hasIdentified() { 
1312      return this.identified != null && !this.identified.isEmpty();
1313    }
1314
1315    /**
1316     * @param value {@link #identified} (The date or period when the detected issue was initially identified.)
1317     */
1318    public DetectedIssue setIdentified(Type value) { 
1319      if (value != null && !(value instanceof DateTimeType || value instanceof Period))
1320        throw new Error("Not the right type for DetectedIssue.identified[x]: "+value.fhirType());
1321      this.identified = value;
1322      return this;
1323    }
1324
1325    /**
1326     * @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.)
1327     */
1328    public Reference getAuthor() { 
1329      if (this.author == null)
1330        if (Configuration.errorOnAutoCreate())
1331          throw new Error("Attempt to auto-create DetectedIssue.author");
1332        else if (Configuration.doAutoCreate())
1333          this.author = new Reference(); // cc
1334      return this.author;
1335    }
1336
1337    public boolean hasAuthor() { 
1338      return this.author != null && !this.author.isEmpty();
1339    }
1340
1341    /**
1342     * @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.)
1343     */
1344    public DetectedIssue setAuthor(Reference value) { 
1345      this.author = value;
1346      return this;
1347    }
1348
1349    /**
1350     * @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.)
1351     */
1352    public Resource getAuthorTarget() { 
1353      return this.authorTarget;
1354    }
1355
1356    /**
1357     * @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.)
1358     */
1359    public DetectedIssue setAuthorTarget(Resource value) { 
1360      this.authorTarget = value;
1361      return this;
1362    }
1363
1364    /**
1365     * @return {@link #implicated} (Indicates the resource representing the current activity or proposed activity that is potentially problematic.)
1366     */
1367    public List<Reference> getImplicated() { 
1368      if (this.implicated == null)
1369        this.implicated = new ArrayList<Reference>();
1370      return this.implicated;
1371    }
1372
1373    /**
1374     * @return Returns a reference to <code>this</code> for easy method chaining
1375     */
1376    public DetectedIssue setImplicated(List<Reference> theImplicated) { 
1377      this.implicated = theImplicated;
1378      return this;
1379    }
1380
1381    public boolean hasImplicated() { 
1382      if (this.implicated == null)
1383        return false;
1384      for (Reference item : this.implicated)
1385        if (!item.isEmpty())
1386          return true;
1387      return false;
1388    }
1389
1390    public Reference addImplicated() { //3
1391      Reference t = new Reference();
1392      if (this.implicated == null)
1393        this.implicated = new ArrayList<Reference>();
1394      this.implicated.add(t);
1395      return t;
1396    }
1397
1398    public DetectedIssue addImplicated(Reference t) { //3
1399      if (t == null)
1400        return this;
1401      if (this.implicated == null)
1402        this.implicated = new ArrayList<Reference>();
1403      this.implicated.add(t);
1404      return this;
1405    }
1406
1407    /**
1408     * @return The first repetition of repeating field {@link #implicated}, creating it if it does not already exist
1409     */
1410    public Reference getImplicatedFirstRep() { 
1411      if (getImplicated().isEmpty()) {
1412        addImplicated();
1413      }
1414      return getImplicated().get(0);
1415    }
1416
1417    /**
1418     * @deprecated Use Reference#setResource(IBaseResource) instead
1419     */
1420    @Deprecated
1421    public List<Resource> getImplicatedTarget() { 
1422      if (this.implicatedTarget == null)
1423        this.implicatedTarget = new ArrayList<Resource>();
1424      return this.implicatedTarget;
1425    }
1426
1427    /**
1428     * @return {@link #evidence} (Supporting evidence or manifestations that provide the basis for identifying the detected issue such as a GuidanceResponse or MeasureReport.)
1429     */
1430    public List<DetectedIssueEvidenceComponent> getEvidence() { 
1431      if (this.evidence == null)
1432        this.evidence = new ArrayList<DetectedIssueEvidenceComponent>();
1433      return this.evidence;
1434    }
1435
1436    /**
1437     * @return Returns a reference to <code>this</code> for easy method chaining
1438     */
1439    public DetectedIssue setEvidence(List<DetectedIssueEvidenceComponent> theEvidence) { 
1440      this.evidence = theEvidence;
1441      return this;
1442    }
1443
1444    public boolean hasEvidence() { 
1445      if (this.evidence == null)
1446        return false;
1447      for (DetectedIssueEvidenceComponent item : this.evidence)
1448        if (!item.isEmpty())
1449          return true;
1450      return false;
1451    }
1452
1453    public DetectedIssueEvidenceComponent addEvidence() { //3
1454      DetectedIssueEvidenceComponent t = new DetectedIssueEvidenceComponent();
1455      if (this.evidence == null)
1456        this.evidence = new ArrayList<DetectedIssueEvidenceComponent>();
1457      this.evidence.add(t);
1458      return t;
1459    }
1460
1461    public DetectedIssue addEvidence(DetectedIssueEvidenceComponent t) { //3
1462      if (t == null)
1463        return this;
1464      if (this.evidence == null)
1465        this.evidence = new ArrayList<DetectedIssueEvidenceComponent>();
1466      this.evidence.add(t);
1467      return this;
1468    }
1469
1470    /**
1471     * @return The first repetition of repeating field {@link #evidence}, creating it if it does not already exist
1472     */
1473    public DetectedIssueEvidenceComponent getEvidenceFirstRep() { 
1474      if (getEvidence().isEmpty()) {
1475        addEvidence();
1476      }
1477      return getEvidence().get(0);
1478    }
1479
1480    /**
1481     * @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
1482     */
1483    public StringType getDetailElement() { 
1484      if (this.detail == null)
1485        if (Configuration.errorOnAutoCreate())
1486          throw new Error("Attempt to auto-create DetectedIssue.detail");
1487        else if (Configuration.doAutoCreate())
1488          this.detail = new StringType(); // bb
1489      return this.detail;
1490    }
1491
1492    public boolean hasDetailElement() { 
1493      return this.detail != null && !this.detail.isEmpty();
1494    }
1495
1496    public boolean hasDetail() { 
1497      return this.detail != null && !this.detail.isEmpty();
1498    }
1499
1500    /**
1501     * @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
1502     */
1503    public DetectedIssue setDetailElement(StringType value) { 
1504      this.detail = value;
1505      return this;
1506    }
1507
1508    /**
1509     * @return A textual explanation of the detected issue.
1510     */
1511    public String getDetail() { 
1512      return this.detail == null ? null : this.detail.getValue();
1513    }
1514
1515    /**
1516     * @param value A textual explanation of the detected issue.
1517     */
1518    public DetectedIssue setDetail(String value) { 
1519      if (Utilities.noString(value))
1520        this.detail = null;
1521      else {
1522        if (this.detail == null)
1523          this.detail = new StringType();
1524        this.detail.setValue(value);
1525      }
1526      return this;
1527    }
1528
1529    /**
1530     * @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
1531     */
1532    public UriType getReferenceElement() { 
1533      if (this.reference == null)
1534        if (Configuration.errorOnAutoCreate())
1535          throw new Error("Attempt to auto-create DetectedIssue.reference");
1536        else if (Configuration.doAutoCreate())
1537          this.reference = new UriType(); // bb
1538      return this.reference;
1539    }
1540
1541    public boolean hasReferenceElement() { 
1542      return this.reference != null && !this.reference.isEmpty();
1543    }
1544
1545    public boolean hasReference() { 
1546      return this.reference != null && !this.reference.isEmpty();
1547    }
1548
1549    /**
1550     * @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
1551     */
1552    public DetectedIssue setReferenceElement(UriType value) { 
1553      this.reference = value;
1554      return this;
1555    }
1556
1557    /**
1558     * @return The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
1559     */
1560    public String getReference() { 
1561      return this.reference == null ? null : this.reference.getValue();
1562    }
1563
1564    /**
1565     * @param value The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.
1566     */
1567    public DetectedIssue setReference(String value) { 
1568      if (Utilities.noString(value))
1569        this.reference = null;
1570      else {
1571        if (this.reference == null)
1572          this.reference = new UriType();
1573        this.reference.setValue(value);
1574      }
1575      return this;
1576    }
1577
1578    /**
1579     * @return {@link #mitigation} (Indicates an action that has been taken or is committed 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.)
1580     */
1581    public List<DetectedIssueMitigationComponent> getMitigation() { 
1582      if (this.mitigation == null)
1583        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1584      return this.mitigation;
1585    }
1586
1587    /**
1588     * @return Returns a reference to <code>this</code> for easy method chaining
1589     */
1590    public DetectedIssue setMitigation(List<DetectedIssueMitigationComponent> theMitigation) { 
1591      this.mitigation = theMitigation;
1592      return this;
1593    }
1594
1595    public boolean hasMitigation() { 
1596      if (this.mitigation == null)
1597        return false;
1598      for (DetectedIssueMitigationComponent item : this.mitigation)
1599        if (!item.isEmpty())
1600          return true;
1601      return false;
1602    }
1603
1604    public DetectedIssueMitigationComponent addMitigation() { //3
1605      DetectedIssueMitigationComponent t = new DetectedIssueMitigationComponent();
1606      if (this.mitigation == null)
1607        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1608      this.mitigation.add(t);
1609      return t;
1610    }
1611
1612    public DetectedIssue addMitigation(DetectedIssueMitigationComponent t) { //3
1613      if (t == null)
1614        return this;
1615      if (this.mitigation == null)
1616        this.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1617      this.mitigation.add(t);
1618      return this;
1619    }
1620
1621    /**
1622     * @return The first repetition of repeating field {@link #mitigation}, creating it if it does not already exist
1623     */
1624    public DetectedIssueMitigationComponent getMitigationFirstRep() { 
1625      if (getMitigation().isEmpty()) {
1626        addMitigation();
1627      }
1628      return getMitigation().get(0);
1629    }
1630
1631      protected void listChildren(List<Property> children) {
1632        super.listChildren(children);
1633        children.add(new Property("identifier", "Identifier", "Business identifier associated with the detected issue record.", 0, java.lang.Integer.MAX_VALUE, identifier));
1634        children.add(new Property("status", "code", "Indicates the status of the detected issue.", 0, 1, status));
1635        children.add(new Property("code", "CodeableConcept", "Identifies the general type of issue identified.", 0, 1, code));
1636        children.add(new Property("severity", "code", "Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.", 0, 1, severity));
1637        children.add(new Property("patient", "Reference(Patient)", "Indicates the patient whose record the detected issue is associated with.", 0, 1, patient));
1638        children.add(new Property("identified[x]", "dateTime|Period", "The date or period when the detected issue was initially identified.", 0, 1, identified));
1639        children.add(new Property("author", "Reference(Practitioner|PractitionerRole|Device)", "Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.", 0, 1, author));
1640        children.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));
1641        children.add(new Property("evidence", "", "Supporting evidence or manifestations that provide the basis for identifying the detected issue such as a GuidanceResponse or MeasureReport.", 0, java.lang.Integer.MAX_VALUE, evidence));
1642        children.add(new Property("detail", "string", "A textual explanation of the detected issue.", 0, 1, detail));
1643        children.add(new Property("reference", "uri", "The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.", 0, 1, reference));
1644        children.add(new Property("mitigation", "", "Indicates an action that has been taken or is committed 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));
1645      }
1646
1647      @Override
1648      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1649        switch (_hash) {
1650        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifier associated with the detected issue record.", 0, java.lang.Integer.MAX_VALUE, identifier);
1651        case -892481550: /*status*/  return new Property("status", "code", "Indicates the status of the detected issue.", 0, 1, status);
1652        case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Identifies the general type of issue identified.", 0, 1, code);
1653        case 1478300413: /*severity*/  return new Property("severity", "code", "Indicates the degree of importance associated with the identified issue based on the potential impact on the patient.", 0, 1, severity);
1654        case -791418107: /*patient*/  return new Property("patient", "Reference(Patient)", "Indicates the patient whose record the detected issue is associated with.", 0, 1, patient);
1655        case 569355781: /*identified[x]*/  return new Property("identified[x]", "dateTime|Period", "The date or period when the detected issue was initially identified.", 0, 1, identified);
1656        case -1618432869: /*identified*/  return new Property("identified[x]", "dateTime|Period", "The date or period when the detected issue was initially identified.", 0, 1, identified);
1657        case -968788650: /*identifiedDateTime*/  return new Property("identified[x]", "dateTime|Period", "The date or period when the detected issue was initially identified.", 0, 1, identified);
1658        case 520482364: /*identifiedPeriod*/  return new Property("identified[x]", "dateTime|Period", "The date or period when the detected issue was initially identified.", 0, 1, identified);
1659        case -1406328437: /*author*/  return new Property("author", "Reference(Practitioner|PractitionerRole|Device)", "Individual or device responsible for the issue being raised.  For example, a decision support application or a pharmacist conducting a medication review.", 0, 1, author);
1660        case -810216884: /*implicated*/  return 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);
1661        case 382967383: /*evidence*/  return new Property("evidence", "", "Supporting evidence or manifestations that provide the basis for identifying the detected issue such as a GuidanceResponse or MeasureReport.", 0, java.lang.Integer.MAX_VALUE, evidence);
1662        case -1335224239: /*detail*/  return new Property("detail", "string", "A textual explanation of the detected issue.", 0, 1, detail);
1663        case -925155509: /*reference*/  return new Property("reference", "uri", "The literature, knowledge-base or similar reference that describes the propensity for the detected issue identified.", 0, 1, reference);
1664        case 1293793087: /*mitigation*/  return new Property("mitigation", "", "Indicates an action that has been taken or is committed 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);
1665        default: return super.getNamedProperty(_hash, _name, _checkValid);
1666        }
1667
1668      }
1669
1670      @Override
1671      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1672        switch (hash) {
1673        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1674        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<DetectedIssueStatus>
1675        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
1676        case 1478300413: /*severity*/ return this.severity == null ? new Base[0] : new Base[] {this.severity}; // Enumeration<DetectedIssueSeverity>
1677        case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
1678        case -1618432869: /*identified*/ return this.identified == null ? new Base[0] : new Base[] {this.identified}; // Type
1679        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
1680        case -810216884: /*implicated*/ return this.implicated == null ? new Base[0] : this.implicated.toArray(new Base[this.implicated.size()]); // Reference
1681        case 382967383: /*evidence*/ return this.evidence == null ? new Base[0] : this.evidence.toArray(new Base[this.evidence.size()]); // DetectedIssueEvidenceComponent
1682        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : new Base[] {this.detail}; // StringType
1683        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // UriType
1684        case 1293793087: /*mitigation*/ return this.mitigation == null ? new Base[0] : this.mitigation.toArray(new Base[this.mitigation.size()]); // DetectedIssueMitigationComponent
1685        default: return super.getProperty(hash, name, checkValid);
1686        }
1687
1688      }
1689
1690      @Override
1691      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1692        switch (hash) {
1693        case -1618432855: // identifier
1694          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1695          return value;
1696        case -892481550: // status
1697          value = new DetectedIssueStatusEnumFactory().fromType(castToCode(value));
1698          this.status = (Enumeration) value; // Enumeration<DetectedIssueStatus>
1699          return value;
1700        case 3059181: // code
1701          this.code = castToCodeableConcept(value); // CodeableConcept
1702          return value;
1703        case 1478300413: // severity
1704          value = new DetectedIssueSeverityEnumFactory().fromType(castToCode(value));
1705          this.severity = (Enumeration) value; // Enumeration<DetectedIssueSeverity>
1706          return value;
1707        case -791418107: // patient
1708          this.patient = castToReference(value); // Reference
1709          return value;
1710        case -1618432869: // identified
1711          this.identified = castToType(value); // Type
1712          return value;
1713        case -1406328437: // author
1714          this.author = castToReference(value); // Reference
1715          return value;
1716        case -810216884: // implicated
1717          this.getImplicated().add(castToReference(value)); // Reference
1718          return value;
1719        case 382967383: // evidence
1720          this.getEvidence().add((DetectedIssueEvidenceComponent) value); // DetectedIssueEvidenceComponent
1721          return value;
1722        case -1335224239: // detail
1723          this.detail = castToString(value); // StringType
1724          return value;
1725        case -925155509: // reference
1726          this.reference = castToUri(value); // UriType
1727          return value;
1728        case 1293793087: // mitigation
1729          this.getMitigation().add((DetectedIssueMitigationComponent) value); // DetectedIssueMitigationComponent
1730          return value;
1731        default: return super.setProperty(hash, name, value);
1732        }
1733
1734      }
1735
1736      @Override
1737      public Base setProperty(String name, Base value) throws FHIRException {
1738        if (name.equals("identifier")) {
1739          this.getIdentifier().add(castToIdentifier(value));
1740        } else if (name.equals("status")) {
1741          value = new DetectedIssueStatusEnumFactory().fromType(castToCode(value));
1742          this.status = (Enumeration) value; // Enumeration<DetectedIssueStatus>
1743        } else if (name.equals("code")) {
1744          this.code = castToCodeableConcept(value); // CodeableConcept
1745        } else if (name.equals("severity")) {
1746          value = new DetectedIssueSeverityEnumFactory().fromType(castToCode(value));
1747          this.severity = (Enumeration) value; // Enumeration<DetectedIssueSeverity>
1748        } else if (name.equals("patient")) {
1749          this.patient = castToReference(value); // Reference
1750        } else if (name.equals("identified[x]")) {
1751          this.identified = castToType(value); // Type
1752        } else if (name.equals("author")) {
1753          this.author = castToReference(value); // Reference
1754        } else if (name.equals("implicated")) {
1755          this.getImplicated().add(castToReference(value));
1756        } else if (name.equals("evidence")) {
1757          this.getEvidence().add((DetectedIssueEvidenceComponent) value);
1758        } else if (name.equals("detail")) {
1759          this.detail = castToString(value); // StringType
1760        } else if (name.equals("reference")) {
1761          this.reference = castToUri(value); // UriType
1762        } else if (name.equals("mitigation")) {
1763          this.getMitigation().add((DetectedIssueMitigationComponent) value);
1764        } else
1765          return super.setProperty(name, value);
1766        return value;
1767      }
1768
1769      @Override
1770      public Base makeProperty(int hash, String name) throws FHIRException {
1771        switch (hash) {
1772        case -1618432855:  return addIdentifier(); 
1773        case -892481550:  return getStatusElement();
1774        case 3059181:  return getCode(); 
1775        case 1478300413:  return getSeverityElement();
1776        case -791418107:  return getPatient(); 
1777        case 569355781:  return getIdentified(); 
1778        case -1618432869:  return getIdentified(); 
1779        case -1406328437:  return getAuthor(); 
1780        case -810216884:  return addImplicated(); 
1781        case 382967383:  return addEvidence(); 
1782        case -1335224239:  return getDetailElement();
1783        case -925155509:  return getReferenceElement();
1784        case 1293793087:  return addMitigation(); 
1785        default: return super.makeProperty(hash, name);
1786        }
1787
1788      }
1789
1790      @Override
1791      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1792        switch (hash) {
1793        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1794        case -892481550: /*status*/ return new String[] {"code"};
1795        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
1796        case 1478300413: /*severity*/ return new String[] {"code"};
1797        case -791418107: /*patient*/ return new String[] {"Reference"};
1798        case -1618432869: /*identified*/ return new String[] {"dateTime", "Period"};
1799        case -1406328437: /*author*/ return new String[] {"Reference"};
1800        case -810216884: /*implicated*/ return new String[] {"Reference"};
1801        case 382967383: /*evidence*/ return new String[] {};
1802        case -1335224239: /*detail*/ return new String[] {"string"};
1803        case -925155509: /*reference*/ return new String[] {"uri"};
1804        case 1293793087: /*mitigation*/ return new String[] {};
1805        default: return super.getTypesForProperty(hash, name);
1806        }
1807
1808      }
1809
1810      @Override
1811      public Base addChild(String name) throws FHIRException {
1812        if (name.equals("identifier")) {
1813          return addIdentifier();
1814        }
1815        else if (name.equals("status")) {
1816          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.status");
1817        }
1818        else if (name.equals("code")) {
1819          this.code = new CodeableConcept();
1820          return this.code;
1821        }
1822        else if (name.equals("severity")) {
1823          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.severity");
1824        }
1825        else if (name.equals("patient")) {
1826          this.patient = new Reference();
1827          return this.patient;
1828        }
1829        else if (name.equals("identifiedDateTime")) {
1830          this.identified = new DateTimeType();
1831          return this.identified;
1832        }
1833        else if (name.equals("identifiedPeriod")) {
1834          this.identified = new Period();
1835          return this.identified;
1836        }
1837        else if (name.equals("author")) {
1838          this.author = new Reference();
1839          return this.author;
1840        }
1841        else if (name.equals("implicated")) {
1842          return addImplicated();
1843        }
1844        else if (name.equals("evidence")) {
1845          return addEvidence();
1846        }
1847        else if (name.equals("detail")) {
1848          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.detail");
1849        }
1850        else if (name.equals("reference")) {
1851          throw new FHIRException("Cannot call addChild on a primitive type DetectedIssue.reference");
1852        }
1853        else if (name.equals("mitigation")) {
1854          return addMitigation();
1855        }
1856        else
1857          return super.addChild(name);
1858      }
1859
1860  public String fhirType() {
1861    return "DetectedIssue";
1862
1863  }
1864
1865      public DetectedIssue copy() {
1866        DetectedIssue dst = new DetectedIssue();
1867        copyValues(dst);
1868        return dst;
1869      }
1870
1871      public void copyValues(DetectedIssue dst) {
1872        super.copyValues(dst);
1873        if (identifier != null) {
1874          dst.identifier = new ArrayList<Identifier>();
1875          for (Identifier i : identifier)
1876            dst.identifier.add(i.copy());
1877        };
1878        dst.status = status == null ? null : status.copy();
1879        dst.code = code == null ? null : code.copy();
1880        dst.severity = severity == null ? null : severity.copy();
1881        dst.patient = patient == null ? null : patient.copy();
1882        dst.identified = identified == null ? null : identified.copy();
1883        dst.author = author == null ? null : author.copy();
1884        if (implicated != null) {
1885          dst.implicated = new ArrayList<Reference>();
1886          for (Reference i : implicated)
1887            dst.implicated.add(i.copy());
1888        };
1889        if (evidence != null) {
1890          dst.evidence = new ArrayList<DetectedIssueEvidenceComponent>();
1891          for (DetectedIssueEvidenceComponent i : evidence)
1892            dst.evidence.add(i.copy());
1893        };
1894        dst.detail = detail == null ? null : detail.copy();
1895        dst.reference = reference == null ? null : reference.copy();
1896        if (mitigation != null) {
1897          dst.mitigation = new ArrayList<DetectedIssueMitigationComponent>();
1898          for (DetectedIssueMitigationComponent i : mitigation)
1899            dst.mitigation.add(i.copy());
1900        };
1901      }
1902
1903      protected DetectedIssue typedCopy() {
1904        return copy();
1905      }
1906
1907      @Override
1908      public boolean equalsDeep(Base other_) {
1909        if (!super.equalsDeep(other_))
1910          return false;
1911        if (!(other_ instanceof DetectedIssue))
1912          return false;
1913        DetectedIssue o = (DetectedIssue) other_;
1914        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(code, o.code, true)
1915           && compareDeep(severity, o.severity, true) && compareDeep(patient, o.patient, true) && compareDeep(identified, o.identified, true)
1916           && compareDeep(author, o.author, true) && compareDeep(implicated, o.implicated, true) && compareDeep(evidence, o.evidence, true)
1917           && compareDeep(detail, o.detail, true) && compareDeep(reference, o.reference, true) && compareDeep(mitigation, o.mitigation, true)
1918          ;
1919      }
1920
1921      @Override
1922      public boolean equalsShallow(Base other_) {
1923        if (!super.equalsShallow(other_))
1924          return false;
1925        if (!(other_ instanceof DetectedIssue))
1926          return false;
1927        DetectedIssue o = (DetectedIssue) other_;
1928        return compareValues(status, o.status, true) && compareValues(severity, o.severity, true) && compareValues(detail, o.detail, true)
1929           && compareValues(reference, o.reference, true);
1930      }
1931
1932      public boolean isEmpty() {
1933        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, code
1934          , severity, patient, identified, author, implicated, evidence, detail, reference
1935          , mitigation);
1936      }
1937
1938  @Override
1939  public ResourceType getResourceType() {
1940    return ResourceType.DetectedIssue;
1941   }
1942
1943 /**
1944   * Search parameter: <b>identifier</b>
1945   * <p>
1946   * Description: <b>Unique id for the detected issue</b><br>
1947   * Type: <b>token</b><br>
1948   * Path: <b>DetectedIssue.identifier</b><br>
1949   * </p>
1950   */
1951  @SearchParamDefinition(name="identifier", path="DetectedIssue.identifier", description="Unique id for the detected issue", type="token" )
1952  public static final String SP_IDENTIFIER = "identifier";
1953 /**
1954   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1955   * <p>
1956   * Description: <b>Unique id for the detected issue</b><br>
1957   * Type: <b>token</b><br>
1958   * Path: <b>DetectedIssue.identifier</b><br>
1959   * </p>
1960   */
1961  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1962
1963 /**
1964   * Search parameter: <b>code</b>
1965   * <p>
1966   * Description: <b>Issue Category, e.g. drug-drug, duplicate therapy, etc.</b><br>
1967   * Type: <b>token</b><br>
1968   * Path: <b>DetectedIssue.code</b><br>
1969   * </p>
1970   */
1971  @SearchParamDefinition(name="code", path="DetectedIssue.code", description="Issue Category, e.g. drug-drug, duplicate therapy, etc.", type="token" )
1972  public static final String SP_CODE = "code";
1973 /**
1974   * <b>Fluent Client</b> search parameter constant for <b>code</b>
1975   * <p>
1976   * Description: <b>Issue Category, e.g. drug-drug, duplicate therapy, etc.</b><br>
1977   * Type: <b>token</b><br>
1978   * Path: <b>DetectedIssue.code</b><br>
1979   * </p>
1980   */
1981  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
1982
1983 /**
1984   * Search parameter: <b>identified</b>
1985   * <p>
1986   * Description: <b>When identified</b><br>
1987   * Type: <b>date</b><br>
1988   * Path: <b>DetectedIssue.identified[x]</b><br>
1989   * </p>
1990   */
1991  @SearchParamDefinition(name="identified", path="DetectedIssue.identified", description="When identified", type="date" )
1992  public static final String SP_IDENTIFIED = "identified";
1993 /**
1994   * <b>Fluent Client</b> search parameter constant for <b>identified</b>
1995   * <p>
1996   * Description: <b>When identified</b><br>
1997   * Type: <b>date</b><br>
1998   * Path: <b>DetectedIssue.identified[x]</b><br>
1999   * </p>
2000   */
2001  public static final ca.uhn.fhir.rest.gclient.DateClientParam IDENTIFIED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_IDENTIFIED);
2002
2003 /**
2004   * Search parameter: <b>patient</b>
2005   * <p>
2006   * Description: <b>Associated patient</b><br>
2007   * Type: <b>reference</b><br>
2008   * Path: <b>DetectedIssue.patient</b><br>
2009   * </p>
2010   */
2011  @SearchParamDefinition(name="patient", path="DetectedIssue.patient", description="Associated patient", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
2012  public static final String SP_PATIENT = "patient";
2013 /**
2014   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
2015   * <p>
2016   * Description: <b>Associated patient</b><br>
2017   * Type: <b>reference</b><br>
2018   * Path: <b>DetectedIssue.patient</b><br>
2019   * </p>
2020   */
2021  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
2022
2023/**
2024   * Constant for fluent queries to be used to add include statements. Specifies
2025   * the path value of "<b>DetectedIssue:patient</b>".
2026   */
2027  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("DetectedIssue:patient").toLocked();
2028
2029 /**
2030   * Search parameter: <b>author</b>
2031   * <p>
2032   * Description: <b>The provider or device that identified the issue</b><br>
2033   * Type: <b>reference</b><br>
2034   * Path: <b>DetectedIssue.author</b><br>
2035   * </p>
2036   */
2037  @SearchParamDefinition(name="author", path="DetectedIssue.author", description="The provider or device that identified the issue", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Device"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner") }, target={Device.class, Practitioner.class, PractitionerRole.class } )
2038  public static final String SP_AUTHOR = "author";
2039 /**
2040   * <b>Fluent Client</b> search parameter constant for <b>author</b>
2041   * <p>
2042   * Description: <b>The provider or device that identified the issue</b><br>
2043   * Type: <b>reference</b><br>
2044   * Path: <b>DetectedIssue.author</b><br>
2045   * </p>
2046   */
2047  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
2048
2049/**
2050   * Constant for fluent queries to be used to add include statements. Specifies
2051   * the path value of "<b>DetectedIssue:author</b>".
2052   */
2053  public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("DetectedIssue:author").toLocked();
2054
2055 /**
2056   * Search parameter: <b>implicated</b>
2057   * <p>
2058   * Description: <b>Problem resource</b><br>
2059   * Type: <b>reference</b><br>
2060   * Path: <b>DetectedIssue.implicated</b><br>
2061   * </p>
2062   */
2063  @SearchParamDefinition(name="implicated", path="DetectedIssue.implicated", description="Problem resource", type="reference" )
2064  public static final String SP_IMPLICATED = "implicated";
2065 /**
2066   * <b>Fluent Client</b> search parameter constant for <b>implicated</b>
2067   * <p>
2068   * Description: <b>Problem resource</b><br>
2069   * Type: <b>reference</b><br>
2070   * Path: <b>DetectedIssue.implicated</b><br>
2071   * </p>
2072   */
2073  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam IMPLICATED = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_IMPLICATED);
2074
2075/**
2076   * Constant for fluent queries to be used to add include statements. Specifies
2077   * the path value of "<b>DetectedIssue:implicated</b>".
2078   */
2079  public static final ca.uhn.fhir.model.api.Include INCLUDE_IMPLICATED = new ca.uhn.fhir.model.api.Include("DetectedIssue:implicated").toLocked();
2080
2081
2082}