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