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