001package org.hl7.fhir.dstu2.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import ca.uhn.fhir.model.api.annotation.Block;
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
043import org.hl7.fhir.exceptions.FHIRException;
044
045/**
046 * Describes the intended objective(s) for a patient, group or organization
047 * care, for example, weight loss, restoring an activity of daily living,
048 * obtaining herd immunity via immunization, meeting a process improvement
049 * objective, etc.
050 */
051@ResourceDef(name = "Goal", profile = "http://hl7.org/fhir/Profile/Goal")
052public class Goal extends DomainResource {
053
054  public enum GoalStatus {
055    /**
056     * A goal is proposed for this patient
057     */
058    PROPOSED,
059    /**
060     * A goal is planned for this patient
061     */
062    PLANNED,
063    /**
064     * A proposed goal was accepted
065     */
066    ACCEPTED,
067    /**
068     * A proposed goal was rejected
069     */
070    REJECTED,
071    /**
072     * The goal is being sought but has not yet been reached. (Also applies if goal
073     * was reached in the past but there has been regression and goal is being
074     * sought again)
075     */
076    INPROGRESS,
077    /**
078     * The goal has been met and no further action is needed
079     */
080    ACHIEVED,
081    /**
082     * The goal has been met, but ongoing activity is needed to sustain the goal
083     * objective
084     */
085    SUSTAINING,
086    /**
087     * The goal remains a long term objective but is no longer being actively
088     * pursued for a temporary period of time.
089     */
090    ONHOLD,
091    /**
092     * The goal is no longer being sought
093     */
094    CANCELLED,
095    /**
096     * added to help the parsers
097     */
098    NULL;
099
100    public static GoalStatus fromCode(String codeString) throws FHIRException {
101      if (codeString == null || "".equals(codeString))
102        return null;
103      if ("proposed".equals(codeString))
104        return PROPOSED;
105      if ("planned".equals(codeString))
106        return PLANNED;
107      if ("accepted".equals(codeString))
108        return ACCEPTED;
109      if ("rejected".equals(codeString))
110        return REJECTED;
111      if ("in-progress".equals(codeString))
112        return INPROGRESS;
113      if ("achieved".equals(codeString))
114        return ACHIEVED;
115      if ("sustaining".equals(codeString))
116        return SUSTAINING;
117      if ("on-hold".equals(codeString))
118        return ONHOLD;
119      if ("cancelled".equals(codeString))
120        return CANCELLED;
121      throw new FHIRException("Unknown GoalStatus code '" + codeString + "'");
122    }
123
124    public String toCode() {
125      switch (this) {
126      case PROPOSED:
127        return "proposed";
128      case PLANNED:
129        return "planned";
130      case ACCEPTED:
131        return "accepted";
132      case REJECTED:
133        return "rejected";
134      case INPROGRESS:
135        return "in-progress";
136      case ACHIEVED:
137        return "achieved";
138      case SUSTAINING:
139        return "sustaining";
140      case ONHOLD:
141        return "on-hold";
142      case CANCELLED:
143        return "cancelled";
144      case NULL:
145        return null;
146      default:
147        return "?";
148      }
149    }
150
151    public String getSystem() {
152      switch (this) {
153      case PROPOSED:
154        return "http://hl7.org/fhir/goal-status";
155      case PLANNED:
156        return "http://hl7.org/fhir/goal-status";
157      case ACCEPTED:
158        return "http://hl7.org/fhir/goal-status";
159      case REJECTED:
160        return "http://hl7.org/fhir/goal-status";
161      case INPROGRESS:
162        return "http://hl7.org/fhir/goal-status";
163      case ACHIEVED:
164        return "http://hl7.org/fhir/goal-status";
165      case SUSTAINING:
166        return "http://hl7.org/fhir/goal-status";
167      case ONHOLD:
168        return "http://hl7.org/fhir/goal-status";
169      case CANCELLED:
170        return "http://hl7.org/fhir/goal-status";
171      case NULL:
172        return null;
173      default:
174        return "?";
175      }
176    }
177
178    public String getDefinition() {
179      switch (this) {
180      case PROPOSED:
181        return "A goal is proposed for this patient";
182      case PLANNED:
183        return "A goal is planned for this patient";
184      case ACCEPTED:
185        return "A proposed goal was accepted";
186      case REJECTED:
187        return "A proposed goal was rejected";
188      case INPROGRESS:
189        return "The goal is being sought but has not yet been reached.  (Also applies if goal was reached in the past but there has been regression and goal is being sought again)";
190      case ACHIEVED:
191        return "The goal has been met and no further action is needed";
192      case SUSTAINING:
193        return "The goal has been met, but ongoing activity is needed to sustain the goal objective";
194      case ONHOLD:
195        return "The goal remains a long term objective but is no longer being actively pursued for a temporary period of time.";
196      case CANCELLED:
197        return "The goal is no longer being sought";
198      case NULL:
199        return null;
200      default:
201        return "?";
202      }
203    }
204
205    public String getDisplay() {
206      switch (this) {
207      case PROPOSED:
208        return "Proposed";
209      case PLANNED:
210        return "Planned";
211      case ACCEPTED:
212        return "Accepted";
213      case REJECTED:
214        return "Rejected";
215      case INPROGRESS:
216        return "In Progress";
217      case ACHIEVED:
218        return "Achieved";
219      case SUSTAINING:
220        return "Sustaining";
221      case ONHOLD:
222        return "On Hold";
223      case CANCELLED:
224        return "Cancelled";
225      case NULL:
226        return null;
227      default:
228        return "?";
229      }
230    }
231  }
232
233  public static class GoalStatusEnumFactory implements EnumFactory<GoalStatus> {
234    public GoalStatus fromCode(String codeString) throws IllegalArgumentException {
235      if (codeString == null || "".equals(codeString))
236        if (codeString == null || "".equals(codeString))
237          return null;
238      if ("proposed".equals(codeString))
239        return GoalStatus.PROPOSED;
240      if ("planned".equals(codeString))
241        return GoalStatus.PLANNED;
242      if ("accepted".equals(codeString))
243        return GoalStatus.ACCEPTED;
244      if ("rejected".equals(codeString))
245        return GoalStatus.REJECTED;
246      if ("in-progress".equals(codeString))
247        return GoalStatus.INPROGRESS;
248      if ("achieved".equals(codeString))
249        return GoalStatus.ACHIEVED;
250      if ("sustaining".equals(codeString))
251        return GoalStatus.SUSTAINING;
252      if ("on-hold".equals(codeString))
253        return GoalStatus.ONHOLD;
254      if ("cancelled".equals(codeString))
255        return GoalStatus.CANCELLED;
256      throw new IllegalArgumentException("Unknown GoalStatus code '" + codeString + "'");
257    }
258
259    public Enumeration<GoalStatus> fromType(Base code) throws FHIRException {
260      if (code == null || code.isEmpty())
261        return null;
262      String codeString = ((PrimitiveType) code).asStringValue();
263      if (codeString == null || "".equals(codeString))
264        return null;
265      if ("proposed".equals(codeString))
266        return new Enumeration<GoalStatus>(this, GoalStatus.PROPOSED);
267      if ("planned".equals(codeString))
268        return new Enumeration<GoalStatus>(this, GoalStatus.PLANNED);
269      if ("accepted".equals(codeString))
270        return new Enumeration<GoalStatus>(this, GoalStatus.ACCEPTED);
271      if ("rejected".equals(codeString))
272        return new Enumeration<GoalStatus>(this, GoalStatus.REJECTED);
273      if ("in-progress".equals(codeString))
274        return new Enumeration<GoalStatus>(this, GoalStatus.INPROGRESS);
275      if ("achieved".equals(codeString))
276        return new Enumeration<GoalStatus>(this, GoalStatus.ACHIEVED);
277      if ("sustaining".equals(codeString))
278        return new Enumeration<GoalStatus>(this, GoalStatus.SUSTAINING);
279      if ("on-hold".equals(codeString))
280        return new Enumeration<GoalStatus>(this, GoalStatus.ONHOLD);
281      if ("cancelled".equals(codeString))
282        return new Enumeration<GoalStatus>(this, GoalStatus.CANCELLED);
283      throw new FHIRException("Unknown GoalStatus code '" + codeString + "'");
284    }
285
286    public String toCode(GoalStatus code) {
287      if (code == GoalStatus.PROPOSED)
288        return "proposed";
289      if (code == GoalStatus.PLANNED)
290        return "planned";
291      if (code == GoalStatus.ACCEPTED)
292        return "accepted";
293      if (code == GoalStatus.REJECTED)
294        return "rejected";
295      if (code == GoalStatus.INPROGRESS)
296        return "in-progress";
297      if (code == GoalStatus.ACHIEVED)
298        return "achieved";
299      if (code == GoalStatus.SUSTAINING)
300        return "sustaining";
301      if (code == GoalStatus.ONHOLD)
302        return "on-hold";
303      if (code == GoalStatus.CANCELLED)
304        return "cancelled";
305      return "?";
306    }
307  }
308
309  @Block()
310  public static class GoalOutcomeComponent extends BackboneElement implements IBaseBackboneElement {
311    /**
312     * Details of what's changed (or not changed).
313     */
314    @Child(name = "result", type = { CodeableConcept.class,
315        Observation.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
316    @Description(shortDefinition = "Code or observation that resulted from goal", formalDefinition = "Details of what's changed (or not changed).")
317    protected Type result;
318
319    private static final long serialVersionUID = 1994317639L;
320
321    /*
322     * Constructor
323     */
324    public GoalOutcomeComponent() {
325      super();
326    }
327
328    /**
329     * @return {@link #result} (Details of what's changed (or not changed).)
330     */
331    public Type getResult() {
332      return this.result;
333    }
334
335    /**
336     * @return {@link #result} (Details of what's changed (or not changed).)
337     */
338    public CodeableConcept getResultCodeableConcept() throws FHIRException {
339      if (!(this.result instanceof CodeableConcept))
340        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
341            + this.result.getClass().getName() + " was encountered");
342      return (CodeableConcept) this.result;
343    }
344
345    public boolean hasResultCodeableConcept() {
346      return this.result instanceof CodeableConcept;
347    }
348
349    /**
350     * @return {@link #result} (Details of what's changed (or not changed).)
351     */
352    public Reference getResultReference() throws FHIRException {
353      if (!(this.result instanceof Reference))
354        throw new FHIRException("Type mismatch: the type Reference was expected, but "
355            + this.result.getClass().getName() + " was encountered");
356      return (Reference) this.result;
357    }
358
359    public boolean hasResultReference() {
360      return this.result instanceof Reference;
361    }
362
363    public boolean hasResult() {
364      return this.result != null && !this.result.isEmpty();
365    }
366
367    /**
368     * @param value {@link #result} (Details of what's changed (or not changed).)
369     */
370    public GoalOutcomeComponent setResult(Type value) {
371      this.result = value;
372      return this;
373    }
374
375    protected void listChildren(List<Property> childrenList) {
376      super.listChildren(childrenList);
377      childrenList.add(new Property("result[x]", "CodeableConcept|Reference(Observation)",
378          "Details of what's changed (or not changed).", 0, java.lang.Integer.MAX_VALUE, result));
379    }
380
381    @Override
382    public void setProperty(String name, Base value) throws FHIRException {
383      if (name.equals("result[x]"))
384        this.result = (Type) value; // Type
385      else
386        super.setProperty(name, value);
387    }
388
389    @Override
390    public Base addChild(String name) throws FHIRException {
391      if (name.equals("resultCodeableConcept")) {
392        this.result = new CodeableConcept();
393        return this.result;
394      } else if (name.equals("resultReference")) {
395        this.result = new Reference();
396        return this.result;
397      } else
398        return super.addChild(name);
399    }
400
401    public GoalOutcomeComponent copy() {
402      GoalOutcomeComponent dst = new GoalOutcomeComponent();
403      copyValues(dst);
404      dst.result = result == null ? null : result.copy();
405      return dst;
406    }
407
408    @Override
409    public boolean equalsDeep(Base other) {
410      if (!super.equalsDeep(other))
411        return false;
412      if (!(other instanceof GoalOutcomeComponent))
413        return false;
414      GoalOutcomeComponent o = (GoalOutcomeComponent) other;
415      return compareDeep(result, o.result, true);
416    }
417
418    @Override
419    public boolean equalsShallow(Base other) {
420      if (!super.equalsShallow(other))
421        return false;
422      if (!(other instanceof GoalOutcomeComponent))
423        return false;
424      GoalOutcomeComponent o = (GoalOutcomeComponent) other;
425      return true;
426    }
427
428    public boolean isEmpty() {
429      return super.isEmpty() && (result == null || result.isEmpty());
430    }
431
432    public String fhirType() {
433      return "Goal.outcome";
434
435    }
436
437  }
438
439  /**
440   * This records identifiers associated with this care plan that are defined by
441   * business processes and/or used to refer to it when a direct URL reference to
442   * the resource itself is not appropriate (e.g. in CDA documents, or in written
443   * / printed documentation).
444   */
445  @Child(name = "identifier", type = {
446      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
447  @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).")
448  protected List<Identifier> identifier;
449
450  /**
451   * Identifies the patient, group or organization for whom the goal is being
452   * established.
453   */
454  @Child(name = "subject", type = { Patient.class, Group.class,
455      Organization.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
456  @Description(shortDefinition = "Who this goal is intended for", formalDefinition = "Identifies the patient, group or organization for whom the goal is being established.")
457  protected Reference subject;
458
459  /**
460   * The actual object that is the target of the reference (Identifies the
461   * patient, group or organization for whom the goal is being established.)
462   */
463  protected Resource subjectTarget;
464
465  /**
466   * The date or event after which the goal should begin being pursued.
467   */
468  @Child(name = "start", type = { DateType.class,
469      CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = true)
470  @Description(shortDefinition = "When goal pursuit begins", formalDefinition = "The date or event after which the goal should begin being pursued.")
471  protected Type start;
472
473  /**
474   * Indicates either the date or the duration after start by which the goal
475   * should be met.
476   */
477  @Child(name = "target", type = { DateType.class,
478      Duration.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
479  @Description(shortDefinition = "Reach goal on or before", formalDefinition = "Indicates either the date or the duration after start by which the goal should be met.")
480  protected Type target;
481
482  /**
483   * Indicates a category the goal falls within.
484   */
485  @Child(name = "category", type = {
486      CodeableConcept.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
487  @Description(shortDefinition = "E.g. Treatment, dietary, behavioral, etc.", formalDefinition = "Indicates a category the goal falls within.")
488  protected List<CodeableConcept> category;
489
490  /**
491   * Human-readable description of a specific desired objective of care.
492   */
493  @Child(name = "description", type = {
494      StringType.class }, order = 5, min = 1, max = 1, modifier = false, summary = true)
495  @Description(shortDefinition = "What's the desired outcome?", formalDefinition = "Human-readable description of a specific desired objective of care.")
496  protected StringType description;
497
498  /**
499   * Indicates whether the goal has been reached and is still considered relevant.
500   */
501  @Child(name = "status", type = { CodeType.class }, order = 6, min = 1, max = 1, modifier = true, summary = true)
502  @Description(shortDefinition = "proposed | planned | accepted | rejected | in-progress | achieved | sustaining | on-hold | cancelled", formalDefinition = "Indicates whether the goal has been reached and is still considered relevant.")
503  protected Enumeration<GoalStatus> status;
504
505  /**
506   * Identifies when the current status. I.e. When initially created, when
507   * achieved, when cancelled, etc.
508   */
509  @Child(name = "statusDate", type = { DateType.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
510  @Description(shortDefinition = "When goal status took effect", formalDefinition = "Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.")
511  protected DateType statusDate;
512
513  /**
514   * Captures the reason for the current status.
515   */
516  @Child(name = "statusReason", type = {
517      CodeableConcept.class }, order = 8, min = 0, max = 1, modifier = false, summary = false)
518  @Description(shortDefinition = "Reason for current status", formalDefinition = "Captures the reason for the current status.")
519  protected CodeableConcept statusReason;
520
521  /**
522   * Indicates whose goal this is - patient goal, practitioner goal, etc.
523   */
524  @Child(name = "author", type = { Patient.class, Practitioner.class,
525      RelatedPerson.class }, order = 9, min = 0, max = 1, modifier = false, summary = true)
526  @Description(shortDefinition = "Who's responsible for creating Goal?", formalDefinition = "Indicates whose goal this is - patient goal, practitioner goal, etc.")
527  protected Reference author;
528
529  /**
530   * The actual object that is the target of the reference (Indicates whose goal
531   * this is - patient goal, practitioner goal, etc.)
532   */
533  protected Resource authorTarget;
534
535  /**
536   * Identifies the mutually agreed level of importance associated with
537   * reaching/sustaining the goal.
538   */
539  @Child(name = "priority", type = {
540      CodeableConcept.class }, order = 10, min = 0, max = 1, modifier = false, summary = true)
541  @Description(shortDefinition = "high | medium |low", formalDefinition = "Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.")
542  protected CodeableConcept priority;
543
544  /**
545   * The identified conditions and other health record elements that are intended
546   * to be addressed by the goal.
547   */
548  @Child(name = "addresses", type = { Condition.class, Observation.class, MedicationStatement.class,
549      NutritionOrder.class, ProcedureRequest.class,
550      RiskAssessment.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
551  @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.")
552  protected List<Reference> addresses;
553  /**
554   * The actual objects that are the target of the reference (The identified
555   * conditions and other health record elements that are intended to be addressed
556   * by the goal.)
557   */
558  protected List<Resource> addressesTarget;
559
560  /**
561   * Any comments related to the goal.
562   */
563  @Child(name = "note", type = {
564      Annotation.class }, order = 12, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
565  @Description(shortDefinition = "Comments about the goal", formalDefinition = "Any comments related to the goal.")
566  protected List<Annotation> note;
567
568  /**
569   * Identifies the change (or lack of change) at the point where the goal was
570   * deepmed to be cancelled or achieved.
571   */
572  @Child(name = "outcome", type = {}, order = 13, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
573  @Description(shortDefinition = "What was end result of goal?", formalDefinition = "Identifies the change (or lack of change) at the point where the goal was deepmed to be cancelled or achieved.")
574  protected List<GoalOutcomeComponent> outcome;
575
576  private static final long serialVersionUID = 2029459056L;
577
578  /*
579   * Constructor
580   */
581  public Goal() {
582    super();
583  }
584
585  /*
586   * Constructor
587   */
588  public Goal(StringType description, Enumeration<GoalStatus> status) {
589    super();
590    this.description = description;
591    this.status = status;
592  }
593
594  /**
595   * @return {@link #identifier} (This records identifiers associated with this
596   *         care plan that are defined by business processes and/or used to refer
597   *         to it when a direct URL reference to the resource itself is not
598   *         appropriate (e.g. in CDA documents, or in written / printed
599   *         documentation).)
600   */
601  public List<Identifier> getIdentifier() {
602    if (this.identifier == null)
603      this.identifier = new ArrayList<Identifier>();
604    return this.identifier;
605  }
606
607  public boolean hasIdentifier() {
608    if (this.identifier == null)
609      return false;
610    for (Identifier item : this.identifier)
611      if (!item.isEmpty())
612        return true;
613    return false;
614  }
615
616  /**
617   * @return {@link #identifier} (This records identifiers associated with this
618   *         care plan that are defined by business processes and/or used to refer
619   *         to it when a direct URL reference to the resource itself is not
620   *         appropriate (e.g. in CDA documents, or in written / printed
621   *         documentation).)
622   */
623  // syntactic sugar
624  public Identifier addIdentifier() { // 3
625    Identifier t = new Identifier();
626    if (this.identifier == null)
627      this.identifier = new ArrayList<Identifier>();
628    this.identifier.add(t);
629    return t;
630  }
631
632  // syntactic sugar
633  public Goal addIdentifier(Identifier t) { // 3
634    if (t == null)
635      return this;
636    if (this.identifier == null)
637      this.identifier = new ArrayList<Identifier>();
638    this.identifier.add(t);
639    return this;
640  }
641
642  /**
643   * @return {@link #subject} (Identifies the patient, group or organization for
644   *         whom the goal is being established.)
645   */
646  public Reference getSubject() {
647    if (this.subject == null)
648      if (Configuration.errorOnAutoCreate())
649        throw new Error("Attempt to auto-create Goal.subject");
650      else if (Configuration.doAutoCreate())
651        this.subject = new Reference(); // cc
652    return this.subject;
653  }
654
655  public boolean hasSubject() {
656    return this.subject != null && !this.subject.isEmpty();
657  }
658
659  /**
660   * @param value {@link #subject} (Identifies the patient, group or organization
661   *              for whom the goal is being established.)
662   */
663  public Goal setSubject(Reference value) {
664    this.subject = value;
665    return this;
666  }
667
668  /**
669   * @return {@link #subject} The actual object that is the target of the
670   *         reference. The reference library doesn't populate this, but you can
671   *         use it to hold the resource if you resolve it. (Identifies the
672   *         patient, group or organization for whom the goal is being
673   *         established.)
674   */
675  public Resource getSubjectTarget() {
676    return this.subjectTarget;
677  }
678
679  /**
680   * @param value {@link #subject} The actual object that is the target of the
681   *              reference. The reference library doesn't use these, but you can
682   *              use it to hold the resource if you resolve it. (Identifies the
683   *              patient, group or organization for whom the goal is being
684   *              established.)
685   */
686  public Goal setSubjectTarget(Resource value) {
687    this.subjectTarget = value;
688    return this;
689  }
690
691  /**
692   * @return {@link #start} (The date or event after which the goal should begin
693   *         being pursued.)
694   */
695  public Type getStart() {
696    return this.start;
697  }
698
699  /**
700   * @return {@link #start} (The date or event after which the goal should begin
701   *         being pursued.)
702   */
703  public DateType getStartDateType() throws FHIRException {
704    if (!(this.start instanceof DateType))
705      throw new FHIRException(
706          "Type mismatch: the type DateType was expected, but " + this.start.getClass().getName() + " was encountered");
707    return (DateType) this.start;
708  }
709
710  public boolean hasStartDateType() {
711    return this.start instanceof DateType;
712  }
713
714  /**
715   * @return {@link #start} (The date or event after which the goal should begin
716   *         being pursued.)
717   */
718  public CodeableConcept getStartCodeableConcept() throws FHIRException {
719    if (!(this.start instanceof CodeableConcept))
720      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
721          + this.start.getClass().getName() + " was encountered");
722    return (CodeableConcept) this.start;
723  }
724
725  public boolean hasStartCodeableConcept() {
726    return this.start instanceof CodeableConcept;
727  }
728
729  public boolean hasStart() {
730    return this.start != null && !this.start.isEmpty();
731  }
732
733  /**
734   * @param value {@link #start} (The date or event after which the goal should
735   *              begin being pursued.)
736   */
737  public Goal setStart(Type value) {
738    this.start = value;
739    return this;
740  }
741
742  /**
743   * @return {@link #target} (Indicates either the date or the duration after
744   *         start by which the goal should be met.)
745   */
746  public Type getTarget() {
747    return this.target;
748  }
749
750  /**
751   * @return {@link #target} (Indicates either the date or the duration after
752   *         start by which the goal should be met.)
753   */
754  public DateType getTargetDateType() throws FHIRException {
755    if (!(this.target instanceof DateType))
756      throw new FHIRException("Type mismatch: the type DateType was expected, but " + this.target.getClass().getName()
757          + " was encountered");
758    return (DateType) this.target;
759  }
760
761  public boolean hasTargetDateType() {
762    return this.target instanceof DateType;
763  }
764
765  /**
766   * @return {@link #target} (Indicates either the date or the duration after
767   *         start by which the goal should be met.)
768   */
769  public Duration getTargetDuration() throws FHIRException {
770    if (!(this.target instanceof Duration))
771      throw new FHIRException("Type mismatch: the type Duration was expected, but " + this.target.getClass().getName()
772          + " was encountered");
773    return (Duration) this.target;
774  }
775
776  public boolean hasTargetDuration() {
777    return this.target instanceof Duration;
778  }
779
780  public boolean hasTarget() {
781    return this.target != null && !this.target.isEmpty();
782  }
783
784  /**
785   * @param value {@link #target} (Indicates either the date or the duration after
786   *              start by which the goal should be met.)
787   */
788  public Goal setTarget(Type value) {
789    this.target = value;
790    return this;
791  }
792
793  /**
794   * @return {@link #category} (Indicates a category the goal falls within.)
795   */
796  public List<CodeableConcept> getCategory() {
797    if (this.category == null)
798      this.category = new ArrayList<CodeableConcept>();
799    return this.category;
800  }
801
802  public boolean hasCategory() {
803    if (this.category == null)
804      return false;
805    for (CodeableConcept item : this.category)
806      if (!item.isEmpty())
807        return true;
808    return false;
809  }
810
811  /**
812   * @return {@link #category} (Indicates a category the goal falls within.)
813   */
814  // syntactic sugar
815  public CodeableConcept addCategory() { // 3
816    CodeableConcept t = new CodeableConcept();
817    if (this.category == null)
818      this.category = new ArrayList<CodeableConcept>();
819    this.category.add(t);
820    return t;
821  }
822
823  // syntactic sugar
824  public Goal addCategory(CodeableConcept t) { // 3
825    if (t == null)
826      return this;
827    if (this.category == null)
828      this.category = new ArrayList<CodeableConcept>();
829    this.category.add(t);
830    return this;
831  }
832
833  /**
834   * @return {@link #description} (Human-readable description of a specific
835   *         desired objective of care.). This is the underlying object with id,
836   *         value and extensions. The accessor "getDescription" gives direct
837   *         access to the value
838   */
839  public StringType getDescriptionElement() {
840    if (this.description == null)
841      if (Configuration.errorOnAutoCreate())
842        throw new Error("Attempt to auto-create Goal.description");
843      else if (Configuration.doAutoCreate())
844        this.description = new StringType(); // bb
845    return this.description;
846  }
847
848  public boolean hasDescriptionElement() {
849    return this.description != null && !this.description.isEmpty();
850  }
851
852  public boolean hasDescription() {
853    return this.description != null && !this.description.isEmpty();
854  }
855
856  /**
857   * @param value {@link #description} (Human-readable description of a specific
858   *              desired objective of care.). This is the underlying object with
859   *              id, value and extensions. The accessor "getDescription" gives
860   *              direct access to the value
861   */
862  public Goal setDescriptionElement(StringType value) {
863    this.description = value;
864    return this;
865  }
866
867  /**
868   * @return Human-readable description of a specific desired objective of care.
869   */
870  public String getDescription() {
871    return this.description == null ? null : this.description.getValue();
872  }
873
874  /**
875   * @param value Human-readable description of a specific desired objective of
876   *              care.
877   */
878  public Goal setDescription(String value) {
879    if (this.description == null)
880      this.description = new StringType();
881    this.description.setValue(value);
882    return this;
883  }
884
885  /**
886   * @return {@link #status} (Indicates whether the goal has been reached and is
887   *         still considered relevant.). This is the underlying object with id,
888   *         value and extensions. The accessor "getStatus" gives direct access to
889   *         the value
890   */
891  public Enumeration<GoalStatus> getStatusElement() {
892    if (this.status == null)
893      if (Configuration.errorOnAutoCreate())
894        throw new Error("Attempt to auto-create Goal.status");
895      else if (Configuration.doAutoCreate())
896        this.status = new Enumeration<GoalStatus>(new GoalStatusEnumFactory()); // bb
897    return this.status;
898  }
899
900  public boolean hasStatusElement() {
901    return this.status != null && !this.status.isEmpty();
902  }
903
904  public boolean hasStatus() {
905    return this.status != null && !this.status.isEmpty();
906  }
907
908  /**
909   * @param value {@link #status} (Indicates whether the goal has been reached and
910   *              is still considered relevant.). This is the underlying object
911   *              with id, value and extensions. The accessor "getStatus" gives
912   *              direct access to the value
913   */
914  public Goal setStatusElement(Enumeration<GoalStatus> value) {
915    this.status = value;
916    return this;
917  }
918
919  /**
920   * @return Indicates whether the goal has been reached and is still considered
921   *         relevant.
922   */
923  public GoalStatus getStatus() {
924    return this.status == null ? null : this.status.getValue();
925  }
926
927  /**
928   * @param value Indicates whether the goal has been reached and is still
929   *              considered relevant.
930   */
931  public Goal setStatus(GoalStatus value) {
932    if (this.status == null)
933      this.status = new Enumeration<GoalStatus>(new GoalStatusEnumFactory());
934    this.status.setValue(value);
935    return this;
936  }
937
938  /**
939   * @return {@link #statusDate} (Identifies when the current status. I.e. When
940   *         initially created, when achieved, when cancelled, etc.). This is the
941   *         underlying object with id, value and extensions. The accessor
942   *         "getStatusDate" gives direct access to the value
943   */
944  public DateType getStatusDateElement() {
945    if (this.statusDate == null)
946      if (Configuration.errorOnAutoCreate())
947        throw new Error("Attempt to auto-create Goal.statusDate");
948      else if (Configuration.doAutoCreate())
949        this.statusDate = new DateType(); // bb
950    return this.statusDate;
951  }
952
953  public boolean hasStatusDateElement() {
954    return this.statusDate != null && !this.statusDate.isEmpty();
955  }
956
957  public boolean hasStatusDate() {
958    return this.statusDate != null && !this.statusDate.isEmpty();
959  }
960
961  /**
962   * @param value {@link #statusDate} (Identifies when the current status. I.e.
963   *              When initially created, when achieved, when cancelled, etc.).
964   *              This is the underlying object with id, value and extensions. The
965   *              accessor "getStatusDate" gives direct access to the value
966   */
967  public Goal setStatusDateElement(DateType value) {
968    this.statusDate = value;
969    return this;
970  }
971
972  /**
973   * @return Identifies when the current status. I.e. When initially created, when
974   *         achieved, when cancelled, etc.
975   */
976  public Date getStatusDate() {
977    return this.statusDate == null ? null : this.statusDate.getValue();
978  }
979
980  /**
981   * @param value Identifies when the current status. I.e. When initially created,
982   *              when achieved, when cancelled, etc.
983   */
984  public Goal setStatusDate(Date value) {
985    if (value == null)
986      this.statusDate = null;
987    else {
988      if (this.statusDate == null)
989        this.statusDate = new DateType();
990      this.statusDate.setValue(value);
991    }
992    return this;
993  }
994
995  /**
996   * @return {@link #statusReason} (Captures the reason for the current status.)
997   */
998  public CodeableConcept getStatusReason() {
999    if (this.statusReason == null)
1000      if (Configuration.errorOnAutoCreate())
1001        throw new Error("Attempt to auto-create Goal.statusReason");
1002      else if (Configuration.doAutoCreate())
1003        this.statusReason = new CodeableConcept(); // cc
1004    return this.statusReason;
1005  }
1006
1007  public boolean hasStatusReason() {
1008    return this.statusReason != null && !this.statusReason.isEmpty();
1009  }
1010
1011  /**
1012   * @param value {@link #statusReason} (Captures the reason for the current
1013   *              status.)
1014   */
1015  public Goal setStatusReason(CodeableConcept value) {
1016    this.statusReason = value;
1017    return this;
1018  }
1019
1020  /**
1021   * @return {@link #author} (Indicates whose goal this is - patient goal,
1022   *         practitioner goal, etc.)
1023   */
1024  public Reference getAuthor() {
1025    if (this.author == null)
1026      if (Configuration.errorOnAutoCreate())
1027        throw new Error("Attempt to auto-create Goal.author");
1028      else if (Configuration.doAutoCreate())
1029        this.author = new Reference(); // cc
1030    return this.author;
1031  }
1032
1033  public boolean hasAuthor() {
1034    return this.author != null && !this.author.isEmpty();
1035  }
1036
1037  /**
1038   * @param value {@link #author} (Indicates whose goal this is - patient goal,
1039   *              practitioner goal, etc.)
1040   */
1041  public Goal setAuthor(Reference value) {
1042    this.author = value;
1043    return this;
1044  }
1045
1046  /**
1047   * @return {@link #author} The actual object that is the target of the
1048   *         reference. The reference library doesn't populate this, but you can
1049   *         use it to hold the resource if you resolve it. (Indicates whose goal
1050   *         this is - patient goal, practitioner goal, etc.)
1051   */
1052  public Resource getAuthorTarget() {
1053    return this.authorTarget;
1054  }
1055
1056  /**
1057   * @param value {@link #author} The actual object that is the target of the
1058   *              reference. The reference library doesn't use these, but you can
1059   *              use it to hold the resource if you resolve it. (Indicates whose
1060   *              goal this is - patient goal, practitioner goal, etc.)
1061   */
1062  public Goal setAuthorTarget(Resource value) {
1063    this.authorTarget = value;
1064    return this;
1065  }
1066
1067  /**
1068   * @return {@link #priority} (Identifies the mutually agreed level of importance
1069   *         associated with reaching/sustaining the goal.)
1070   */
1071  public CodeableConcept getPriority() {
1072    if (this.priority == null)
1073      if (Configuration.errorOnAutoCreate())
1074        throw new Error("Attempt to auto-create Goal.priority");
1075      else if (Configuration.doAutoCreate())
1076        this.priority = new CodeableConcept(); // cc
1077    return this.priority;
1078  }
1079
1080  public boolean hasPriority() {
1081    return this.priority != null && !this.priority.isEmpty();
1082  }
1083
1084  /**
1085   * @param value {@link #priority} (Identifies the mutually agreed level of
1086   *              importance associated with reaching/sustaining the goal.)
1087   */
1088  public Goal setPriority(CodeableConcept value) {
1089    this.priority = value;
1090    return this;
1091  }
1092
1093  /**
1094   * @return {@link #addresses} (The identified conditions and other health record
1095   *         elements that are intended to be addressed by the goal.)
1096   */
1097  public List<Reference> getAddresses() {
1098    if (this.addresses == null)
1099      this.addresses = new ArrayList<Reference>();
1100    return this.addresses;
1101  }
1102
1103  public boolean hasAddresses() {
1104    if (this.addresses == null)
1105      return false;
1106    for (Reference item : this.addresses)
1107      if (!item.isEmpty())
1108        return true;
1109    return false;
1110  }
1111
1112  /**
1113   * @return {@link #addresses} (The identified conditions and other health record
1114   *         elements that are intended to be addressed by the goal.)
1115   */
1116  // syntactic sugar
1117  public Reference addAddresses() { // 3
1118    Reference t = new Reference();
1119    if (this.addresses == null)
1120      this.addresses = new ArrayList<Reference>();
1121    this.addresses.add(t);
1122    return t;
1123  }
1124
1125  // syntactic sugar
1126  public Goal addAddresses(Reference t) { // 3
1127    if (t == null)
1128      return this;
1129    if (this.addresses == null)
1130      this.addresses = new ArrayList<Reference>();
1131    this.addresses.add(t);
1132    return this;
1133  }
1134
1135  /**
1136   * @return {@link #addresses} (The actual objects that are the target of the
1137   *         reference. The reference library doesn't populate this, but you can
1138   *         use this to hold the resources if you resolvethemt. The identified
1139   *         conditions and other health record elements that are intended to be
1140   *         addressed by the goal.)
1141   */
1142  public List<Resource> getAddressesTarget() {
1143    if (this.addressesTarget == null)
1144      this.addressesTarget = new ArrayList<Resource>();
1145    return this.addressesTarget;
1146  }
1147
1148  /**
1149   * @return {@link #note} (Any comments related to the goal.)
1150   */
1151  public List<Annotation> getNote() {
1152    if (this.note == null)
1153      this.note = new ArrayList<Annotation>();
1154    return this.note;
1155  }
1156
1157  public boolean hasNote() {
1158    if (this.note == null)
1159      return false;
1160    for (Annotation item : this.note)
1161      if (!item.isEmpty())
1162        return true;
1163    return false;
1164  }
1165
1166  /**
1167   * @return {@link #note} (Any comments related to the goal.)
1168   */
1169  // syntactic sugar
1170  public Annotation addNote() { // 3
1171    Annotation t = new Annotation();
1172    if (this.note == null)
1173      this.note = new ArrayList<Annotation>();
1174    this.note.add(t);
1175    return t;
1176  }
1177
1178  // syntactic sugar
1179  public Goal addNote(Annotation t) { // 3
1180    if (t == null)
1181      return this;
1182    if (this.note == null)
1183      this.note = new ArrayList<Annotation>();
1184    this.note.add(t);
1185    return this;
1186  }
1187
1188  /**
1189   * @return {@link #outcome} (Identifies the change (or lack of change) at the
1190   *         point where the goal was deepmed to be cancelled or achieved.)
1191   */
1192  public List<GoalOutcomeComponent> getOutcome() {
1193    if (this.outcome == null)
1194      this.outcome = new ArrayList<GoalOutcomeComponent>();
1195    return this.outcome;
1196  }
1197
1198  public boolean hasOutcome() {
1199    if (this.outcome == null)
1200      return false;
1201    for (GoalOutcomeComponent item : this.outcome)
1202      if (!item.isEmpty())
1203        return true;
1204    return false;
1205  }
1206
1207  /**
1208   * @return {@link #outcome} (Identifies the change (or lack of change) at the
1209   *         point where the goal was deepmed to be cancelled or achieved.)
1210   */
1211  // syntactic sugar
1212  public GoalOutcomeComponent addOutcome() { // 3
1213    GoalOutcomeComponent t = new GoalOutcomeComponent();
1214    if (this.outcome == null)
1215      this.outcome = new ArrayList<GoalOutcomeComponent>();
1216    this.outcome.add(t);
1217    return t;
1218  }
1219
1220  // syntactic sugar
1221  public Goal addOutcome(GoalOutcomeComponent t) { // 3
1222    if (t == null)
1223      return this;
1224    if (this.outcome == null)
1225      this.outcome = new ArrayList<GoalOutcomeComponent>();
1226    this.outcome.add(t);
1227    return this;
1228  }
1229
1230  protected void listChildren(List<Property> childrenList) {
1231    super.listChildren(childrenList);
1232    childrenList.add(new Property("identifier", "Identifier",
1233        "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).",
1234        0, java.lang.Integer.MAX_VALUE, identifier));
1235    childrenList.add(new Property("subject", "Reference(Patient|Group|Organization)",
1236        "Identifies the patient, group or organization for whom the goal is being established.", 0,
1237        java.lang.Integer.MAX_VALUE, subject));
1238    childrenList.add(new Property("start[x]", "date|CodeableConcept",
1239        "The date or event after which the goal should begin being pursued.", 0, java.lang.Integer.MAX_VALUE, start));
1240    childrenList.add(new Property("target[x]", "date|Duration",
1241        "Indicates either the date or the duration after start by which the goal should be met.", 0,
1242        java.lang.Integer.MAX_VALUE, target));
1243    childrenList.add(new Property("category", "CodeableConcept", "Indicates a category the goal falls within.", 0,
1244        java.lang.Integer.MAX_VALUE, category));
1245    childrenList.add(
1246        new Property("description", "string", "Human-readable description of a specific desired objective of care.", 0,
1247            java.lang.Integer.MAX_VALUE, description));
1248    childrenList.add(
1249        new Property("status", "code", "Indicates whether the goal has been reached and is still considered relevant.",
1250            0, java.lang.Integer.MAX_VALUE, status));
1251    childrenList.add(new Property("statusDate", "date",
1252        "Identifies when the current status.  I.e. When initially created, when achieved, when cancelled, etc.", 0,
1253        java.lang.Integer.MAX_VALUE, statusDate));
1254    childrenList.add(new Property("statusReason", "CodeableConcept", "Captures the reason for the current status.", 0,
1255        java.lang.Integer.MAX_VALUE, statusReason));
1256    childrenList.add(new Property("author", "Reference(Patient|Practitioner|RelatedPerson)",
1257        "Indicates whose goal this is - patient goal, practitioner goal, etc.", 0, java.lang.Integer.MAX_VALUE,
1258        author));
1259    childrenList.add(new Property("priority", "CodeableConcept",
1260        "Identifies the mutually agreed level of importance associated with reaching/sustaining the goal.", 0,
1261        java.lang.Integer.MAX_VALUE, priority));
1262    childrenList.add(new Property("addresses",
1263        "Reference(Condition|Observation|MedicationStatement|NutritionOrder|ProcedureRequest|RiskAssessment)",
1264        "The identified conditions and other health record elements that are intended to be addressed by the goal.", 0,
1265        java.lang.Integer.MAX_VALUE, addresses));
1266    childrenList.add(
1267        new Property("note", "Annotation", "Any comments related to the goal.", 0, java.lang.Integer.MAX_VALUE, note));
1268    childrenList.add(new Property("outcome", "",
1269        "Identifies the change (or lack of change) at the point where the goal was deepmed to be cancelled or achieved.",
1270        0, java.lang.Integer.MAX_VALUE, outcome));
1271  }
1272
1273  @Override
1274  public void setProperty(String name, Base value) throws FHIRException {
1275    if (name.equals("identifier"))
1276      this.getIdentifier().add(castToIdentifier(value));
1277    else if (name.equals("subject"))
1278      this.subject = castToReference(value); // Reference
1279    else if (name.equals("start[x]"))
1280      this.start = (Type) value; // Type
1281    else if (name.equals("target[x]"))
1282      this.target = (Type) value; // Type
1283    else if (name.equals("category"))
1284      this.getCategory().add(castToCodeableConcept(value));
1285    else if (name.equals("description"))
1286      this.description = castToString(value); // StringType
1287    else if (name.equals("status"))
1288      this.status = new GoalStatusEnumFactory().fromType(value); // Enumeration<GoalStatus>
1289    else if (name.equals("statusDate"))
1290      this.statusDate = castToDate(value); // DateType
1291    else if (name.equals("statusReason"))
1292      this.statusReason = castToCodeableConcept(value); // CodeableConcept
1293    else if (name.equals("author"))
1294      this.author = castToReference(value); // Reference
1295    else if (name.equals("priority"))
1296      this.priority = castToCodeableConcept(value); // CodeableConcept
1297    else if (name.equals("addresses"))
1298      this.getAddresses().add(castToReference(value));
1299    else if (name.equals("note"))
1300      this.getNote().add(castToAnnotation(value));
1301    else if (name.equals("outcome"))
1302      this.getOutcome().add((GoalOutcomeComponent) value);
1303    else
1304      super.setProperty(name, value);
1305  }
1306
1307  @Override
1308  public Base addChild(String name) throws FHIRException {
1309    if (name.equals("identifier")) {
1310      return addIdentifier();
1311    } else if (name.equals("subject")) {
1312      this.subject = new Reference();
1313      return this.subject;
1314    } else if (name.equals("startDate")) {
1315      this.start = new DateType();
1316      return this.start;
1317    } else if (name.equals("startCodeableConcept")) {
1318      this.start = new CodeableConcept();
1319      return this.start;
1320    } else if (name.equals("targetDate")) {
1321      this.target = new DateType();
1322      return this.target;
1323    } else if (name.equals("targetDuration")) {
1324      this.target = new Duration();
1325      return this.target;
1326    } else if (name.equals("category")) {
1327      return addCategory();
1328    } else if (name.equals("description")) {
1329      throw new FHIRException("Cannot call addChild on a singleton property Goal.description");
1330    } else if (name.equals("status")) {
1331      throw new FHIRException("Cannot call addChild on a singleton property Goal.status");
1332    } else if (name.equals("statusDate")) {
1333      throw new FHIRException("Cannot call addChild on a singleton property Goal.statusDate");
1334    } else if (name.equals("statusReason")) {
1335      this.statusReason = new CodeableConcept();
1336      return this.statusReason;
1337    } else if (name.equals("author")) {
1338      this.author = new Reference();
1339      return this.author;
1340    } else if (name.equals("priority")) {
1341      this.priority = new CodeableConcept();
1342      return this.priority;
1343    } else if (name.equals("addresses")) {
1344      return addAddresses();
1345    } else if (name.equals("note")) {
1346      return addNote();
1347    } else if (name.equals("outcome")) {
1348      return addOutcome();
1349    } else
1350      return super.addChild(name);
1351  }
1352
1353  public String fhirType() {
1354    return "Goal";
1355
1356  }
1357
1358  public Goal copy() {
1359    Goal dst = new Goal();
1360    copyValues(dst);
1361    if (identifier != null) {
1362      dst.identifier = new ArrayList<Identifier>();
1363      for (Identifier i : identifier)
1364        dst.identifier.add(i.copy());
1365    }
1366    ;
1367    dst.subject = subject == null ? null : subject.copy();
1368    dst.start = start == null ? null : start.copy();
1369    dst.target = target == null ? null : target.copy();
1370    if (category != null) {
1371      dst.category = new ArrayList<CodeableConcept>();
1372      for (CodeableConcept i : category)
1373        dst.category.add(i.copy());
1374    }
1375    ;
1376    dst.description = description == null ? null : description.copy();
1377    dst.status = status == null ? null : status.copy();
1378    dst.statusDate = statusDate == null ? null : statusDate.copy();
1379    dst.statusReason = statusReason == null ? null : statusReason.copy();
1380    dst.author = author == null ? null : author.copy();
1381    dst.priority = priority == null ? null : priority.copy();
1382    if (addresses != null) {
1383      dst.addresses = new ArrayList<Reference>();
1384      for (Reference i : addresses)
1385        dst.addresses.add(i.copy());
1386    }
1387    ;
1388    if (note != null) {
1389      dst.note = new ArrayList<Annotation>();
1390      for (Annotation i : note)
1391        dst.note.add(i.copy());
1392    }
1393    ;
1394    if (outcome != null) {
1395      dst.outcome = new ArrayList<GoalOutcomeComponent>();
1396      for (GoalOutcomeComponent i : outcome)
1397        dst.outcome.add(i.copy());
1398    }
1399    ;
1400    return dst;
1401  }
1402
1403  protected Goal typedCopy() {
1404    return copy();
1405  }
1406
1407  @Override
1408  public boolean equalsDeep(Base other) {
1409    if (!super.equalsDeep(other))
1410      return false;
1411    if (!(other instanceof Goal))
1412      return false;
1413    Goal o = (Goal) other;
1414    return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true)
1415        && compareDeep(start, o.start, true) && compareDeep(target, o.target, true)
1416        && compareDeep(category, o.category, true) && compareDeep(description, o.description, true)
1417        && compareDeep(status, o.status, true) && compareDeep(statusDate, o.statusDate, true)
1418        && compareDeep(statusReason, o.statusReason, true) && compareDeep(author, o.author, true)
1419        && compareDeep(priority, o.priority, true) && compareDeep(addresses, o.addresses, true)
1420        && compareDeep(note, o.note, true) && compareDeep(outcome, o.outcome, true);
1421  }
1422
1423  @Override
1424  public boolean equalsShallow(Base other) {
1425    if (!super.equalsShallow(other))
1426      return false;
1427    if (!(other instanceof Goal))
1428      return false;
1429    Goal o = (Goal) other;
1430    return compareValues(description, o.description, true) && compareValues(status, o.status, true)
1431        && compareValues(statusDate, o.statusDate, true);
1432  }
1433
1434  public boolean isEmpty() {
1435    return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
1436        && (start == null || start.isEmpty()) && (target == null || target.isEmpty())
1437        && (category == null || category.isEmpty()) && (description == null || description.isEmpty())
1438        && (status == null || status.isEmpty()) && (statusDate == null || statusDate.isEmpty())
1439        && (statusReason == null || statusReason.isEmpty()) && (author == null || author.isEmpty())
1440        && (priority == null || priority.isEmpty()) && (addresses == null || addresses.isEmpty())
1441        && (note == null || note.isEmpty()) && (outcome == null || outcome.isEmpty());
1442  }
1443
1444  @Override
1445  public ResourceType getResourceType() {
1446    return ResourceType.Goal;
1447  }
1448
1449  @SearchParamDefinition(name = "identifier", path = "Goal.identifier", description = "External Ids for this goal", type = "token")
1450  public static final String SP_IDENTIFIER = "identifier";
1451  @SearchParamDefinition(name = "patient", path = "Goal.subject", description = "Who this goal is intended for", type = "reference")
1452  public static final String SP_PATIENT = "patient";
1453  @SearchParamDefinition(name = "subject", path = "Goal.subject", description = "Who this goal is intended for", type = "reference")
1454  public static final String SP_SUBJECT = "subject";
1455  @SearchParamDefinition(name = "targetdate", path = "Goal.targetDate", description = "Reach goal on or before", type = "date")
1456  public static final String SP_TARGETDATE = "targetdate";
1457  @SearchParamDefinition(name = "category", path = "Goal.category", description = "E.g. Treatment, dietary, behavioral, etc.", type = "token")
1458  public static final String SP_CATEGORY = "category";
1459  @SearchParamDefinition(name = "status", path = "Goal.status", description = "proposed | planned | accepted | rejected | in-progress | achieved | sustaining | on-hold | cancelled", type = "token")
1460  public static final String SP_STATUS = "status";
1461
1462}