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