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