001package org.hl7.fhir.r4.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Thu, Sep 13, 2018 09:04-0400 for FHIR v3.5.0
033
034import java.util.*;
035
036import org.hl7.fhir.utilities.Utilities;
037import ca.uhn.fhir.model.api.annotation.ResourceDef;
038import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
039import ca.uhn.fhir.model.api.annotation.Child;
040import ca.uhn.fhir.model.api.annotation.ChildOrder;
041import ca.uhn.fhir.model.api.annotation.Description;
042import ca.uhn.fhir.model.api.annotation.Block;
043import org.hl7.fhir.instance.model.api.*;
044import org.hl7.fhir.exceptions.FHIRException;
045/**
046 * Describes the intended objective(s) for a patient, group or organization care, for example, weight loss, restoring an activity of daily living, obtaining herd immunity via immunization, meeting a process improvement objective, etc.
047 */
048@ResourceDef(name="Goal", profile="http://hl7.org/fhir/StructureDefinition/Goal")
049public class Goal extends DomainResource {
050
051    public enum GoalStatus {
052        /**
053         * A goal is proposed for this patient.
054         */
055        PROPOSED, 
056        /**
057         * A proposed goal was accepted or acknowledged.
058         */
059        ACCEPTED, 
060        /**
061         * A goal is planned for this patient.
062         */
063        PLANNED, 
064        /**
065         * The goal is being sought but has not yet been reached.  (Also applies if goal was reached in the past but there has been regression and goal is being sought again).
066         */
067        INPROGRESS, 
068        /**
069         * The goal is on schedule for the planned timelines.
070         */
071        ONTARGET, 
072        /**
073         * The goal is ahead of the planned timelines.
074         */
075        AHEADOFTARGET, 
076        /**
077         * The goal is behind the planned timelines.
078         */
079        BEHINDTARGET, 
080        /**
081         * The goal has been met, but ongoing activity is needed to sustain the goal objective.
082         */
083        SUSTAINING, 
084        /**
085         * The goal has been met and no further action is needed.
086         */
087        ACHIEVED, 
088        /**
089         * The goal remains a long term objective but is no longer being actively pursued for a temporary period of time.
090         */
091        ONHOLD, 
092        /**
093         * The previously accepted goal is no longer being sought.
094         */
095        CANCELLED, 
096        /**
097         * The goal was entered in error and voided.
098         */
099        ENTEREDINERROR, 
100        /**
101         * A proposed goal was rejected.
102         */
103        REJECTED, 
104        /**
105         * added to help the parsers with the generic types
106         */
107        NULL;
108        public static GoalStatus fromCode(String codeString) throws FHIRException {
109            if (codeString == null || "".equals(codeString))
110                return null;
111        if ("proposed".equals(codeString))
112          return PROPOSED;
113        if ("accepted".equals(codeString))
114          return ACCEPTED;
115        if ("planned".equals(codeString))
116          return PLANNED;
117        if ("in-progress".equals(codeString))
118          return INPROGRESS;
119        if ("on-target".equals(codeString))
120          return ONTARGET;
121        if ("ahead-of-target".equals(codeString))
122          return AHEADOFTARGET;
123        if ("behind-target".equals(codeString))
124          return BEHINDTARGET;
125        if ("sustaining".equals(codeString))
126          return SUSTAINING;
127        if ("achieved".equals(codeString))
128          return ACHIEVED;
129        if ("on-hold".equals(codeString))
130          return ONHOLD;
131        if ("cancelled".equals(codeString))
132          return CANCELLED;
133        if ("entered-in-error".equals(codeString))
134          return ENTEREDINERROR;
135        if ("rejected".equals(codeString))
136          return REJECTED;
137        if (Configuration.isAcceptInvalidEnums())
138          return null;
139        else
140          throw new FHIRException("Unknown GoalStatus code '"+codeString+"'");
141        }
142        public String toCode() {
143          switch (this) {
144            case PROPOSED: return "proposed";
145            case ACCEPTED: return "accepted";
146            case PLANNED: return "planned";
147            case INPROGRESS: return "in-progress";
148            case ONTARGET: return "on-target";
149            case AHEADOFTARGET: return "ahead-of-target";
150            case BEHINDTARGET: return "behind-target";
151            case SUSTAINING: return "sustaining";
152            case ACHIEVED: return "achieved";
153            case ONHOLD: return "on-hold";
154            case CANCELLED: return "cancelled";
155            case ENTEREDINERROR: return "entered-in-error";
156            case REJECTED: return "rejected";
157            default: return "?";
158          }
159        }
160        public String getSystem() {
161          switch (this) {
162            case PROPOSED: return "http://hl7.org/fhir/goal-status";
163            case ACCEPTED: return "http://hl7.org/fhir/goal-status";
164            case PLANNED: return "http://hl7.org/fhir/goal-status";
165            case INPROGRESS: return "http://hl7.org/fhir/goal-status";
166            case ONTARGET: return "http://hl7.org/fhir/goal-status";
167            case AHEADOFTARGET: return "http://hl7.org/fhir/goal-status";
168            case BEHINDTARGET: return "http://hl7.org/fhir/goal-status";
169            case SUSTAINING: return "http://hl7.org/fhir/goal-status";
170            case ACHIEVED: return "http://hl7.org/fhir/goal-status";
171            case ONHOLD: return "http://hl7.org/fhir/goal-status";
172            case CANCELLED: return "http://hl7.org/fhir/goal-status";
173            case ENTEREDINERROR: return "http://hl7.org/fhir/goal-status";
174            case REJECTED: return "http://hl7.org/fhir/goal-status";
175            default: return "?";
176          }
177        }
178        public String getDefinition() {
179          switch (this) {
180            case PROPOSED: return "A goal is proposed for this patient.";
181            case ACCEPTED: return "A proposed goal was accepted or acknowledged.";
182            case PLANNED: return "A goal is planned for this patient.";
183            case INPROGRESS: return "The goal is being sought but has not yet been reached.  (Also applies if goal was reached in the past but there has been regression and goal is being sought again).";
184            case ONTARGET: return "The goal is on schedule for the planned timelines.";
185            case AHEADOFTARGET: return "The goal is ahead of the planned timelines.";
186            case BEHINDTARGET: return "The goal is behind the planned timelines.";
187            case SUSTAINING: return "The goal has been met, but ongoing activity is needed to sustain the goal objective.";
188            case ACHIEVED: return "The goal has been met and no further action is needed.";
189            case ONHOLD: return "The goal remains a long term objective but is no longer being actively pursued for a temporary period of time.";
190            case CANCELLED: return "The previously accepted goal is no longer being sought.";
191            case ENTEREDINERROR: return "The goal was entered in error and voided.";
192            case REJECTED: return "A proposed goal was rejected.";
193            default: return "?";
194          }
195        }
196        public String getDisplay() {
197          switch (this) {
198            case PROPOSED: return "Proposed";
199            case ACCEPTED: return "Accepted";
200            case PLANNED: return "Planned";
201            case INPROGRESS: return "In Progress";
202            case ONTARGET: return "On Target";
203            case AHEADOFTARGET: return "Ahead of Target";
204            case BEHINDTARGET: return "Behind Target";
205            case SUSTAINING: return "Sustaining";
206            case ACHIEVED: return "Achieved";
207            case ONHOLD: return "On Hold";
208            case CANCELLED: return "Cancelled";
209            case ENTEREDINERROR: return "Entered In Error";
210            case REJECTED: return "Rejected";
211            default: return "?";
212          }
213        }
214    }
215
216  public static class GoalStatusEnumFactory implements EnumFactory<GoalStatus> {
217    public GoalStatus fromCode(String codeString) throws IllegalArgumentException {
218      if (codeString == null || "".equals(codeString))
219            if (codeString == null || "".equals(codeString))
220                return null;
221        if ("proposed".equals(codeString))
222          return GoalStatus.PROPOSED;
223        if ("accepted".equals(codeString))
224          return GoalStatus.ACCEPTED;
225        if ("planned".equals(codeString))
226          return GoalStatus.PLANNED;
227        if ("in-progress".equals(codeString))
228          return GoalStatus.INPROGRESS;
229        if ("on-target".equals(codeString))
230          return GoalStatus.ONTARGET;
231        if ("ahead-of-target".equals(codeString))
232          return GoalStatus.AHEADOFTARGET;
233        if ("behind-target".equals(codeString))
234          return GoalStatus.BEHINDTARGET;
235        if ("sustaining".equals(codeString))
236          return GoalStatus.SUSTAINING;
237        if ("achieved".equals(codeString))
238          return GoalStatus.ACHIEVED;
239        if ("on-hold".equals(codeString))
240          return GoalStatus.ONHOLD;
241        if ("cancelled".equals(codeString))
242          return GoalStatus.CANCELLED;
243        if ("entered-in-error".equals(codeString))
244          return GoalStatus.ENTEREDINERROR;
245        if ("rejected".equals(codeString))
246          return GoalStatus.REJECTED;
247        throw new IllegalArgumentException("Unknown GoalStatus code '"+codeString+"'");
248        }
249        public Enumeration<GoalStatus> fromType(Base code) throws FHIRException {
250          if (code == null)
251            return null;
252          if (code.isEmpty())
253            return new Enumeration<GoalStatus>(this);
254          String codeString = ((PrimitiveType) code).asStringValue();
255          if (codeString == null || "".equals(codeString))
256            return null;
257        if ("proposed".equals(codeString))
258          return new Enumeration<GoalStatus>(this, GoalStatus.PROPOSED);
259        if ("accepted".equals(codeString))
260          return new Enumeration<GoalStatus>(this, GoalStatus.ACCEPTED);
261        if ("planned".equals(codeString))
262          return new Enumeration<GoalStatus>(this, GoalStatus.PLANNED);
263        if ("in-progress".equals(codeString))
264          return new Enumeration<GoalStatus>(this, GoalStatus.INPROGRESS);
265        if ("on-target".equals(codeString))
266          return new Enumeration<GoalStatus>(this, GoalStatus.ONTARGET);
267        if ("ahead-of-target".equals(codeString))
268          return new Enumeration<GoalStatus>(this, GoalStatus.AHEADOFTARGET);
269        if ("behind-target".equals(codeString))
270          return new Enumeration<GoalStatus>(this, GoalStatus.BEHINDTARGET);
271        if ("sustaining".equals(codeString))
272          return new Enumeration<GoalStatus>(this, GoalStatus.SUSTAINING);
273        if ("achieved".equals(codeString))
274          return new Enumeration<GoalStatus>(this, GoalStatus.ACHIEVED);
275        if ("on-hold".equals(codeString))
276          return new Enumeration<GoalStatus>(this, GoalStatus.ONHOLD);
277        if ("cancelled".equals(codeString))
278          return new Enumeration<GoalStatus>(this, GoalStatus.CANCELLED);
279        if ("entered-in-error".equals(codeString))
280          return new Enumeration<GoalStatus>(this, GoalStatus.ENTEREDINERROR);
281        if ("rejected".equals(codeString))
282          return new Enumeration<GoalStatus>(this, GoalStatus.REJECTED);
283        throw new FHIRException("Unknown GoalStatus code '"+codeString+"'");
284        }
285    public String toCode(GoalStatus code) {
286      if (code == GoalStatus.PROPOSED)
287        return "proposed";
288      if (code == GoalStatus.ACCEPTED)
289        return "accepted";
290      if (code == GoalStatus.PLANNED)
291        return "planned";
292      if (code == GoalStatus.INPROGRESS)
293        return "in-progress";
294      if (code == GoalStatus.ONTARGET)
295        return "on-target";
296      if (code == GoalStatus.AHEADOFTARGET)
297        return "ahead-of-target";
298      if (code == GoalStatus.BEHINDTARGET)
299        return "behind-target";
300      if (code == GoalStatus.SUSTAINING)
301        return "sustaining";
302      if (code == GoalStatus.ACHIEVED)
303        return "achieved";
304      if (code == GoalStatus.ONHOLD)
305        return "on-hold";
306      if (code == GoalStatus.CANCELLED)
307        return "cancelled";
308      if (code == GoalStatus.ENTEREDINERROR)
309        return "entered-in-error";
310      if (code == GoalStatus.REJECTED)
311        return "rejected";
312      return "?";
313      }
314    public String toSystem(GoalStatus code) {
315      return code.getSystem();
316      }
317    }
318
319    @Block()
320    public static class GoalTargetComponent extends BackboneElement implements IBaseBackboneElement {
321        /**
322         * The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level.
323         */
324        @Child(name = "measure", type = {CodeableConcept.class}, order=1, min=0, max=1, modifier=false, summary=true)
325        @Description(shortDefinition="The parameter whose value is being tracked", formalDefinition="The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level." )
326        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/observation-codes")
327        protected CodeableConcept measure;
328
329        /**
330         * The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.
331         */
332        @Child(name = "detail", type = {Quantity.class, Range.class, CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
333        @Description(shortDefinition="The target value to be achieved", formalDefinition="The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value." )
334        protected Type detail;
335
336        /**
337         * Indicates either the date or the duration after start by which the goal should be met.
338         */
339        @Child(name = "due", type = {DateType.class, Duration.class}, order=3, min=0, max=1, modifier=false, summary=true)
340        @Description(shortDefinition="Reach goal on or before", formalDefinition="Indicates either the date or the duration after start by which the goal should be met." )
341        protected Type due;
342
343        private static final long serialVersionUID = -585108934L;
344
345    /**
346     * Constructor
347     */
348      public GoalTargetComponent() {
349        super();
350      }
351
352        /**
353         * @return {@link #measure} (The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level.)
354         */
355        public CodeableConcept getMeasure() { 
356          if (this.measure == null)
357            if (Configuration.errorOnAutoCreate())
358              throw new Error("Attempt to auto-create GoalTargetComponent.measure");
359            else if (Configuration.doAutoCreate())
360              this.measure = new CodeableConcept(); // cc
361          return this.measure;
362        }
363
364        public boolean hasMeasure() { 
365          return this.measure != null && !this.measure.isEmpty();
366        }
367
368        /**
369         * @param value {@link #measure} (The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level.)
370         */
371        public GoalTargetComponent setMeasure(CodeableConcept value) { 
372          this.measure = value;
373          return this;
374        }
375
376        /**
377         * @return {@link #detail} (The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.)
378         */
379        public Type getDetail() { 
380          return this.detail;
381        }
382
383        /**
384         * @return {@link #detail} (The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.)
385         */
386        public Quantity getDetailQuantity() throws FHIRException { 
387          if (this.detail == null)
388            return null;
389          if (!(this.detail instanceof Quantity))
390            throw new FHIRException("Type mismatch: the type Quantity was expected, but "+this.detail.getClass().getName()+" was encountered");
391          return (Quantity) this.detail;
392        }
393
394        public boolean hasDetailQuantity() { 
395          return this != null && this.detail instanceof Quantity;
396        }
397
398        /**
399         * @return {@link #detail} (The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.)
400         */
401        public Range getDetailRange() throws FHIRException { 
402          if (this.detail == null)
403            return null;
404          if (!(this.detail instanceof Range))
405            throw new FHIRException("Type mismatch: the type Range was expected, but "+this.detail.getClass().getName()+" was encountered");
406          return (Range) this.detail;
407        }
408
409        public boolean hasDetailRange() { 
410          return this != null && this.detail instanceof Range;
411        }
412
413        /**
414         * @return {@link #detail} (The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.)
415         */
416        public CodeableConcept getDetailCodeableConcept() throws FHIRException { 
417          if (this.detail == null)
418            return null;
419          if (!(this.detail instanceof CodeableConcept))
420            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.detail.getClass().getName()+" was encountered");
421          return (CodeableConcept) this.detail;
422        }
423
424        public boolean hasDetailCodeableConcept() { 
425          return this != null && this.detail instanceof CodeableConcept;
426        }
427
428        public boolean hasDetail() { 
429          return this.detail != null && !this.detail.isEmpty();
430        }
431
432        /**
433         * @param value {@link #detail} (The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.)
434         */
435        public GoalTargetComponent setDetail(Type value) { 
436          if (value != null && !(value instanceof Quantity || value instanceof Range || value instanceof CodeableConcept))
437            throw new Error("Not the right type for Goal.target.detail[x]: "+value.fhirType());
438          this.detail = value;
439          return this;
440        }
441
442        /**
443         * @return {@link #due} (Indicates either the date or the duration after start by which the goal should be met.)
444         */
445        public Type getDue() { 
446          return this.due;
447        }
448
449        /**
450         * @return {@link #due} (Indicates either the date or the duration after start by which the goal should be met.)
451         */
452        public DateType getDueDateType() throws FHIRException { 
453          if (this.due == null)
454            return null;
455          if (!(this.due instanceof DateType))
456            throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.due.getClass().getName()+" was encountered");
457          return (DateType) this.due;
458        }
459
460        public boolean hasDueDateType() { 
461          return this != null && this.due instanceof DateType;
462        }
463
464        /**
465         * @return {@link #due} (Indicates either the date or the duration after start by which the goal should be met.)
466         */
467        public Duration getDueDuration() throws FHIRException { 
468          if (this.due == null)
469            return null;
470          if (!(this.due instanceof Duration))
471            throw new FHIRException("Type mismatch: the type Duration was expected, but "+this.due.getClass().getName()+" was encountered");
472          return (Duration) this.due;
473        }
474
475        public boolean hasDueDuration() { 
476          return this != null && this.due instanceof Duration;
477        }
478
479        public boolean hasDue() { 
480          return this.due != null && !this.due.isEmpty();
481        }
482
483        /**
484         * @param value {@link #due} (Indicates either the date or the duration after start by which the goal should be met.)
485         */
486        public GoalTargetComponent setDue(Type value) { 
487          if (value != null && !(value instanceof DateType || value instanceof Duration))
488            throw new Error("Not the right type for Goal.target.due[x]: "+value.fhirType());
489          this.due = value;
490          return this;
491        }
492
493        protected void listChildren(List<Property> children) {
494          super.listChildren(children);
495          children.add(new Property("measure", "CodeableConcept", "The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level.", 0, 1, measure));
496          children.add(new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail));
497          children.add(new Property("due[x]", "date|Duration", "Indicates either the date or the duration after start by which the goal should be met.", 0, 1, due));
498        }
499
500        @Override
501        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
502          switch (_hash) {
503          case 938321246: /*measure*/  return new Property("measure", "CodeableConcept", "The parameter whose value is being tracked, e.g. body weight, blood pressure, or hemoglobin A1c level.", 0, 1, measure);
504          case -1973084529: /*detail[x]*/  return new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail);
505          case -1335224239: /*detail*/  return new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail);
506          case -1313079300: /*detailQuantity*/  return new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail);
507          case -2062632084: /*detailRange*/  return new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail);
508          case -175586544: /*detailCodeableConcept*/  return new Property("detail[x]", "Quantity|Range|CodeableConcept", "The target value of the focus to be achieved to signify the fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low or both values of the range can be specified. When a low value is missing, it indicates that the goal is achieved at any focus value at or below the high value. Similarly, if the high value is missing, it indicates that the goal is achieved at any focus value at or above the low value.", 0, 1, detail);
509          case -1320900084: /*due[x]*/  return new Property("due[x]", "date|Duration", "Indicates either the date or the duration after start by which the goal should be met.", 0, 1, due);
510          case 99828: /*due*/  return new Property("due[x]", "date|Duration", "Indicates either the date or the duration after start by which the goal should be met.", 0, 1, due);
511          case 2001063874: /*dueDate*/  return new Property("due[x]", "date|Duration", "Indicates either the date or the duration after start by which the goal should be met.", 0, 1, due);
512          case -620428376: /*dueDuration*/  return new Property("due[x]", "date|Duration", "Indicates either the date or the duration after start by which the goal should be met.", 0, 1, due);
513          default: return super.getNamedProperty(_hash, _name, _checkValid);
514          }
515
516        }
517
518      @Override
519      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
520        switch (hash) {
521        case 938321246: /*measure*/ return this.measure == null ? new Base[0] : new Base[] {this.measure}; // CodeableConcept
522        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : new Base[] {this.detail}; // Type
523        case 99828: /*due*/ return this.due == null ? new Base[0] : new Base[] {this.due}; // Type
524        default: return super.getProperty(hash, name, checkValid);
525        }
526
527      }
528
529      @Override
530      public Base setProperty(int hash, String name, Base value) throws FHIRException {
531        switch (hash) {
532        case 938321246: // measure
533          this.measure = castToCodeableConcept(value); // CodeableConcept
534          return value;
535        case -1335224239: // detail
536          this.detail = castToType(value); // Type
537          return value;
538        case 99828: // due
539          this.due = castToType(value); // Type
540          return value;
541        default: return super.setProperty(hash, name, value);
542        }
543
544      }
545
546      @Override
547      public Base setProperty(String name, Base value) throws FHIRException {
548        if (name.equals("measure")) {
549          this.measure = castToCodeableConcept(value); // CodeableConcept
550        } else if (name.equals("detail[x]")) {
551          this.detail = castToType(value); // Type
552        } else if (name.equals("due[x]")) {
553          this.due = castToType(value); // Type
554        } else
555          return super.setProperty(name, value);
556        return value;
557      }
558
559      @Override
560      public Base makeProperty(int hash, String name) throws FHIRException {
561        switch (hash) {
562        case 938321246:  return getMeasure(); 
563        case -1973084529:  return getDetail(); 
564        case -1335224239:  return getDetail(); 
565        case -1320900084:  return getDue(); 
566        case 99828:  return getDue(); 
567        default: return super.makeProperty(hash, name);
568        }
569
570      }
571
572      @Override
573      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
574        switch (hash) {
575        case 938321246: /*measure*/ return new String[] {"CodeableConcept"};
576        case -1335224239: /*detail*/ return new String[] {"Quantity", "Range", "CodeableConcept"};
577        case 99828: /*due*/ return new String[] {"date", "Duration"};
578        default: return super.getTypesForProperty(hash, name);
579        }
580
581      }
582
583      @Override
584      public Base addChild(String name) throws FHIRException {
585        if (name.equals("measure")) {
586          this.measure = new CodeableConcept();
587          return this.measure;
588        }
589        else if (name.equals("detailQuantity")) {
590          this.detail = new Quantity();
591          return this.detail;
592        }
593        else if (name.equals("detailRange")) {
594          this.detail = new Range();
595          return this.detail;
596        }
597        else if (name.equals("detailCodeableConcept")) {
598          this.detail = new CodeableConcept();
599          return this.detail;
600        }
601        else if (name.equals("dueDate")) {
602          this.due = new DateType();
603          return this.due;
604        }
605        else if (name.equals("dueDuration")) {
606          this.due = new Duration();
607          return this.due;
608        }
609        else
610          return super.addChild(name);
611      }
612
613      public GoalTargetComponent copy() {
614        GoalTargetComponent dst = new GoalTargetComponent();
615        copyValues(dst);
616        dst.measure = measure == null ? null : measure.copy();
617        dst.detail = detail == null ? null : detail.copy();
618        dst.due = due == null ? null : due.copy();
619        return dst;
620      }
621
622      @Override
623      public boolean equalsDeep(Base other_) {
624        if (!super.equalsDeep(other_))
625          return false;
626        if (!(other_ instanceof GoalTargetComponent))
627          return false;
628        GoalTargetComponent o = (GoalTargetComponent) other_;
629        return compareDeep(measure, o.measure, true) && compareDeep(detail, o.detail, true) && compareDeep(due, o.due, true)
630          ;
631      }
632
633      @Override
634      public boolean equalsShallow(Base other_) {
635        if (!super.equalsShallow(other_))
636          return false;
637        if (!(other_ instanceof GoalTargetComponent))
638          return false;
639        GoalTargetComponent o = (GoalTargetComponent) other_;
640        return true;
641      }
642
643      public boolean isEmpty() {
644        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(measure, detail, due);
645      }
646
647  public String fhirType() {
648    return "Goal.target";
649
650  }
651
652  }
653
654    /**
655     * Business identifiers assigned to this goal by the performer or other systems which remain constant as the resource is updated and propagates from server to server.
656     */
657    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
658    @Description(shortDefinition="External Ids for this goal", formalDefinition="Business identifiers assigned to this goal by the performer or other systems which remain constant as the resource is updated and propagates from server to server." )
659    protected List<Identifier> identifier;
660
661    /**
662     * Indicates whether the goal has been reached and is still considered relevant.
663     */
664    @Child(name = "status", type = {CodeType.class}, order=1, min=1, max=1, modifier=true, summary=true)
665    @Description(shortDefinition="proposed | accepted | planned | in-progress | on-target | ahead-of-target | behind-target | sustaining | achieved | on-hold | cancelled | entered-in-error | rejected", formalDefinition="Indicates whether the goal has been reached and is still considered relevant." )
666    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/goal-status")
667    protected Enumeration<GoalStatus> status;
668
669    /**
670     * Indicates a category the goal falls within.
671     */
672    @Child(name = "category", type = {CodeableConcept.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
673    @Description(shortDefinition="E.g. Treatment, dietary, behavioral, etc.", formalDefinition="Indicates a category the goal falls within." )
674    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/goal-category")
675    protected List<CodeableConcept> category;
676
677    /**
678     * Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.
679     */
680    @Child(name = "priority", type = {CodeableConcept.class}, order=3, min=0, max=1, modifier=false, summary=true)
681    @Description(shortDefinition="high-priority | medium-priority | low-priority", formalDefinition="Identifies the mutually agreed level of importance associated with reaching/sustaining the goal." )
682    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/goal-priority")
683    protected CodeableConcept priority;
684
685    /**
686     * Human-readable and/or coded description of a specific desired objective of care, such as "control blood pressure" or "negotiate an obstacle course" or "dance with child at wedding".
687     */
688    @Child(name = "description", type = {CodeableConcept.class}, order=4, min=1, max=1, modifier=false, summary=true)
689    @Description(shortDefinition="Code or text describing goal", formalDefinition="Human-readable and/or coded description of a specific desired objective of care, such as \"control blood pressure\" or \"negotiate an obstacle course\" or \"dance with child at wedding\"." )
690    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
691    protected CodeableConcept description;
692
693    /**
694     * Identifies the patient, group or organization for whom the goal is being established.
695     */
696    @Child(name = "subject", type = {Patient.class, Group.class, Organization.class}, order=5, min=1, max=1, modifier=false, summary=true)
697    @Description(shortDefinition="Who this goal is intended for", formalDefinition="Identifies the patient, group or organization for whom the goal is being established." )
698    protected Reference subject;
699
700    /**
701     * The actual object that is the target of the reference (Identifies the patient, group or organization for whom the goal is being established.)
702     */
703    protected Resource subjectTarget;
704
705    /**
706     * The date or event after which the goal should begin being pursued.
707     */
708    @Child(name = "start", type = {DateType.class, CodeableConcept.class}, order=6, min=0, max=1, modifier=false, summary=true)
709    @Description(shortDefinition="When goal pursuit begins", formalDefinition="The date or event after which the goal should begin being pursued." )
710    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/goal-start-event")
711    protected Type start;
712
713    /**
714     * Indicates what should be done by when.
715     */
716    @Child(name = "target", type = {}, order=7, min=0, max=1, modifier=false, summary=false)
717    @Description(shortDefinition="Target outcome for the goal", formalDefinition="Indicates what should be done by when." )
718    protected GoalTargetComponent target;
719
720    /**
721     * Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.
722     */
723    @Child(name = "statusDate", type = {DateType.class}, order=8, min=0, max=1, modifier=false, summary=true)
724    @Description(shortDefinition="When goal status took effect", formalDefinition="Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc." )
725    protected DateType statusDate;
726
727    /**
728     * Captures the reason for the current status.
729     */
730    @Child(name = "statusReason", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=false)
731    @Description(shortDefinition="Reason for current status", formalDefinition="Captures the reason for the current status." )
732    protected StringType statusReason;
733
734    /**
735     * Indicates whose goal this is - patient goal, practitioner goal, etc.
736     */
737    @Child(name = "expressedBy", type = {Patient.class, Practitioner.class, RelatedPerson.class}, order=10, min=0, max=1, modifier=false, summary=true)
738    @Description(shortDefinition="Who's responsible for creating Goal?", formalDefinition="Indicates whose goal this is - patient goal, practitioner goal, etc." )
739    protected Reference expressedBy;
740
741    /**
742     * The actual object that is the target of the reference (Indicates whose goal this is - patient goal, practitioner goal, etc.)
743     */
744    protected Resource expressedByTarget;
745
746    /**
747     * The identified conditions and other health record elements that are intended to be addressed by the goal.
748     */
749    @Child(name = "addresses", type = {Condition.class, Observation.class, MedicationStatement.class, NutritionOrder.class, ServiceRequest.class, RiskAssessment.class}, order=11, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
750    @Description(shortDefinition="Issues addressed by this goal", formalDefinition="The identified conditions and other health record elements that are intended to be addressed by the goal." )
751    protected List<Reference> addresses;
752    /**
753     * The actual objects that are the target of the reference (The identified conditions and other health record elements that are intended to be addressed by the goal.)
754     */
755    protected List<Resource> addressesTarget;
756
757
758    /**
759     * Any comments related to the goal.
760     */
761    @Child(name = "note", type = {Annotation.class}, order=12, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
762    @Description(shortDefinition="Comments about the goal", formalDefinition="Any comments related to the goal." )
763    protected List<Annotation> note;
764
765    /**
766     * Identifies the change (or lack of change) at the point when the status of the goal is assessed.
767     */
768    @Child(name = "outcomeCode", type = {CodeableConcept.class}, order=13, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
769    @Description(shortDefinition="What result was achieved regarding the goal?", formalDefinition="Identifies the change (or lack of change) at the point when the status of the goal is assessed." )
770    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
771    protected List<CodeableConcept> outcomeCode;
772
773    /**
774     * Details of what's changed (or not changed).
775     */
776    @Child(name = "outcomeReference", type = {Observation.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
777    @Description(shortDefinition="Observation that resulted from goal", formalDefinition="Details of what's changed (or not changed)." )
778    protected List<Reference> outcomeReference;
779    /**
780     * The actual objects that are the target of the reference (Details of what's changed (or not changed).)
781     */
782    protected List<Observation> outcomeReferenceTarget;
783
784
785    private static final long serialVersionUID = -1045412647L;
786
787  /**
788   * Constructor
789   */
790    public Goal() {
791      super();
792    }
793
794  /**
795   * Constructor
796   */
797    public Goal(Enumeration<GoalStatus> status, CodeableConcept description, Reference subject) {
798      super();
799      this.status = status;
800      this.description = description;
801      this.subject = subject;
802    }
803
804    /**
805     * @return {@link #identifier} (Business identifiers assigned to this goal by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
806     */
807    public List<Identifier> getIdentifier() { 
808      if (this.identifier == null)
809        this.identifier = new ArrayList<Identifier>();
810      return this.identifier;
811    }
812
813    /**
814     * @return Returns a reference to <code>this</code> for easy method chaining
815     */
816    public Goal setIdentifier(List<Identifier> theIdentifier) { 
817      this.identifier = theIdentifier;
818      return this;
819    }
820
821    public boolean hasIdentifier() { 
822      if (this.identifier == null)
823        return false;
824      for (Identifier item : this.identifier)
825        if (!item.isEmpty())
826          return true;
827      return false;
828    }
829
830    public Identifier addIdentifier() { //3
831      Identifier t = new Identifier();
832      if (this.identifier == null)
833        this.identifier = new ArrayList<Identifier>();
834      this.identifier.add(t);
835      return t;
836    }
837
838    public Goal addIdentifier(Identifier t) { //3
839      if (t == null)
840        return this;
841      if (this.identifier == null)
842        this.identifier = new ArrayList<Identifier>();
843      this.identifier.add(t);
844      return this;
845    }
846
847    /**
848     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
849     */
850    public Identifier getIdentifierFirstRep() { 
851      if (getIdentifier().isEmpty()) {
852        addIdentifier();
853      }
854      return getIdentifier().get(0);
855    }
856
857    /**
858     * @return {@link #status} (Indicates whether the goal has been reached and is still considered relevant.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
859     */
860    public Enumeration<GoalStatus> getStatusElement() { 
861      if (this.status == null)
862        if (Configuration.errorOnAutoCreate())
863          throw new Error("Attempt to auto-create Goal.status");
864        else if (Configuration.doAutoCreate())
865          this.status = new Enumeration<GoalStatus>(new GoalStatusEnumFactory()); // bb
866      return this.status;
867    }
868
869    public boolean hasStatusElement() { 
870      return this.status != null && !this.status.isEmpty();
871    }
872
873    public boolean hasStatus() { 
874      return this.status != null && !this.status.isEmpty();
875    }
876
877    /**
878     * @param value {@link #status} (Indicates whether the goal has been reached and is still considered relevant.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
879     */
880    public Goal setStatusElement(Enumeration<GoalStatus> value) { 
881      this.status = value;
882      return this;
883    }
884
885    /**
886     * @return Indicates whether the goal has been reached and is still considered relevant.
887     */
888    public GoalStatus getStatus() { 
889      return this.status == null ? null : this.status.getValue();
890    }
891
892    /**
893     * @param value Indicates whether the goal has been reached and is still considered relevant.
894     */
895    public Goal setStatus(GoalStatus value) { 
896        if (this.status == null)
897          this.status = new Enumeration<GoalStatus>(new GoalStatusEnumFactory());
898        this.status.setValue(value);
899      return this;
900    }
901
902    /**
903     * @return {@link #category} (Indicates a category the goal falls within.)
904     */
905    public List<CodeableConcept> getCategory() { 
906      if (this.category == null)
907        this.category = new ArrayList<CodeableConcept>();
908      return this.category;
909    }
910
911    /**
912     * @return Returns a reference to <code>this</code> for easy method chaining
913     */
914    public Goal setCategory(List<CodeableConcept> theCategory) { 
915      this.category = theCategory;
916      return this;
917    }
918
919    public boolean hasCategory() { 
920      if (this.category == null)
921        return false;
922      for (CodeableConcept item : this.category)
923        if (!item.isEmpty())
924          return true;
925      return false;
926    }
927
928    public CodeableConcept addCategory() { //3
929      CodeableConcept t = new CodeableConcept();
930      if (this.category == null)
931        this.category = new ArrayList<CodeableConcept>();
932      this.category.add(t);
933      return t;
934    }
935
936    public Goal addCategory(CodeableConcept t) { //3
937      if (t == null)
938        return this;
939      if (this.category == null)
940        this.category = new ArrayList<CodeableConcept>();
941      this.category.add(t);
942      return this;
943    }
944
945    /**
946     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
947     */
948    public CodeableConcept getCategoryFirstRep() { 
949      if (getCategory().isEmpty()) {
950        addCategory();
951      }
952      return getCategory().get(0);
953    }
954
955    /**
956     * @return {@link #priority} (Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.)
957     */
958    public CodeableConcept getPriority() { 
959      if (this.priority == null)
960        if (Configuration.errorOnAutoCreate())
961          throw new Error("Attempt to auto-create Goal.priority");
962        else if (Configuration.doAutoCreate())
963          this.priority = new CodeableConcept(); // cc
964      return this.priority;
965    }
966
967    public boolean hasPriority() { 
968      return this.priority != null && !this.priority.isEmpty();
969    }
970
971    /**
972     * @param value {@link #priority} (Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.)
973     */
974    public Goal setPriority(CodeableConcept value) { 
975      this.priority = value;
976      return this;
977    }
978
979    /**
980     * @return {@link #description} (Human-readable and/or coded description of a specific desired objective of care, such as "control blood pressure" or "negotiate an obstacle course" or "dance with child at wedding".)
981     */
982    public CodeableConcept getDescription() { 
983      if (this.description == null)
984        if (Configuration.errorOnAutoCreate())
985          throw new Error("Attempt to auto-create Goal.description");
986        else if (Configuration.doAutoCreate())
987          this.description = new CodeableConcept(); // cc
988      return this.description;
989    }
990
991    public boolean hasDescription() { 
992      return this.description != null && !this.description.isEmpty();
993    }
994
995    /**
996     * @param value {@link #description} (Human-readable and/or coded description of a specific desired objective of care, such as "control blood pressure" or "negotiate an obstacle course" or "dance with child at wedding".)
997     */
998    public Goal setDescription(CodeableConcept value) { 
999      this.description = value;
1000      return this;
1001    }
1002
1003    /**
1004     * @return {@link #subject} (Identifies the patient, group or organization for whom the goal is being established.)
1005     */
1006    public Reference getSubject() { 
1007      if (this.subject == null)
1008        if (Configuration.errorOnAutoCreate())
1009          throw new Error("Attempt to auto-create Goal.subject");
1010        else if (Configuration.doAutoCreate())
1011          this.subject = new Reference(); // cc
1012      return this.subject;
1013    }
1014
1015    public boolean hasSubject() { 
1016      return this.subject != null && !this.subject.isEmpty();
1017    }
1018
1019    /**
1020     * @param value {@link #subject} (Identifies the patient, group or organization for whom the goal is being established.)
1021     */
1022    public Goal setSubject(Reference value) { 
1023      this.subject = value;
1024      return this;
1025    }
1026
1027    /**
1028     * @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. (Identifies the patient, group or organization for whom the goal is being established.)
1029     */
1030    public Resource getSubjectTarget() { 
1031      return this.subjectTarget;
1032    }
1033
1034    /**
1035     * @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. (Identifies the patient, group or organization for whom the goal is being established.)
1036     */
1037    public Goal setSubjectTarget(Resource value) { 
1038      this.subjectTarget = value;
1039      return this;
1040    }
1041
1042    /**
1043     * @return {@link #start} (The date or event after which the goal should begin being pursued.)
1044     */
1045    public Type getStart() { 
1046      return this.start;
1047    }
1048
1049    /**
1050     * @return {@link #start} (The date or event after which the goal should begin being pursued.)
1051     */
1052    public DateType getStartDateType() throws FHIRException { 
1053      if (this.start == null)
1054        return null;
1055      if (!(this.start instanceof DateType))
1056        throw new FHIRException("Type mismatch: the type DateType was expected, but "+this.start.getClass().getName()+" was encountered");
1057      return (DateType) this.start;
1058    }
1059
1060    public boolean hasStartDateType() { 
1061      return this != null && this.start instanceof DateType;
1062    }
1063
1064    /**
1065     * @return {@link #start} (The date or event after which the goal should begin being pursued.)
1066     */
1067    public CodeableConcept getStartCodeableConcept() throws FHIRException { 
1068      if (this.start == null)
1069        return null;
1070      if (!(this.start instanceof CodeableConcept))
1071        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.start.getClass().getName()+" was encountered");
1072      return (CodeableConcept) this.start;
1073    }
1074
1075    public boolean hasStartCodeableConcept() { 
1076      return this != null && this.start instanceof CodeableConcept;
1077    }
1078
1079    public boolean hasStart() { 
1080      return this.start != null && !this.start.isEmpty();
1081    }
1082
1083    /**
1084     * @param value {@link #start} (The date or event after which the goal should begin being pursued.)
1085     */
1086    public Goal setStart(Type value) { 
1087      if (value != null && !(value instanceof DateType || value instanceof CodeableConcept))
1088        throw new Error("Not the right type for Goal.start[x]: "+value.fhirType());
1089      this.start = value;
1090      return this;
1091    }
1092
1093    /**
1094     * @return {@link #target} (Indicates what should be done by when.)
1095     */
1096    public GoalTargetComponent getTarget() { 
1097      if (this.target == null)
1098        if (Configuration.errorOnAutoCreate())
1099          throw new Error("Attempt to auto-create Goal.target");
1100        else if (Configuration.doAutoCreate())
1101          this.target = new GoalTargetComponent(); // cc
1102      return this.target;
1103    }
1104
1105    public boolean hasTarget() { 
1106      return this.target != null && !this.target.isEmpty();
1107    }
1108
1109    /**
1110     * @param value {@link #target} (Indicates what should be done by when.)
1111     */
1112    public Goal setTarget(GoalTargetComponent value) { 
1113      this.target = value;
1114      return this;
1115    }
1116
1117    /**
1118     * @return {@link #statusDate} (Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
1119     */
1120    public DateType getStatusDateElement() { 
1121      if (this.statusDate == null)
1122        if (Configuration.errorOnAutoCreate())
1123          throw new Error("Attempt to auto-create Goal.statusDate");
1124        else if (Configuration.doAutoCreate())
1125          this.statusDate = new DateType(); // bb
1126      return this.statusDate;
1127    }
1128
1129    public boolean hasStatusDateElement() { 
1130      return this.statusDate != null && !this.statusDate.isEmpty();
1131    }
1132
1133    public boolean hasStatusDate() { 
1134      return this.statusDate != null && !this.statusDate.isEmpty();
1135    }
1136
1137    /**
1138     * @param value {@link #statusDate} (Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.). This is the underlying object with id, value and extensions. The accessor "getStatusDate" gives direct access to the value
1139     */
1140    public Goal setStatusDateElement(DateType value) { 
1141      this.statusDate = value;
1142      return this;
1143    }
1144
1145    /**
1146     * @return Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.
1147     */
1148    public Date getStatusDate() { 
1149      return this.statusDate == null ? null : this.statusDate.getValue();
1150    }
1151
1152    /**
1153     * @param value Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.
1154     */
1155    public Goal setStatusDate(Date value) { 
1156      if (value == null)
1157        this.statusDate = null;
1158      else {
1159        if (this.statusDate == null)
1160          this.statusDate = new DateType();
1161        this.statusDate.setValue(value);
1162      }
1163      return this;
1164    }
1165
1166    /**
1167     * @return {@link #statusReason} (Captures the reason for the current status.). This is the underlying object with id, value and extensions. The accessor "getStatusReason" gives direct access to the value
1168     */
1169    public StringType getStatusReasonElement() { 
1170      if (this.statusReason == null)
1171        if (Configuration.errorOnAutoCreate())
1172          throw new Error("Attempt to auto-create Goal.statusReason");
1173        else if (Configuration.doAutoCreate())
1174          this.statusReason = new StringType(); // bb
1175      return this.statusReason;
1176    }
1177
1178    public boolean hasStatusReasonElement() { 
1179      return this.statusReason != null && !this.statusReason.isEmpty();
1180    }
1181
1182    public boolean hasStatusReason() { 
1183      return this.statusReason != null && !this.statusReason.isEmpty();
1184    }
1185
1186    /**
1187     * @param value {@link #statusReason} (Captures the reason for the current status.). This is the underlying object with id, value and extensions. The accessor "getStatusReason" gives direct access to the value
1188     */
1189    public Goal setStatusReasonElement(StringType value) { 
1190      this.statusReason = value;
1191      return this;
1192    }
1193
1194    /**
1195     * @return Captures the reason for the current status.
1196     */
1197    public String getStatusReason() { 
1198      return this.statusReason == null ? null : this.statusReason.getValue();
1199    }
1200
1201    /**
1202     * @param value Captures the reason for the current status.
1203     */
1204    public Goal setStatusReason(String value) { 
1205      if (Utilities.noString(value))
1206        this.statusReason = null;
1207      else {
1208        if (this.statusReason == null)
1209          this.statusReason = new StringType();
1210        this.statusReason.setValue(value);
1211      }
1212      return this;
1213    }
1214
1215    /**
1216     * @return {@link #expressedBy} (Indicates whose goal this is - patient goal, practitioner goal, etc.)
1217     */
1218    public Reference getExpressedBy() { 
1219      if (this.expressedBy == null)
1220        if (Configuration.errorOnAutoCreate())
1221          throw new Error("Attempt to auto-create Goal.expressedBy");
1222        else if (Configuration.doAutoCreate())
1223          this.expressedBy = new Reference(); // cc
1224      return this.expressedBy;
1225    }
1226
1227    public boolean hasExpressedBy() { 
1228      return this.expressedBy != null && !this.expressedBy.isEmpty();
1229    }
1230
1231    /**
1232     * @param value {@link #expressedBy} (Indicates whose goal this is - patient goal, practitioner goal, etc.)
1233     */
1234    public Goal setExpressedBy(Reference value) { 
1235      this.expressedBy = value;
1236      return this;
1237    }
1238
1239    /**
1240     * @return {@link #expressedBy} 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 whose goal this is - patient goal, practitioner goal, etc.)
1241     */
1242    public Resource getExpressedByTarget() { 
1243      return this.expressedByTarget;
1244    }
1245
1246    /**
1247     * @param value {@link #expressedBy} 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 whose goal this is - patient goal, practitioner goal, etc.)
1248     */
1249    public Goal setExpressedByTarget(Resource value) { 
1250      this.expressedByTarget = value;
1251      return this;
1252    }
1253
1254    /**
1255     * @return {@link #addresses} (The identified conditions and other health record elements that are intended to be addressed by the goal.)
1256     */
1257    public List<Reference> getAddresses() { 
1258      if (this.addresses == null)
1259        this.addresses = new ArrayList<Reference>();
1260      return this.addresses;
1261    }
1262
1263    /**
1264     * @return Returns a reference to <code>this</code> for easy method chaining
1265     */
1266    public Goal setAddresses(List<Reference> theAddresses) { 
1267      this.addresses = theAddresses;
1268      return this;
1269    }
1270
1271    public boolean hasAddresses() { 
1272      if (this.addresses == null)
1273        return false;
1274      for (Reference item : this.addresses)
1275        if (!item.isEmpty())
1276          return true;
1277      return false;
1278    }
1279
1280    public Reference addAddresses() { //3
1281      Reference t = new Reference();
1282      if (this.addresses == null)
1283        this.addresses = new ArrayList<Reference>();
1284      this.addresses.add(t);
1285      return t;
1286    }
1287
1288    public Goal addAddresses(Reference t) { //3
1289      if (t == null)
1290        return this;
1291      if (this.addresses == null)
1292        this.addresses = new ArrayList<Reference>();
1293      this.addresses.add(t);
1294      return this;
1295    }
1296
1297    /**
1298     * @return The first repetition of repeating field {@link #addresses}, creating it if it does not already exist
1299     */
1300    public Reference getAddressesFirstRep() { 
1301      if (getAddresses().isEmpty()) {
1302        addAddresses();
1303      }
1304      return getAddresses().get(0);
1305    }
1306
1307    /**
1308     * @deprecated Use Reference#setResource(IBaseResource) instead
1309     */
1310    @Deprecated
1311    public List<Resource> getAddressesTarget() { 
1312      if (this.addressesTarget == null)
1313        this.addressesTarget = new ArrayList<Resource>();
1314      return this.addressesTarget;
1315    }
1316
1317    /**
1318     * @return {@link #note} (Any comments related to the goal.)
1319     */
1320    public List<Annotation> getNote() { 
1321      if (this.note == null)
1322        this.note = new ArrayList<Annotation>();
1323      return this.note;
1324    }
1325
1326    /**
1327     * @return Returns a reference to <code>this</code> for easy method chaining
1328     */
1329    public Goal setNote(List<Annotation> theNote) { 
1330      this.note = theNote;
1331      return this;
1332    }
1333
1334    public boolean hasNote() { 
1335      if (this.note == null)
1336        return false;
1337      for (Annotation item : this.note)
1338        if (!item.isEmpty())
1339          return true;
1340      return false;
1341    }
1342
1343    public Annotation addNote() { //3
1344      Annotation t = new Annotation();
1345      if (this.note == null)
1346        this.note = new ArrayList<Annotation>();
1347      this.note.add(t);
1348      return t;
1349    }
1350
1351    public Goal addNote(Annotation t) { //3
1352      if (t == null)
1353        return this;
1354      if (this.note == null)
1355        this.note = new ArrayList<Annotation>();
1356      this.note.add(t);
1357      return this;
1358    }
1359
1360    /**
1361     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
1362     */
1363    public Annotation getNoteFirstRep() { 
1364      if (getNote().isEmpty()) {
1365        addNote();
1366      }
1367      return getNote().get(0);
1368    }
1369
1370    /**
1371     * @return {@link #outcomeCode} (Identifies the change (or lack of change) at the point when the status of the goal is assessed.)
1372     */
1373    public List<CodeableConcept> getOutcomeCode() { 
1374      if (this.outcomeCode == null)
1375        this.outcomeCode = new ArrayList<CodeableConcept>();
1376      return this.outcomeCode;
1377    }
1378
1379    /**
1380     * @return Returns a reference to <code>this</code> for easy method chaining
1381     */
1382    public Goal setOutcomeCode(List<CodeableConcept> theOutcomeCode) { 
1383      this.outcomeCode = theOutcomeCode;
1384      return this;
1385    }
1386
1387    public boolean hasOutcomeCode() { 
1388      if (this.outcomeCode == null)
1389        return false;
1390      for (CodeableConcept item : this.outcomeCode)
1391        if (!item.isEmpty())
1392          return true;
1393      return false;
1394    }
1395
1396    public CodeableConcept addOutcomeCode() { //3
1397      CodeableConcept t = new CodeableConcept();
1398      if (this.outcomeCode == null)
1399        this.outcomeCode = new ArrayList<CodeableConcept>();
1400      this.outcomeCode.add(t);
1401      return t;
1402    }
1403
1404    public Goal addOutcomeCode(CodeableConcept t) { //3
1405      if (t == null)
1406        return this;
1407      if (this.outcomeCode == null)
1408        this.outcomeCode = new ArrayList<CodeableConcept>();
1409      this.outcomeCode.add(t);
1410      return this;
1411    }
1412
1413    /**
1414     * @return The first repetition of repeating field {@link #outcomeCode}, creating it if it does not already exist
1415     */
1416    public CodeableConcept getOutcomeCodeFirstRep() { 
1417      if (getOutcomeCode().isEmpty()) {
1418        addOutcomeCode();
1419      }
1420      return getOutcomeCode().get(0);
1421    }
1422
1423    /**
1424     * @return {@link #outcomeReference} (Details of what's changed (or not changed).)
1425     */
1426    public List<Reference> getOutcomeReference() { 
1427      if (this.outcomeReference == null)
1428        this.outcomeReference = new ArrayList<Reference>();
1429      return this.outcomeReference;
1430    }
1431
1432    /**
1433     * @return Returns a reference to <code>this</code> for easy method chaining
1434     */
1435    public Goal setOutcomeReference(List<Reference> theOutcomeReference) { 
1436      this.outcomeReference = theOutcomeReference;
1437      return this;
1438    }
1439
1440    public boolean hasOutcomeReference() { 
1441      if (this.outcomeReference == null)
1442        return false;
1443      for (Reference item : this.outcomeReference)
1444        if (!item.isEmpty())
1445          return true;
1446      return false;
1447    }
1448
1449    public Reference addOutcomeReference() { //3
1450      Reference t = new Reference();
1451      if (this.outcomeReference == null)
1452        this.outcomeReference = new ArrayList<Reference>();
1453      this.outcomeReference.add(t);
1454      return t;
1455    }
1456
1457    public Goal addOutcomeReference(Reference t) { //3
1458      if (t == null)
1459        return this;
1460      if (this.outcomeReference == null)
1461        this.outcomeReference = new ArrayList<Reference>();
1462      this.outcomeReference.add(t);
1463      return this;
1464    }
1465
1466    /**
1467     * @return The first repetition of repeating field {@link #outcomeReference}, creating it if it does not already exist
1468     */
1469    public Reference getOutcomeReferenceFirstRep() { 
1470      if (getOutcomeReference().isEmpty()) {
1471        addOutcomeReference();
1472      }
1473      return getOutcomeReference().get(0);
1474    }
1475
1476    /**
1477     * @deprecated Use Reference#setResource(IBaseResource) instead
1478     */
1479    @Deprecated
1480    public List<Observation> getOutcomeReferenceTarget() { 
1481      if (this.outcomeReferenceTarget == null)
1482        this.outcomeReferenceTarget = new ArrayList<Observation>();
1483      return this.outcomeReferenceTarget;
1484    }
1485
1486    /**
1487     * @deprecated Use Reference#setResource(IBaseResource) instead
1488     */
1489    @Deprecated
1490    public Observation addOutcomeReferenceTarget() { 
1491      Observation r = new Observation();
1492      if (this.outcomeReferenceTarget == null)
1493        this.outcomeReferenceTarget = new ArrayList<Observation>();
1494      this.outcomeReferenceTarget.add(r);
1495      return r;
1496    }
1497
1498      protected void listChildren(List<Property> children) {
1499        super.listChildren(children);
1500        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this goal by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
1501        children.add(new Property("status", "code", "Indicates whether the goal has been reached and is still considered relevant.", 0, 1, status));
1502        children.add(new Property("category", "CodeableConcept", "Indicates a category the goal falls within.", 0, java.lang.Integer.MAX_VALUE, category));
1503        children.add(new Property("priority", "CodeableConcept", "Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.", 0, 1, priority));
1504        children.add(new Property("description", "CodeableConcept", "Human-readable and/or coded description of a specific desired objective of care, such as \"control blood pressure\" or \"negotiate an obstacle course\" or \"dance with child at wedding\".", 0, 1, description));
1505        children.add(new Property("subject", "Reference(Patient|Group|Organization)", "Identifies the patient, group or organization for whom the goal is being established.", 0, 1, subject));
1506        children.add(new Property("start[x]", "date|CodeableConcept", "The date or event after which the goal should begin being pursued.", 0, 1, start));
1507        children.add(new Property("target", "", "Indicates what should be done by when.", 0, 1, target));
1508        children.add(new Property("statusDate", "date", "Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.", 0, 1, statusDate));
1509        children.add(new Property("statusReason", "string", "Captures the reason for the current status.", 0, 1, statusReason));
1510        children.add(new Property("expressedBy", "Reference(Patient|Practitioner|RelatedPerson)", "Indicates whose goal this is - patient goal, practitioner goal, etc.", 0, 1, expressedBy));
1511        children.add(new Property("addresses", "Reference(Condition|Observation|MedicationStatement|NutritionOrder|ServiceRequest|RiskAssessment)", "The identified conditions and other health record elements that are intended to be addressed by the goal.", 0, java.lang.Integer.MAX_VALUE, addresses));
1512        children.add(new Property("note", "Annotation", "Any comments related to the goal.", 0, java.lang.Integer.MAX_VALUE, note));
1513        children.add(new Property("outcomeCode", "CodeableConcept", "Identifies the change (or lack of change) at the point when the status of the goal is assessed.", 0, java.lang.Integer.MAX_VALUE, outcomeCode));
1514        children.add(new Property("outcomeReference", "Reference(Observation)", "Details of what's changed (or not changed).", 0, java.lang.Integer.MAX_VALUE, outcomeReference));
1515      }
1516
1517      @Override
1518      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1519        switch (_hash) {
1520        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this goal by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
1521        case -892481550: /*status*/  return new Property("status", "code", "Indicates whether the goal has been reached and is still considered relevant.", 0, 1, status);
1522        case 50511102: /*category*/  return new Property("category", "CodeableConcept", "Indicates a category the goal falls within.", 0, java.lang.Integer.MAX_VALUE, category);
1523        case -1165461084: /*priority*/  return new Property("priority", "CodeableConcept", "Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.", 0, 1, priority);
1524        case -1724546052: /*description*/  return new Property("description", "CodeableConcept", "Human-readable and/or coded description of a specific desired objective of care, such as \"control blood pressure\" or \"negotiate an obstacle course\" or \"dance with child at wedding\".", 0, 1, description);
1525        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group|Organization)", "Identifies the patient, group or organization for whom the goal is being established.", 0, 1, subject);
1526        case 1316793566: /*start[x]*/  return new Property("start[x]", "date|CodeableConcept", "The date or event after which the goal should begin being pursued.", 0, 1, start);
1527        case 109757538: /*start*/  return new Property("start[x]", "date|CodeableConcept", "The date or event after which the goal should begin being pursued.", 0, 1, start);
1528        case -2129778896: /*startDate*/  return new Property("start[x]", "date|CodeableConcept", "The date or event after which the goal should begin being pursued.", 0, 1, start);
1529        case -1758833953: /*startCodeableConcept*/  return new Property("start[x]", "date|CodeableConcept", "The date or event after which the goal should begin being pursued.", 0, 1, start);
1530        case -880905839: /*target*/  return new Property("target", "", "Indicates what should be done by when.", 0, 1, target);
1531        case 247524032: /*statusDate*/  return new Property("statusDate", "date", "Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.", 0, 1, statusDate);
1532        case 2051346646: /*statusReason*/  return new Property("statusReason", "string", "Captures the reason for the current status.", 0, 1, statusReason);
1533        case 175423686: /*expressedBy*/  return new Property("expressedBy", "Reference(Patient|Practitioner|RelatedPerson)", "Indicates whose goal this is - patient goal, practitioner goal, etc.", 0, 1, expressedBy);
1534        case 874544034: /*addresses*/  return new Property("addresses", "Reference(Condition|Observation|MedicationStatement|NutritionOrder|ServiceRequest|RiskAssessment)", "The identified conditions and other health record elements that are intended to be addressed by the goal.", 0, java.lang.Integer.MAX_VALUE, addresses);
1535        case 3387378: /*note*/  return new Property("note", "Annotation", "Any comments related to the goal.", 0, java.lang.Integer.MAX_VALUE, note);
1536        case 1062482015: /*outcomeCode*/  return new Property("outcomeCode", "CodeableConcept", "Identifies the change (or lack of change) at the point when the status of the goal is assessed.", 0, java.lang.Integer.MAX_VALUE, outcomeCode);
1537        case -782273511: /*outcomeReference*/  return new Property("outcomeReference", "Reference(Observation)", "Details of what's changed (or not changed).", 0, java.lang.Integer.MAX_VALUE, outcomeReference);
1538        default: return super.getNamedProperty(_hash, _name, _checkValid);
1539        }
1540
1541      }
1542
1543      @Override
1544      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1545        switch (hash) {
1546        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
1547        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<GoalStatus>
1548        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
1549        case -1165461084: /*priority*/ return this.priority == null ? new Base[0] : new Base[] {this.priority}; // CodeableConcept
1550        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // CodeableConcept
1551        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
1552        case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // Type
1553        case -880905839: /*target*/ return this.target == null ? new Base[0] : new Base[] {this.target}; // GoalTargetComponent
1554        case 247524032: /*statusDate*/ return this.statusDate == null ? new Base[0] : new Base[] {this.statusDate}; // DateType
1555        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // StringType
1556        case 175423686: /*expressedBy*/ return this.expressedBy == null ? new Base[0] : new Base[] {this.expressedBy}; // Reference
1557        case 874544034: /*addresses*/ return this.addresses == null ? new Base[0] : this.addresses.toArray(new Base[this.addresses.size()]); // Reference
1558        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
1559        case 1062482015: /*outcomeCode*/ return this.outcomeCode == null ? new Base[0] : this.outcomeCode.toArray(new Base[this.outcomeCode.size()]); // CodeableConcept
1560        case -782273511: /*outcomeReference*/ return this.outcomeReference == null ? new Base[0] : this.outcomeReference.toArray(new Base[this.outcomeReference.size()]); // Reference
1561        default: return super.getProperty(hash, name, checkValid);
1562        }
1563
1564      }
1565
1566      @Override
1567      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1568        switch (hash) {
1569        case -1618432855: // identifier
1570          this.getIdentifier().add(castToIdentifier(value)); // Identifier
1571          return value;
1572        case -892481550: // status
1573          value = new GoalStatusEnumFactory().fromType(castToCode(value));
1574          this.status = (Enumeration) value; // Enumeration<GoalStatus>
1575          return value;
1576        case 50511102: // category
1577          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
1578          return value;
1579        case -1165461084: // priority
1580          this.priority = castToCodeableConcept(value); // CodeableConcept
1581          return value;
1582        case -1724546052: // description
1583          this.description = castToCodeableConcept(value); // CodeableConcept
1584          return value;
1585        case -1867885268: // subject
1586          this.subject = castToReference(value); // Reference
1587          return value;
1588        case 109757538: // start
1589          this.start = castToType(value); // Type
1590          return value;
1591        case -880905839: // target
1592          this.target = (GoalTargetComponent) value; // GoalTargetComponent
1593          return value;
1594        case 247524032: // statusDate
1595          this.statusDate = castToDate(value); // DateType
1596          return value;
1597        case 2051346646: // statusReason
1598          this.statusReason = castToString(value); // StringType
1599          return value;
1600        case 175423686: // expressedBy
1601          this.expressedBy = castToReference(value); // Reference
1602          return value;
1603        case 874544034: // addresses
1604          this.getAddresses().add(castToReference(value)); // Reference
1605          return value;
1606        case 3387378: // note
1607          this.getNote().add(castToAnnotation(value)); // Annotation
1608          return value;
1609        case 1062482015: // outcomeCode
1610          this.getOutcomeCode().add(castToCodeableConcept(value)); // CodeableConcept
1611          return value;
1612        case -782273511: // outcomeReference
1613          this.getOutcomeReference().add(castToReference(value)); // Reference
1614          return value;
1615        default: return super.setProperty(hash, name, value);
1616        }
1617
1618      }
1619
1620      @Override
1621      public Base setProperty(String name, Base value) throws FHIRException {
1622        if (name.equals("identifier")) {
1623          this.getIdentifier().add(castToIdentifier(value));
1624        } else if (name.equals("status")) {
1625          value = new GoalStatusEnumFactory().fromType(castToCode(value));
1626          this.status = (Enumeration) value; // Enumeration<GoalStatus>
1627        } else if (name.equals("category")) {
1628          this.getCategory().add(castToCodeableConcept(value));
1629        } else if (name.equals("priority")) {
1630          this.priority = castToCodeableConcept(value); // CodeableConcept
1631        } else if (name.equals("description")) {
1632          this.description = castToCodeableConcept(value); // CodeableConcept
1633        } else if (name.equals("subject")) {
1634          this.subject = castToReference(value); // Reference
1635        } else if (name.equals("start[x]")) {
1636          this.start = castToType(value); // Type
1637        } else if (name.equals("target")) {
1638          this.target = (GoalTargetComponent) value; // GoalTargetComponent
1639        } else if (name.equals("statusDate")) {
1640          this.statusDate = castToDate(value); // DateType
1641        } else if (name.equals("statusReason")) {
1642          this.statusReason = castToString(value); // StringType
1643        } else if (name.equals("expressedBy")) {
1644          this.expressedBy = castToReference(value); // Reference
1645        } else if (name.equals("addresses")) {
1646          this.getAddresses().add(castToReference(value));
1647        } else if (name.equals("note")) {
1648          this.getNote().add(castToAnnotation(value));
1649        } else if (name.equals("outcomeCode")) {
1650          this.getOutcomeCode().add(castToCodeableConcept(value));
1651        } else if (name.equals("outcomeReference")) {
1652          this.getOutcomeReference().add(castToReference(value));
1653        } else
1654          return super.setProperty(name, value);
1655        return value;
1656      }
1657
1658      @Override
1659      public Base makeProperty(int hash, String name) throws FHIRException {
1660        switch (hash) {
1661        case -1618432855:  return addIdentifier(); 
1662        case -892481550:  return getStatusElement();
1663        case 50511102:  return addCategory(); 
1664        case -1165461084:  return getPriority(); 
1665        case -1724546052:  return getDescription(); 
1666        case -1867885268:  return getSubject(); 
1667        case 1316793566:  return getStart(); 
1668        case 109757538:  return getStart(); 
1669        case -880905839:  return getTarget(); 
1670        case 247524032:  return getStatusDateElement();
1671        case 2051346646:  return getStatusReasonElement();
1672        case 175423686:  return getExpressedBy(); 
1673        case 874544034:  return addAddresses(); 
1674        case 3387378:  return addNote(); 
1675        case 1062482015:  return addOutcomeCode(); 
1676        case -782273511:  return addOutcomeReference(); 
1677        default: return super.makeProperty(hash, name);
1678        }
1679
1680      }
1681
1682      @Override
1683      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1684        switch (hash) {
1685        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
1686        case -892481550: /*status*/ return new String[] {"code"};
1687        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
1688        case -1165461084: /*priority*/ return new String[] {"CodeableConcept"};
1689        case -1724546052: /*description*/ return new String[] {"CodeableConcept"};
1690        case -1867885268: /*subject*/ return new String[] {"Reference"};
1691        case 109757538: /*start*/ return new String[] {"date", "CodeableConcept"};
1692        case -880905839: /*target*/ return new String[] {};
1693        case 247524032: /*statusDate*/ return new String[] {"date"};
1694        case 2051346646: /*statusReason*/ return new String[] {"string"};
1695        case 175423686: /*expressedBy*/ return new String[] {"Reference"};
1696        case 874544034: /*addresses*/ return new String[] {"Reference"};
1697        case 3387378: /*note*/ return new String[] {"Annotation"};
1698        case 1062482015: /*outcomeCode*/ return new String[] {"CodeableConcept"};
1699        case -782273511: /*outcomeReference*/ return new String[] {"Reference"};
1700        default: return super.getTypesForProperty(hash, name);
1701        }
1702
1703      }
1704
1705      @Override
1706      public Base addChild(String name) throws FHIRException {
1707        if (name.equals("identifier")) {
1708          return addIdentifier();
1709        }
1710        else if (name.equals("status")) {
1711          throw new FHIRException("Cannot call addChild on a primitive type Goal.status");
1712        }
1713        else if (name.equals("category")) {
1714          return addCategory();
1715        }
1716        else if (name.equals("priority")) {
1717          this.priority = new CodeableConcept();
1718          return this.priority;
1719        }
1720        else if (name.equals("description")) {
1721          this.description = new CodeableConcept();
1722          return this.description;
1723        }
1724        else if (name.equals("subject")) {
1725          this.subject = new Reference();
1726          return this.subject;
1727        }
1728        else if (name.equals("startDate")) {
1729          this.start = new DateType();
1730          return this.start;
1731        }
1732        else if (name.equals("startCodeableConcept")) {
1733          this.start = new CodeableConcept();
1734          return this.start;
1735        }
1736        else if (name.equals("target")) {
1737          this.target = new GoalTargetComponent();
1738          return this.target;
1739        }
1740        else if (name.equals("statusDate")) {
1741          throw new FHIRException("Cannot call addChild on a primitive type Goal.statusDate");
1742        }
1743        else if (name.equals("statusReason")) {
1744          throw new FHIRException("Cannot call addChild on a primitive type Goal.statusReason");
1745        }
1746        else if (name.equals("expressedBy")) {
1747          this.expressedBy = new Reference();
1748          return this.expressedBy;
1749        }
1750        else if (name.equals("addresses")) {
1751          return addAddresses();
1752        }
1753        else if (name.equals("note")) {
1754          return addNote();
1755        }
1756        else if (name.equals("outcomeCode")) {
1757          return addOutcomeCode();
1758        }
1759        else if (name.equals("outcomeReference")) {
1760          return addOutcomeReference();
1761        }
1762        else
1763          return super.addChild(name);
1764      }
1765
1766  public String fhirType() {
1767    return "Goal";
1768
1769  }
1770
1771      public Goal copy() {
1772        Goal dst = new Goal();
1773        copyValues(dst);
1774        if (identifier != null) {
1775          dst.identifier = new ArrayList<Identifier>();
1776          for (Identifier i : identifier)
1777            dst.identifier.add(i.copy());
1778        };
1779        dst.status = status == null ? null : status.copy();
1780        if (category != null) {
1781          dst.category = new ArrayList<CodeableConcept>();
1782          for (CodeableConcept i : category)
1783            dst.category.add(i.copy());
1784        };
1785        dst.priority = priority == null ? null : priority.copy();
1786        dst.description = description == null ? null : description.copy();
1787        dst.subject = subject == null ? null : subject.copy();
1788        dst.start = start == null ? null : start.copy();
1789        dst.target = target == null ? null : target.copy();
1790        dst.statusDate = statusDate == null ? null : statusDate.copy();
1791        dst.statusReason = statusReason == null ? null : statusReason.copy();
1792        dst.expressedBy = expressedBy == null ? null : expressedBy.copy();
1793        if (addresses != null) {
1794          dst.addresses = new ArrayList<Reference>();
1795          for (Reference i : addresses)
1796            dst.addresses.add(i.copy());
1797        };
1798        if (note != null) {
1799          dst.note = new ArrayList<Annotation>();
1800          for (Annotation i : note)
1801            dst.note.add(i.copy());
1802        };
1803        if (outcomeCode != null) {
1804          dst.outcomeCode = new ArrayList<CodeableConcept>();
1805          for (CodeableConcept i : outcomeCode)
1806            dst.outcomeCode.add(i.copy());
1807        };
1808        if (outcomeReference != null) {
1809          dst.outcomeReference = new ArrayList<Reference>();
1810          for (Reference i : outcomeReference)
1811            dst.outcomeReference.add(i.copy());
1812        };
1813        return dst;
1814      }
1815
1816      protected Goal typedCopy() {
1817        return copy();
1818      }
1819
1820      @Override
1821      public boolean equalsDeep(Base other_) {
1822        if (!super.equalsDeep(other_))
1823          return false;
1824        if (!(other_ instanceof Goal))
1825          return false;
1826        Goal o = (Goal) other_;
1827        return compareDeep(identifier, o.identifier, true) && compareDeep(status, o.status, true) && compareDeep(category, o.category, true)
1828           && compareDeep(priority, o.priority, true) && compareDeep(description, o.description, true) && compareDeep(subject, o.subject, true)
1829           && compareDeep(start, o.start, true) && compareDeep(target, o.target, true) && compareDeep(statusDate, o.statusDate, true)
1830           && compareDeep(statusReason, o.statusReason, true) && compareDeep(expressedBy, o.expressedBy, true)
1831           && compareDeep(addresses, o.addresses, true) && compareDeep(note, o.note, true) && compareDeep(outcomeCode, o.outcomeCode, true)
1832           && compareDeep(outcomeReference, o.outcomeReference, true);
1833      }
1834
1835      @Override
1836      public boolean equalsShallow(Base other_) {
1837        if (!super.equalsShallow(other_))
1838          return false;
1839        if (!(other_ instanceof Goal))
1840          return false;
1841        Goal o = (Goal) other_;
1842        return compareValues(status, o.status, true) && compareValues(statusDate, o.statusDate, true) && compareValues(statusReason, o.statusReason, true)
1843          ;
1844      }
1845
1846      public boolean isEmpty() {
1847        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, status, category
1848          , priority, description, subject, start, target, statusDate, statusReason, expressedBy
1849          , addresses, note, outcomeCode, outcomeReference);
1850      }
1851
1852  @Override
1853  public ResourceType getResourceType() {
1854    return ResourceType.Goal;
1855   }
1856
1857 /**
1858   * Search parameter: <b>identifier</b>
1859   * <p>
1860   * Description: <b>External Ids for this goal</b><br>
1861   * Type: <b>token</b><br>
1862   * Path: <b>Goal.identifier</b><br>
1863   * </p>
1864   */
1865  @SearchParamDefinition(name="identifier", path="Goal.identifier", description="External Ids for this goal", type="token" )
1866  public static final String SP_IDENTIFIER = "identifier";
1867 /**
1868   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
1869   * <p>
1870   * Description: <b>External Ids for this goal</b><br>
1871   * Type: <b>token</b><br>
1872   * Path: <b>Goal.identifier</b><br>
1873   * </p>
1874   */
1875  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
1876
1877 /**
1878   * Search parameter: <b>patient</b>
1879   * <p>
1880   * Description: <b>Who this goal is intended for</b><br>
1881   * Type: <b>reference</b><br>
1882   * Path: <b>Goal.subject</b><br>
1883   * </p>
1884   */
1885  @SearchParamDefinition(name="patient", path="Goal.subject.where(resolve() is Patient)", description="Who this goal is intended for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
1886  public static final String SP_PATIENT = "patient";
1887 /**
1888   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
1889   * <p>
1890   * Description: <b>Who this goal is intended for</b><br>
1891   * Type: <b>reference</b><br>
1892   * Path: <b>Goal.subject</b><br>
1893   * </p>
1894   */
1895  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
1896
1897/**
1898   * Constant for fluent queries to be used to add include statements. Specifies
1899   * the path value of "<b>Goal:patient</b>".
1900   */
1901  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Goal:patient").toLocked();
1902
1903 /**
1904   * Search parameter: <b>subject</b>
1905   * <p>
1906   * Description: <b>Who this goal is intended for</b><br>
1907   * Type: <b>reference</b><br>
1908   * Path: <b>Goal.subject</b><br>
1909   * </p>
1910   */
1911  @SearchParamDefinition(name="subject", path="Goal.subject", description="Who this goal is intended for", type="reference", target={Group.class, Organization.class, Patient.class } )
1912  public static final String SP_SUBJECT = "subject";
1913 /**
1914   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
1915   * <p>
1916   * Description: <b>Who this goal is intended for</b><br>
1917   * Type: <b>reference</b><br>
1918   * Path: <b>Goal.subject</b><br>
1919   * </p>
1920   */
1921  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
1922
1923/**
1924   * Constant for fluent queries to be used to add include statements. Specifies
1925   * the path value of "<b>Goal:subject</b>".
1926   */
1927  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Goal:subject").toLocked();
1928
1929 /**
1930   * Search parameter: <b>start-date</b>
1931   * <p>
1932   * Description: <b>When goal pursuit begins</b><br>
1933   * Type: <b>date</b><br>
1934   * Path: <b>Goal.startDate</b><br>
1935   * </p>
1936   */
1937  @SearchParamDefinition(name="start-date", path="(Goal.start as date)", description="When goal pursuit begins", type="date" )
1938  public static final String SP_START_DATE = "start-date";
1939 /**
1940   * <b>Fluent Client</b> search parameter constant for <b>start-date</b>
1941   * <p>
1942   * Description: <b>When goal pursuit begins</b><br>
1943   * Type: <b>date</b><br>
1944   * Path: <b>Goal.startDate</b><br>
1945   * </p>
1946   */
1947  public static final ca.uhn.fhir.rest.gclient.DateClientParam START_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_START_DATE);
1948
1949 /**
1950   * Search parameter: <b>category</b>
1951   * <p>
1952   * Description: <b>E.g. Treatment, dietary, behavioral, etc.</b><br>
1953   * Type: <b>token</b><br>
1954   * Path: <b>Goal.category</b><br>
1955   * </p>
1956   */
1957  @SearchParamDefinition(name="category", path="Goal.category", description="E.g. Treatment, dietary, behavioral, etc.", type="token" )
1958  public static final String SP_CATEGORY = "category";
1959 /**
1960   * <b>Fluent Client</b> search parameter constant for <b>category</b>
1961   * <p>
1962   * Description: <b>E.g. Treatment, dietary, behavioral, etc.</b><br>
1963   * Type: <b>token</b><br>
1964   * Path: <b>Goal.category</b><br>
1965   * </p>
1966   */
1967  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
1968
1969 /**
1970   * Search parameter: <b>target-date</b>
1971   * <p>
1972   * Description: <b>Reach goal on or before</b><br>
1973   * Type: <b>date</b><br>
1974   * Path: <b>Goal.target.dueDate</b><br>
1975   * </p>
1976   */
1977  @SearchParamDefinition(name="target-date", path="(Goal.target.due as date)", description="Reach goal on or before", type="date" )
1978  public static final String SP_TARGET_DATE = "target-date";
1979 /**
1980   * <b>Fluent Client</b> search parameter constant for <b>target-date</b>
1981   * <p>
1982   * Description: <b>Reach goal on or before</b><br>
1983   * Type: <b>date</b><br>
1984   * Path: <b>Goal.target.dueDate</b><br>
1985   * </p>
1986   */
1987  public static final ca.uhn.fhir.rest.gclient.DateClientParam TARGET_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_TARGET_DATE);
1988
1989 /**
1990   * Search parameter: <b>status</b>
1991   * <p>
1992   * Description: <b>proposed | accepted | planned | in-progress | on-target | ahead-of-target | behind-target | sustaining | achieved | on-hold | cancelled | entered-in-error | rejected</b><br>
1993   * Type: <b>token</b><br>
1994   * Path: <b>Goal.status</b><br>
1995   * </p>
1996   */
1997  @SearchParamDefinition(name="status", path="Goal.status", description="proposed | accepted | planned | in-progress | on-target | ahead-of-target | behind-target | sustaining | achieved | on-hold | cancelled | entered-in-error | rejected", type="token" )
1998  public static final String SP_STATUS = "status";
1999 /**
2000   * <b>Fluent Client</b> search parameter constant for <b>status</b>
2001   * <p>
2002   * Description: <b>proposed | accepted | planned | in-progress | on-target | ahead-of-target | behind-target | sustaining | achieved | on-hold | cancelled | entered-in-error | rejected</b><br>
2003   * Type: <b>token</b><br>
2004   * Path: <b>Goal.status</b><br>
2005   * </p>
2006   */
2007  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
2008
2009
2010}
2011