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