001package org.hl7.fhir.dstu2.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu2
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
024import java.math.BigDecimal;
025
026/*
027  Copyright (c) 2011+, HL7, Inc.
028  All rights reserved.
029  
030  Redistribution and use in source and binary forms, with or without modification, 
031  are permitted provided that the following conditions are met:
032  
033   * Redistributions of source code must retain the above copyright notice, this 
034     list of conditions and the following disclaimer.
035   * Redistributions in binary form must reproduce the above copyright notice, 
036     this list of conditions and the following disclaimer in the documentation 
037     and/or other materials provided with the distribution.
038   * Neither the name of HL7 nor the names of its contributors may be used to 
039     endorse or promote products derived from this software without specific 
040     prior written permission.
041  
042  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
043  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
044  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
045  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
046  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
047  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
048  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
049  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
050  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
051  POSSIBILITY OF SUCH DAMAGE.
052  
053*/
054
055// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
056import java.util.ArrayList;
057import java.util.Date;
058import java.util.List;
059
060import ca.uhn.fhir.model.api.annotation.Block;
061import ca.uhn.fhir.model.api.annotation.Child;
062import ca.uhn.fhir.model.api.annotation.Description;
063import ca.uhn.fhir.model.api.annotation.ResourceDef;
064import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
065import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
066import org.hl7.fhir.exceptions.FHIRException;
067import org.hl7.fhir.utilities.Utilities;
068/**
069 * An assessment of the likely outcome(s) for a patient or other subject as well as the likelihood of each outcome.
070 */
071@ResourceDef(name="RiskAssessment", profile="http://hl7.org/fhir/Profile/RiskAssessment")
072public class RiskAssessment extends DomainResource {
073
074    @Block()
075    public static class RiskAssessmentPredictionComponent extends BackboneElement implements IBaseBackboneElement {
076        /**
077         * One of the potential outcomes for the patient (e.g. remission, death,  a particular condition).
078         */
079        @Child(name = "outcome", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=false, summary=false)
080        @Description(shortDefinition="Possible outcome for the subject", formalDefinition="One of the potential outcomes for the patient (e.g. remission, death,  a particular condition)." )
081        protected CodeableConcept outcome;
082
083        /**
084         * How likely is the outcome (in the specified timeframe).
085         */
086        @Child(name = "probability", type = {DecimalType.class, Range.class, CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=false)
087        @Description(shortDefinition="Likelihood of specified outcome", formalDefinition="How likely is the outcome (in the specified timeframe)." )
088        protected Type probability;
089
090        /**
091         * Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).
092         */
093        @Child(name = "relativeRisk", type = {DecimalType.class}, order=3, min=0, max=1, modifier=false, summary=false)
094        @Description(shortDefinition="Relative likelihood", formalDefinition="Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.)." )
095        protected DecimalType relativeRisk;
096
097        /**
098         * Indicates the period of time or age range of the subject to which the specified probability applies.
099         */
100        @Child(name = "when", type = {Period.class, Range.class}, order=4, min=0, max=1, modifier=false, summary=false)
101        @Description(shortDefinition="Timeframe or age range", formalDefinition="Indicates the period of time or age range of the subject to which the specified probability applies." )
102        protected Type when;
103
104        /**
105         * Additional information explaining the basis for the prediction.
106         */
107        @Child(name = "rationale", type = {StringType.class}, order=5, min=0, max=1, modifier=false, summary=false)
108        @Description(shortDefinition="Explanation of prediction", formalDefinition="Additional information explaining the basis for the prediction." )
109        protected StringType rationale;
110
111        private static final long serialVersionUID = 647967428L;
112
113    /*
114     * Constructor
115     */
116      public RiskAssessmentPredictionComponent() {
117        super();
118      }
119
120    /*
121     * Constructor
122     */
123      public RiskAssessmentPredictionComponent(CodeableConcept outcome) {
124        super();
125        this.outcome = outcome;
126      }
127
128        /**
129         * @return {@link #outcome} (One of the potential outcomes for the patient (e.g. remission, death,  a particular condition).)
130         */
131        public CodeableConcept getOutcome() { 
132          if (this.outcome == null)
133            if (Configuration.errorOnAutoCreate())
134              throw new Error("Attempt to auto-create RiskAssessmentPredictionComponent.outcome");
135            else if (Configuration.doAutoCreate())
136              this.outcome = new CodeableConcept(); // cc
137          return this.outcome;
138        }
139
140        public boolean hasOutcome() { 
141          return this.outcome != null && !this.outcome.isEmpty();
142        }
143
144        /**
145         * @param value {@link #outcome} (One of the potential outcomes for the patient (e.g. remission, death,  a particular condition).)
146         */
147        public RiskAssessmentPredictionComponent setOutcome(CodeableConcept value) { 
148          this.outcome = value;
149          return this;
150        }
151
152        /**
153         * @return {@link #probability} (How likely is the outcome (in the specified timeframe).)
154         */
155        public Type getProbability() { 
156          return this.probability;
157        }
158
159        /**
160         * @return {@link #probability} (How likely is the outcome (in the specified timeframe).)
161         */
162        public DecimalType getProbabilityDecimalType() throws FHIRException { 
163          if (!(this.probability instanceof DecimalType))
164            throw new FHIRException("Type mismatch: the type DecimalType was expected, but "+this.probability.getClass().getName()+" was encountered");
165          return (DecimalType) this.probability;
166        }
167
168        public boolean hasProbabilityDecimalType() { 
169          return this.probability instanceof DecimalType;
170        }
171
172        /**
173         * @return {@link #probability} (How likely is the outcome (in the specified timeframe).)
174         */
175        public Range getProbabilityRange() throws FHIRException { 
176          if (!(this.probability instanceof Range))
177            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.probability.getClass().getName()+" was encountered");
178          return (Range) this.probability;
179        }
180
181        public boolean hasProbabilityRange() { 
182          return this.probability instanceof Range;
183        }
184
185        /**
186         * @return {@link #probability} (How likely is the outcome (in the specified timeframe).)
187         */
188        public CodeableConcept getProbabilityCodeableConcept() throws FHIRException { 
189          if (!(this.probability instanceof CodeableConcept))
190            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.probability.getClass().getName()+" was encountered");
191          return (CodeableConcept) this.probability;
192        }
193
194        public boolean hasProbabilityCodeableConcept() { 
195          return this.probability instanceof CodeableConcept;
196        }
197
198        public boolean hasProbability() { 
199          return this.probability != null && !this.probability.isEmpty();
200        }
201
202        /**
203         * @param value {@link #probability} (How likely is the outcome (in the specified timeframe).)
204         */
205        public RiskAssessmentPredictionComponent setProbability(Type value) { 
206          this.probability = value;
207          return this;
208        }
209
210        /**
211         * @return {@link #relativeRisk} (Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).). This is the underlying object with id, value and extensions. The accessor "getRelativeRisk" gives direct access to the value
212         */
213        public DecimalType getRelativeRiskElement() { 
214          if (this.relativeRisk == null)
215            if (Configuration.errorOnAutoCreate())
216              throw new Error("Attempt to auto-create RiskAssessmentPredictionComponent.relativeRisk");
217            else if (Configuration.doAutoCreate())
218              this.relativeRisk = new DecimalType(); // bb
219          return this.relativeRisk;
220        }
221
222        public boolean hasRelativeRiskElement() { 
223          return this.relativeRisk != null && !this.relativeRisk.isEmpty();
224        }
225
226        public boolean hasRelativeRisk() { 
227          return this.relativeRisk != null && !this.relativeRisk.isEmpty();
228        }
229
230        /**
231         * @param value {@link #relativeRisk} (Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).). This is the underlying object with id, value and extensions. The accessor "getRelativeRisk" gives direct access to the value
232         */
233        public RiskAssessmentPredictionComponent setRelativeRiskElement(DecimalType value) { 
234          this.relativeRisk = value;
235          return this;
236        }
237
238        /**
239         * @return Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).
240         */
241        public BigDecimal getRelativeRisk() { 
242          return this.relativeRisk == null ? null : this.relativeRisk.getValue();
243        }
244
245        /**
246         * @param value Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).
247         */
248        public RiskAssessmentPredictionComponent setRelativeRisk(BigDecimal value) { 
249          if (value == null)
250            this.relativeRisk = null;
251          else {
252            if (this.relativeRisk == null)
253              this.relativeRisk = new DecimalType();
254            this.relativeRisk.setValue(value);
255          }
256          return this;
257        }
258
259        /**
260         * @return {@link #when} (Indicates the period of time or age range of the subject to which the specified probability applies.)
261         */
262        public Type getWhen() { 
263          return this.when;
264        }
265
266        /**
267         * @return {@link #when} (Indicates the period of time or age range of the subject to which the specified probability applies.)
268         */
269        public Period getWhenPeriod() throws FHIRException { 
270          if (!(this.when instanceof Period))
271            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.when.getClass().getName()+" was encountered");
272          return (Period) this.when;
273        }
274
275        public boolean hasWhenPeriod() { 
276          return this.when instanceof Period;
277        }
278
279        /**
280         * @return {@link #when} (Indicates the period of time or age range of the subject to which the specified probability applies.)
281         */
282        public Range getWhenRange() throws FHIRException { 
283          if (!(this.when instanceof Range))
284            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.when.getClass().getName()+" was encountered");
285          return (Range) this.when;
286        }
287
288        public boolean hasWhenRange() { 
289          return this.when instanceof Range;
290        }
291
292        public boolean hasWhen() { 
293          return this.when != null && !this.when.isEmpty();
294        }
295
296        /**
297         * @param value {@link #when} (Indicates the period of time or age range of the subject to which the specified probability applies.)
298         */
299        public RiskAssessmentPredictionComponent setWhen(Type value) { 
300          this.when = value;
301          return this;
302        }
303
304        /**
305         * @return {@link #rationale} (Additional information explaining the basis for the prediction.). This is the underlying object with id, value and extensions. The accessor "getRationale" gives direct access to the value
306         */
307        public StringType getRationaleElement() { 
308          if (this.rationale == null)
309            if (Configuration.errorOnAutoCreate())
310              throw new Error("Attempt to auto-create RiskAssessmentPredictionComponent.rationale");
311            else if (Configuration.doAutoCreate())
312              this.rationale = new StringType(); // bb
313          return this.rationale;
314        }
315
316        public boolean hasRationaleElement() { 
317          return this.rationale != null && !this.rationale.isEmpty();
318        }
319
320        public boolean hasRationale() { 
321          return this.rationale != null && !this.rationale.isEmpty();
322        }
323
324        /**
325         * @param value {@link #rationale} (Additional information explaining the basis for the prediction.). This is the underlying object with id, value and extensions. The accessor "getRationale" gives direct access to the value
326         */
327        public RiskAssessmentPredictionComponent setRationaleElement(StringType value) { 
328          this.rationale = value;
329          return this;
330        }
331
332        /**
333         * @return Additional information explaining the basis for the prediction.
334         */
335        public String getRationale() { 
336          return this.rationale == null ? null : this.rationale.getValue();
337        }
338
339        /**
340         * @param value Additional information explaining the basis for the prediction.
341         */
342        public RiskAssessmentPredictionComponent setRationale(String value) { 
343          if (Utilities.noString(value))
344            this.rationale = null;
345          else {
346            if (this.rationale == null)
347              this.rationale = new StringType();
348            this.rationale.setValue(value);
349          }
350          return this;
351        }
352
353        protected void listChildren(List<Property> childrenList) {
354          super.listChildren(childrenList);
355          childrenList.add(new Property("outcome", "CodeableConcept", "One of the potential outcomes for the patient (e.g. remission, death,  a particular condition).", 0, java.lang.Integer.MAX_VALUE, outcome));
356          childrenList.add(new Property("probability[x]", "decimal|Range|CodeableConcept", "How likely is the outcome (in the specified timeframe).", 0, java.lang.Integer.MAX_VALUE, probability));
357          childrenList.add(new Property("relativeRisk", "decimal", "Indicates the risk for this particular subject (with their specific characteristics) divided by the risk of the population in general.  (Numbers greater than 1 = higher risk than the population, numbers less than 1 = lower risk.).", 0, java.lang.Integer.MAX_VALUE, relativeRisk));
358          childrenList.add(new Property("when[x]", "Period|Range", "Indicates the period of time or age range of the subject to which the specified probability applies.", 0, java.lang.Integer.MAX_VALUE, when));
359          childrenList.add(new Property("rationale", "string", "Additional information explaining the basis for the prediction.", 0, java.lang.Integer.MAX_VALUE, rationale));
360        }
361
362      @Override
363      public void setProperty(String name, Base value) throws FHIRException {
364        if (name.equals("outcome"))
365          this.outcome = castToCodeableConcept(value); // CodeableConcept
366        else if (name.equals("probability[x]"))
367          this.probability = (Type) value; // Type
368        else if (name.equals("relativeRisk"))
369          this.relativeRisk = castToDecimal(value); // DecimalType
370        else if (name.equals("when[x]"))
371          this.when = (Type) value; // Type
372        else if (name.equals("rationale"))
373          this.rationale = castToString(value); // StringType
374        else
375          super.setProperty(name, value);
376      }
377
378      @Override
379      public Base addChild(String name) throws FHIRException {
380        if (name.equals("outcome")) {
381          this.outcome = new CodeableConcept();
382          return this.outcome;
383        }
384        else if (name.equals("probabilityDecimal")) {
385          this.probability = new DecimalType();
386          return this.probability;
387        }
388        else if (name.equals("probabilityRange")) {
389          this.probability = new Range();
390          return this.probability;
391        }
392        else if (name.equals("probabilityCodeableConcept")) {
393          this.probability = new CodeableConcept();
394          return this.probability;
395        }
396        else if (name.equals("relativeRisk")) {
397          throw new FHIRException("Cannot call addChild on a primitive type RiskAssessment.relativeRisk");
398        }
399        else if (name.equals("whenPeriod")) {
400          this.when = new Period();
401          return this.when;
402        }
403        else if (name.equals("whenRange")) {
404          this.when = new Range();
405          return this.when;
406        }
407        else if (name.equals("rationale")) {
408          throw new FHIRException("Cannot call addChild on a primitive type RiskAssessment.rationale");
409        }
410        else
411          return super.addChild(name);
412      }
413
414      public RiskAssessmentPredictionComponent copy() {
415        RiskAssessmentPredictionComponent dst = new RiskAssessmentPredictionComponent();
416        copyValues(dst);
417        dst.outcome = outcome == null ? null : outcome.copy();
418        dst.probability = probability == null ? null : probability.copy();
419        dst.relativeRisk = relativeRisk == null ? null : relativeRisk.copy();
420        dst.when = when == null ? null : when.copy();
421        dst.rationale = rationale == null ? null : rationale.copy();
422        return dst;
423      }
424
425      @Override
426      public boolean equalsDeep(Base other) {
427        if (!super.equalsDeep(other))
428          return false;
429        if (!(other instanceof RiskAssessmentPredictionComponent))
430          return false;
431        RiskAssessmentPredictionComponent o = (RiskAssessmentPredictionComponent) other;
432        return compareDeep(outcome, o.outcome, true) && compareDeep(probability, o.probability, true) && compareDeep(relativeRisk, o.relativeRisk, true)
433           && compareDeep(when, o.when, true) && compareDeep(rationale, o.rationale, true);
434      }
435
436      @Override
437      public boolean equalsShallow(Base other) {
438        if (!super.equalsShallow(other))
439          return false;
440        if (!(other instanceof RiskAssessmentPredictionComponent))
441          return false;
442        RiskAssessmentPredictionComponent o = (RiskAssessmentPredictionComponent) other;
443        return compareValues(relativeRisk, o.relativeRisk, true) && compareValues(rationale, o.rationale, true)
444          ;
445      }
446
447      public boolean isEmpty() {
448        return super.isEmpty() && (outcome == null || outcome.isEmpty()) && (probability == null || probability.isEmpty())
449           && (relativeRisk == null || relativeRisk.isEmpty()) && (when == null || when.isEmpty()) && (rationale == null || rationale.isEmpty())
450          ;
451      }
452
453  public String fhirType() {
454    return "RiskAssessment.prediction";
455
456  }
457
458  }
459
460    /**
461     * The patient or group the risk assessment applies to.
462     */
463    @Child(name = "subject", type = {Patient.class, Group.class}, order=0, min=0, max=1, modifier=false, summary=true)
464    @Description(shortDefinition="Who/what does assessment apply to?", formalDefinition="The patient or group the risk assessment applies to." )
465    protected Reference subject;
466
467    /**
468     * The actual object that is the target of the reference (The patient or group the risk assessment applies to.)
469     */
470    protected Resource subjectTarget;
471
472    /**
473     * The date (and possibly time) the risk assessment was performed.
474     */
475    @Child(name = "date", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
476    @Description(shortDefinition="When was assessment made?", formalDefinition="The date (and possibly time) the risk assessment was performed." )
477    protected DateTimeType date;
478
479    /**
480     * For assessments or prognosis specific to a particular condition, indicates the condition being assessed.
481     */
482    @Child(name = "condition", type = {Condition.class}, order=2, min=0, max=1, modifier=false, summary=true)
483    @Description(shortDefinition="Condition assessed", formalDefinition="For assessments or prognosis specific to a particular condition, indicates the condition being assessed." )
484    protected Reference condition;
485
486    /**
487     * The actual object that is the target of the reference (For assessments or prognosis specific to a particular condition, indicates the condition being assessed.)
488     */
489    protected Condition conditionTarget;
490
491    /**
492     * The encounter where the assessment was performed.
493     */
494    @Child(name = "encounter", type = {Encounter.class}, order=3, min=0, max=1, modifier=false, summary=true)
495    @Description(shortDefinition="Where was assessment performed?", formalDefinition="The encounter where the assessment was performed." )
496    protected Reference encounter;
497
498    /**
499     * The actual object that is the target of the reference (The encounter where the assessment was performed.)
500     */
501    protected Encounter encounterTarget;
502
503    /**
504     * The provider or software application that performed the assessment.
505     */
506    @Child(name = "performer", type = {Practitioner.class, Device.class}, order=4, min=0, max=1, modifier=false, summary=true)
507    @Description(shortDefinition="Who did assessment?", formalDefinition="The provider or software application that performed the assessment." )
508    protected Reference performer;
509
510    /**
511     * The actual object that is the target of the reference (The provider or software application that performed the assessment.)
512     */
513    protected Resource performerTarget;
514
515    /**
516     * Business identifier assigned to the risk assessment.
517     */
518    @Child(name = "identifier", type = {Identifier.class}, order=5, min=0, max=1, modifier=false, summary=true)
519    @Description(shortDefinition="Unique identifier for the assessment", formalDefinition="Business identifier assigned to the risk assessment." )
520    protected Identifier identifier;
521
522    /**
523     * The algorithm, process or mechanism used to evaluate the risk.
524     */
525    @Child(name = "method", type = {CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
526    @Description(shortDefinition="Evaluation mechanism", formalDefinition="The algorithm, process or mechanism used to evaluate the risk." )
527    protected CodeableConcept method;
528
529    /**
530     * Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).
531     */
532    @Child(name = "basis", type = {}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
533    @Description(shortDefinition="Information used in assessment", formalDefinition="Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.)." )
534    protected List<Reference> basis;
535    /**
536     * The actual objects that are the target of the reference (Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).)
537     */
538    protected List<Resource> basisTarget;
539
540
541    /**
542     * Describes the expected outcome for the subject.
543     */
544    @Child(name = "prediction", type = {}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
545    @Description(shortDefinition="Outcome predicted", formalDefinition="Describes the expected outcome for the subject." )
546    protected List<RiskAssessmentPredictionComponent> prediction;
547
548    /**
549     * A description of the steps that might be taken to reduce the identified risk(s).
550     */
551    @Child(name = "mitigation", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=false)
552    @Description(shortDefinition="How to reduce risk", formalDefinition="A description of the steps that might be taken to reduce the identified risk(s)." )
553    protected StringType mitigation;
554
555    private static final long serialVersionUID = 724306293L;
556
557  /*
558   * Constructor
559   */
560    public RiskAssessment() {
561      super();
562    }
563
564    /**
565     * @return {@link #subject} (The patient or group the risk assessment applies to.)
566     */
567    public Reference getSubject() { 
568      if (this.subject == null)
569        if (Configuration.errorOnAutoCreate())
570          throw new Error("Attempt to auto-create RiskAssessment.subject");
571        else if (Configuration.doAutoCreate())
572          this.subject = new Reference(); // cc
573      return this.subject;
574    }
575
576    public boolean hasSubject() { 
577      return this.subject != null && !this.subject.isEmpty();
578    }
579
580    /**
581     * @param value {@link #subject} (The patient or group the risk assessment applies to.)
582     */
583    public RiskAssessment setSubject(Reference value) { 
584      this.subject = value;
585      return this;
586    }
587
588    /**
589     * @return {@link #subject} 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. (The patient or group the risk assessment applies to.)
590     */
591    public Resource getSubjectTarget() { 
592      return this.subjectTarget;
593    }
594
595    /**
596     * @param value {@link #subject} 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. (The patient or group the risk assessment applies to.)
597     */
598    public RiskAssessment setSubjectTarget(Resource value) { 
599      this.subjectTarget = value;
600      return this;
601    }
602
603    /**
604     * @return {@link #date} (The date (and possibly time) the risk assessment was performed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
605     */
606    public DateTimeType getDateElement() { 
607      if (this.date == null)
608        if (Configuration.errorOnAutoCreate())
609          throw new Error("Attempt to auto-create RiskAssessment.date");
610        else if (Configuration.doAutoCreate())
611          this.date = new DateTimeType(); // bb
612      return this.date;
613    }
614
615    public boolean hasDateElement() { 
616      return this.date != null && !this.date.isEmpty();
617    }
618
619    public boolean hasDate() { 
620      return this.date != null && !this.date.isEmpty();
621    }
622
623    /**
624     * @param value {@link #date} (The date (and possibly time) the risk assessment was performed.). This is the underlying object with id, value and extensions. The accessor "getDate" gives direct access to the value
625     */
626    public RiskAssessment setDateElement(DateTimeType value) { 
627      this.date = value;
628      return this;
629    }
630
631    /**
632     * @return The date (and possibly time) the risk assessment was performed.
633     */
634    public Date getDate() { 
635      return this.date == null ? null : this.date.getValue();
636    }
637
638    /**
639     * @param value The date (and possibly time) the risk assessment was performed.
640     */
641    public RiskAssessment setDate(Date value) { 
642      if (value == null)
643        this.date = null;
644      else {
645        if (this.date == null)
646          this.date = new DateTimeType();
647        this.date.setValue(value);
648      }
649      return this;
650    }
651
652    /**
653     * @return {@link #condition} (For assessments or prognosis specific to a particular condition, indicates the condition being assessed.)
654     */
655    public Reference getCondition() { 
656      if (this.condition == null)
657        if (Configuration.errorOnAutoCreate())
658          throw new Error("Attempt to auto-create RiskAssessment.condition");
659        else if (Configuration.doAutoCreate())
660          this.condition = new Reference(); // cc
661      return this.condition;
662    }
663
664    public boolean hasCondition() { 
665      return this.condition != null && !this.condition.isEmpty();
666    }
667
668    /**
669     * @param value {@link #condition} (For assessments or prognosis specific to a particular condition, indicates the condition being assessed.)
670     */
671    public RiskAssessment setCondition(Reference value) { 
672      this.condition = value;
673      return this;
674    }
675
676    /**
677     * @return {@link #condition} 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. (For assessments or prognosis specific to a particular condition, indicates the condition being assessed.)
678     */
679    public Condition getConditionTarget() { 
680      if (this.conditionTarget == null)
681        if (Configuration.errorOnAutoCreate())
682          throw new Error("Attempt to auto-create RiskAssessment.condition");
683        else if (Configuration.doAutoCreate())
684          this.conditionTarget = new Condition(); // aa
685      return this.conditionTarget;
686    }
687
688    /**
689     * @param value {@link #condition} 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. (For assessments or prognosis specific to a particular condition, indicates the condition being assessed.)
690     */
691    public RiskAssessment setConditionTarget(Condition value) { 
692      this.conditionTarget = value;
693      return this;
694    }
695
696    /**
697     * @return {@link #encounter} (The encounter where the assessment was performed.)
698     */
699    public Reference getEncounter() { 
700      if (this.encounter == null)
701        if (Configuration.errorOnAutoCreate())
702          throw new Error("Attempt to auto-create RiskAssessment.encounter");
703        else if (Configuration.doAutoCreate())
704          this.encounter = new Reference(); // cc
705      return this.encounter;
706    }
707
708    public boolean hasEncounter() { 
709      return this.encounter != null && !this.encounter.isEmpty();
710    }
711
712    /**
713     * @param value {@link #encounter} (The encounter where the assessment was performed.)
714     */
715    public RiskAssessment setEncounter(Reference value) { 
716      this.encounter = value;
717      return this;
718    }
719
720    /**
721     * @return {@link #encounter} 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. (The encounter where the assessment was performed.)
722     */
723    public Encounter getEncounterTarget() { 
724      if (this.encounterTarget == null)
725        if (Configuration.errorOnAutoCreate())
726          throw new Error("Attempt to auto-create RiskAssessment.encounter");
727        else if (Configuration.doAutoCreate())
728          this.encounterTarget = new Encounter(); // aa
729      return this.encounterTarget;
730    }
731
732    /**
733     * @param value {@link #encounter} 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. (The encounter where the assessment was performed.)
734     */
735    public RiskAssessment setEncounterTarget(Encounter value) { 
736      this.encounterTarget = value;
737      return this;
738    }
739
740    /**
741     * @return {@link #performer} (The provider or software application that performed the assessment.)
742     */
743    public Reference getPerformer() { 
744      if (this.performer == null)
745        if (Configuration.errorOnAutoCreate())
746          throw new Error("Attempt to auto-create RiskAssessment.performer");
747        else if (Configuration.doAutoCreate())
748          this.performer = new Reference(); // cc
749      return this.performer;
750    }
751
752    public boolean hasPerformer() { 
753      return this.performer != null && !this.performer.isEmpty();
754    }
755
756    /**
757     * @param value {@link #performer} (The provider or software application that performed the assessment.)
758     */
759    public RiskAssessment setPerformer(Reference value) { 
760      this.performer = value;
761      return this;
762    }
763
764    /**
765     * @return {@link #performer} 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. (The provider or software application that performed the assessment.)
766     */
767    public Resource getPerformerTarget() { 
768      return this.performerTarget;
769    }
770
771    /**
772     * @param value {@link #performer} 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. (The provider or software application that performed the assessment.)
773     */
774    public RiskAssessment setPerformerTarget(Resource value) { 
775      this.performerTarget = value;
776      return this;
777    }
778
779    /**
780     * @return {@link #identifier} (Business identifier assigned to the risk assessment.)
781     */
782    public Identifier getIdentifier() { 
783      if (this.identifier == null)
784        if (Configuration.errorOnAutoCreate())
785          throw new Error("Attempt to auto-create RiskAssessment.identifier");
786        else if (Configuration.doAutoCreate())
787          this.identifier = new Identifier(); // cc
788      return this.identifier;
789    }
790
791    public boolean hasIdentifier() { 
792      return this.identifier != null && !this.identifier.isEmpty();
793    }
794
795    /**
796     * @param value {@link #identifier} (Business identifier assigned to the risk assessment.)
797     */
798    public RiskAssessment setIdentifier(Identifier value) { 
799      this.identifier = value;
800      return this;
801    }
802
803    /**
804     * @return {@link #method} (The algorithm, process or mechanism used to evaluate the risk.)
805     */
806    public CodeableConcept getMethod() { 
807      if (this.method == null)
808        if (Configuration.errorOnAutoCreate())
809          throw new Error("Attempt to auto-create RiskAssessment.method");
810        else if (Configuration.doAutoCreate())
811          this.method = new CodeableConcept(); // cc
812      return this.method;
813    }
814
815    public boolean hasMethod() { 
816      return this.method != null && !this.method.isEmpty();
817    }
818
819    /**
820     * @param value {@link #method} (The algorithm, process or mechanism used to evaluate the risk.)
821     */
822    public RiskAssessment setMethod(CodeableConcept value) { 
823      this.method = value;
824      return this;
825    }
826
827    /**
828     * @return {@link #basis} (Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).)
829     */
830    public List<Reference> getBasis() { 
831      if (this.basis == null)
832        this.basis = new ArrayList<Reference>();
833      return this.basis;
834    }
835
836    public boolean hasBasis() { 
837      if (this.basis == null)
838        return false;
839      for (Reference item : this.basis)
840        if (!item.isEmpty())
841          return true;
842      return false;
843    }
844
845    /**
846     * @return {@link #basis} (Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).)
847     */
848    // syntactic sugar
849    public Reference addBasis() { //3
850      Reference t = new Reference();
851      if (this.basis == null)
852        this.basis = new ArrayList<Reference>();
853      this.basis.add(t);
854      return t;
855    }
856
857    // syntactic sugar
858    public RiskAssessment addBasis(Reference t) { //3
859      if (t == null)
860        return this;
861      if (this.basis == null)
862        this.basis = new ArrayList<Reference>();
863      this.basis.add(t);
864      return this;
865    }
866
867    /**
868     * @return {@link #basis} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).)
869     */
870    public List<Resource> getBasisTarget() { 
871      if (this.basisTarget == null)
872        this.basisTarget = new ArrayList<Resource>();
873      return this.basisTarget;
874    }
875
876    /**
877     * @return {@link #prediction} (Describes the expected outcome for the subject.)
878     */
879    public List<RiskAssessmentPredictionComponent> getPrediction() { 
880      if (this.prediction == null)
881        this.prediction = new ArrayList<RiskAssessmentPredictionComponent>();
882      return this.prediction;
883    }
884
885    public boolean hasPrediction() { 
886      if (this.prediction == null)
887        return false;
888      for (RiskAssessmentPredictionComponent item : this.prediction)
889        if (!item.isEmpty())
890          return true;
891      return false;
892    }
893
894    /**
895     * @return {@link #prediction} (Describes the expected outcome for the subject.)
896     */
897    // syntactic sugar
898    public RiskAssessmentPredictionComponent addPrediction() { //3
899      RiskAssessmentPredictionComponent t = new RiskAssessmentPredictionComponent();
900      if (this.prediction == null)
901        this.prediction = new ArrayList<RiskAssessmentPredictionComponent>();
902      this.prediction.add(t);
903      return t;
904    }
905
906    // syntactic sugar
907    public RiskAssessment addPrediction(RiskAssessmentPredictionComponent t) { //3
908      if (t == null)
909        return this;
910      if (this.prediction == null)
911        this.prediction = new ArrayList<RiskAssessmentPredictionComponent>();
912      this.prediction.add(t);
913      return this;
914    }
915
916    /**
917     * @return {@link #mitigation} (A description of the steps that might be taken to reduce the identified risk(s).). This is the underlying object with id, value and extensions. The accessor "getMitigation" gives direct access to the value
918     */
919    public StringType getMitigationElement() { 
920      if (this.mitigation == null)
921        if (Configuration.errorOnAutoCreate())
922          throw new Error("Attempt to auto-create RiskAssessment.mitigation");
923        else if (Configuration.doAutoCreate())
924          this.mitigation = new StringType(); // bb
925      return this.mitigation;
926    }
927
928    public boolean hasMitigationElement() { 
929      return this.mitigation != null && !this.mitigation.isEmpty();
930    }
931
932    public boolean hasMitigation() { 
933      return this.mitigation != null && !this.mitigation.isEmpty();
934    }
935
936    /**
937     * @param value {@link #mitigation} (A description of the steps that might be taken to reduce the identified risk(s).). This is the underlying object with id, value and extensions. The accessor "getMitigation" gives direct access to the value
938     */
939    public RiskAssessment setMitigationElement(StringType value) { 
940      this.mitigation = value;
941      return this;
942    }
943
944    /**
945     * @return A description of the steps that might be taken to reduce the identified risk(s).
946     */
947    public String getMitigation() { 
948      return this.mitigation == null ? null : this.mitigation.getValue();
949    }
950
951    /**
952     * @param value A description of the steps that might be taken to reduce the identified risk(s).
953     */
954    public RiskAssessment setMitigation(String value) { 
955      if (Utilities.noString(value))
956        this.mitigation = null;
957      else {
958        if (this.mitigation == null)
959          this.mitigation = new StringType();
960        this.mitigation.setValue(value);
961      }
962      return this;
963    }
964
965      protected void listChildren(List<Property> childrenList) {
966        super.listChildren(childrenList);
967        childrenList.add(new Property("subject", "Reference(Patient|Group)", "The patient or group the risk assessment applies to.", 0, java.lang.Integer.MAX_VALUE, subject));
968        childrenList.add(new Property("date", "dateTime", "The date (and possibly time) the risk assessment was performed.", 0, java.lang.Integer.MAX_VALUE, date));
969        childrenList.add(new Property("condition", "Reference(Condition)", "For assessments or prognosis specific to a particular condition, indicates the condition being assessed.", 0, java.lang.Integer.MAX_VALUE, condition));
970        childrenList.add(new Property("encounter", "Reference(Encounter)", "The encounter where the assessment was performed.", 0, java.lang.Integer.MAX_VALUE, encounter));
971        childrenList.add(new Property("performer", "Reference(Practitioner|Device)", "The provider or software application that performed the assessment.", 0, java.lang.Integer.MAX_VALUE, performer));
972        childrenList.add(new Property("identifier", "Identifier", "Business identifier assigned to the risk assessment.", 0, java.lang.Integer.MAX_VALUE, identifier));
973        childrenList.add(new Property("method", "CodeableConcept", "The algorithm, process or mechanism used to evaluate the risk.", 0, java.lang.Integer.MAX_VALUE, method));
974        childrenList.add(new Property("basis", "Reference(Any)", "Indicates the source data considered as part of the assessment (FamilyHistory, Observations, Procedures, Conditions, etc.).", 0, java.lang.Integer.MAX_VALUE, basis));
975        childrenList.add(new Property("prediction", "", "Describes the expected outcome for the subject.", 0, java.lang.Integer.MAX_VALUE, prediction));
976        childrenList.add(new Property("mitigation", "string", "A description of the steps that might be taken to reduce the identified risk(s).", 0, java.lang.Integer.MAX_VALUE, mitigation));
977      }
978
979      @Override
980      public void setProperty(String name, Base value) throws FHIRException {
981        if (name.equals("subject"))
982          this.subject = castToReference(value); // Reference
983        else if (name.equals("date"))
984          this.date = castToDateTime(value); // DateTimeType
985        else if (name.equals("condition"))
986          this.condition = castToReference(value); // Reference
987        else if (name.equals("encounter"))
988          this.encounter = castToReference(value); // Reference
989        else if (name.equals("performer"))
990          this.performer = castToReference(value); // Reference
991        else if (name.equals("identifier"))
992          this.identifier = castToIdentifier(value); // Identifier
993        else if (name.equals("method"))
994          this.method = castToCodeableConcept(value); // CodeableConcept
995        else if (name.equals("basis"))
996          this.getBasis().add(castToReference(value));
997        else if (name.equals("prediction"))
998          this.getPrediction().add((RiskAssessmentPredictionComponent) value);
999        else if (name.equals("mitigation"))
1000          this.mitigation = castToString(value); // StringType
1001        else
1002          super.setProperty(name, value);
1003      }
1004
1005      @Override
1006      public Base addChild(String name) throws FHIRException {
1007        if (name.equals("subject")) {
1008          this.subject = new Reference();
1009          return this.subject;
1010        }
1011        else if (name.equals("date")) {
1012          throw new FHIRException("Cannot call addChild on a primitive type RiskAssessment.date");
1013        }
1014        else if (name.equals("condition")) {
1015          this.condition = new Reference();
1016          return this.condition;
1017        }
1018        else if (name.equals("encounter")) {
1019          this.encounter = new Reference();
1020          return this.encounter;
1021        }
1022        else if (name.equals("performer")) {
1023          this.performer = new Reference();
1024          return this.performer;
1025        }
1026        else if (name.equals("identifier")) {
1027          this.identifier = new Identifier();
1028          return this.identifier;
1029        }
1030        else if (name.equals("method")) {
1031          this.method = new CodeableConcept();
1032          return this.method;
1033        }
1034        else if (name.equals("basis")) {
1035          return addBasis();
1036        }
1037        else if (name.equals("prediction")) {
1038          return addPrediction();
1039        }
1040        else if (name.equals("mitigation")) {
1041          throw new FHIRException("Cannot call addChild on a primitive type RiskAssessment.mitigation");
1042        }
1043        else
1044          return super.addChild(name);
1045      }
1046
1047  public String fhirType() {
1048    return "RiskAssessment";
1049
1050  }
1051
1052      public RiskAssessment copy() {
1053        RiskAssessment dst = new RiskAssessment();
1054        copyValues(dst);
1055        dst.subject = subject == null ? null : subject.copy();
1056        dst.date = date == null ? null : date.copy();
1057        dst.condition = condition == null ? null : condition.copy();
1058        dst.encounter = encounter == null ? null : encounter.copy();
1059        dst.performer = performer == null ? null : performer.copy();
1060        dst.identifier = identifier == null ? null : identifier.copy();
1061        dst.method = method == null ? null : method.copy();
1062        if (basis != null) {
1063          dst.basis = new ArrayList<Reference>();
1064          for (Reference i : basis)
1065            dst.basis.add(i.copy());
1066        };
1067        if (prediction != null) {
1068          dst.prediction = new ArrayList<RiskAssessmentPredictionComponent>();
1069          for (RiskAssessmentPredictionComponent i : prediction)
1070            dst.prediction.add(i.copy());
1071        };
1072        dst.mitigation = mitigation == null ? null : mitigation.copy();
1073        return dst;
1074      }
1075
1076      protected RiskAssessment typedCopy() {
1077        return copy();
1078      }
1079
1080      @Override
1081      public boolean equalsDeep(Base other) {
1082        if (!super.equalsDeep(other))
1083          return false;
1084        if (!(other instanceof RiskAssessment))
1085          return false;
1086        RiskAssessment o = (RiskAssessment) other;
1087        return compareDeep(subject, o.subject, true) && compareDeep(date, o.date, true) && compareDeep(condition, o.condition, true)
1088           && compareDeep(encounter, o.encounter, true) && compareDeep(performer, o.performer, true) && compareDeep(identifier, o.identifier, true)
1089           && compareDeep(method, o.method, true) && compareDeep(basis, o.basis, true) && compareDeep(prediction, o.prediction, true)
1090           && compareDeep(mitigation, o.mitigation, true);
1091      }
1092
1093      @Override
1094      public boolean equalsShallow(Base other) {
1095        if (!super.equalsShallow(other))
1096          return false;
1097        if (!(other instanceof RiskAssessment))
1098          return false;
1099        RiskAssessment o = (RiskAssessment) other;
1100        return compareValues(date, o.date, true) && compareValues(mitigation, o.mitigation, true);
1101      }
1102
1103      public boolean isEmpty() {
1104        return super.isEmpty() && (subject == null || subject.isEmpty()) && (date == null || date.isEmpty())
1105           && (condition == null || condition.isEmpty()) && (encounter == null || encounter.isEmpty())
1106           && (performer == null || performer.isEmpty()) && (identifier == null || identifier.isEmpty())
1107           && (method == null || method.isEmpty()) && (basis == null || basis.isEmpty()) && (prediction == null || prediction.isEmpty())
1108           && (mitigation == null || mitigation.isEmpty());
1109      }
1110
1111  @Override
1112  public ResourceType getResourceType() {
1113    return ResourceType.RiskAssessment;
1114   }
1115
1116  @SearchParamDefinition(name="date", path="RiskAssessment.date", description="When was assessment made?", type="date" )
1117  public static final String SP_DATE = "date";
1118  @SearchParamDefinition(name="identifier", path="RiskAssessment.identifier", description="Unique identifier for the assessment", type="token" )
1119  public static final String SP_IDENTIFIER = "identifier";
1120  @SearchParamDefinition(name="condition", path="RiskAssessment.condition", description="Condition assessed", type="reference" )
1121  public static final String SP_CONDITION = "condition";
1122  @SearchParamDefinition(name="performer", path="RiskAssessment.performer", description="Who did assessment?", type="reference" )
1123  public static final String SP_PERFORMER = "performer";
1124  @SearchParamDefinition(name="method", path="RiskAssessment.method", description="Evaluation mechanism", type="token" )
1125  public static final String SP_METHOD = "method";
1126  @SearchParamDefinition(name="subject", path="RiskAssessment.subject", description="Who/what does assessment apply to?", type="reference" )
1127  public static final String SP_SUBJECT = "subject";
1128  @SearchParamDefinition(name="patient", path="RiskAssessment.subject", description="Who/what does assessment apply to?", type="reference" )
1129  public static final String SP_PATIENT = "patient";
1130  @SearchParamDefinition(name="encounter", path="RiskAssessment.encounter", description="Where was assessment performed?", type="reference" )
1131  public static final String SP_ENCOUNTER = "encounter";
1132
1133}
1134