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