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