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