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;
044import org.hl7.fhir.utilities.Utilities;
045
046/**
047 * Describes the intention of how one or more practitioners intend to deliver
048 * care for a particular patient, group or community for a period of time,
049 * possibly limited to care for a specific condition or set of conditions.
050 */
051@ResourceDef(name = "CarePlan", profile = "http://hl7.org/fhir/Profile/CarePlan")
052public class CarePlan extends DomainResource {
053
054  public enum CarePlanStatus {
055    /**
056     * The plan has been suggested but no commitment to it has yet been made.
057     */
058    PROPOSED,
059    /**
060     * The plan is in development or awaiting use but is not yet intended to be
061     * acted upon.
062     */
063    DRAFT,
064    /**
065     * The plan is intended to be followed and used as part of patient care.
066     */
067    ACTIVE,
068    /**
069     * The plan is no longer in use and is not expected to be followed or used in
070     * patient care.
071     */
072    COMPLETED,
073    /**
074     * The plan has been terminated prior to reaching completion (though it may have
075     * been replaced by a new plan).
076     */
077    CANCELLED,
078    /**
079     * added to help the parsers
080     */
081    NULL;
082
083    public static CarePlanStatus fromCode(String codeString) throws FHIRException {
084      if (codeString == null || "".equals(codeString))
085        return null;
086      if ("proposed".equals(codeString))
087        return PROPOSED;
088      if ("draft".equals(codeString))
089        return DRAFT;
090      if ("active".equals(codeString))
091        return ACTIVE;
092      if ("completed".equals(codeString))
093        return COMPLETED;
094      if ("cancelled".equals(codeString))
095        return CANCELLED;
096      throw new FHIRException("Unknown CarePlanStatus code '" + codeString + "'");
097    }
098
099    public String toCode() {
100      switch (this) {
101      case PROPOSED:
102        return "proposed";
103      case DRAFT:
104        return "draft";
105      case ACTIVE:
106        return "active";
107      case COMPLETED:
108        return "completed";
109      case CANCELLED:
110        return "cancelled";
111      case NULL:
112        return null;
113      default:
114        return "?";
115      }
116    }
117
118    public String getSystem() {
119      switch (this) {
120      case PROPOSED:
121        return "http://hl7.org/fhir/care-plan-status";
122      case DRAFT:
123        return "http://hl7.org/fhir/care-plan-status";
124      case ACTIVE:
125        return "http://hl7.org/fhir/care-plan-status";
126      case COMPLETED:
127        return "http://hl7.org/fhir/care-plan-status";
128      case CANCELLED:
129        return "http://hl7.org/fhir/care-plan-status";
130      case NULL:
131        return null;
132      default:
133        return "?";
134      }
135    }
136
137    public String getDefinition() {
138      switch (this) {
139      case PROPOSED:
140        return "The plan has been suggested but no commitment to it has yet been made.";
141      case DRAFT:
142        return "The plan is in development or awaiting use but is not yet intended to be acted upon.";
143      case ACTIVE:
144        return "The plan is intended to be followed and used as part of patient care.";
145      case COMPLETED:
146        return "The plan is no longer in use and is not expected to be followed or used in patient care.";
147      case CANCELLED:
148        return "The plan has been terminated prior to reaching completion (though it may have been replaced by a new plan).";
149      case NULL:
150        return null;
151      default:
152        return "?";
153      }
154    }
155
156    public String getDisplay() {
157      switch (this) {
158      case PROPOSED:
159        return "Proposed";
160      case DRAFT:
161        return "Pending";
162      case ACTIVE:
163        return "Active";
164      case COMPLETED:
165        return "Completed";
166      case CANCELLED:
167        return "Cancelled";
168      case NULL:
169        return null;
170      default:
171        return "?";
172      }
173    }
174  }
175
176  public static class CarePlanStatusEnumFactory implements EnumFactory<CarePlanStatus> {
177    public CarePlanStatus fromCode(String codeString) throws IllegalArgumentException {
178      if (codeString == null || "".equals(codeString))
179        if (codeString == null || "".equals(codeString))
180          return null;
181      if ("proposed".equals(codeString))
182        return CarePlanStatus.PROPOSED;
183      if ("draft".equals(codeString))
184        return CarePlanStatus.DRAFT;
185      if ("active".equals(codeString))
186        return CarePlanStatus.ACTIVE;
187      if ("completed".equals(codeString))
188        return CarePlanStatus.COMPLETED;
189      if ("cancelled".equals(codeString))
190        return CarePlanStatus.CANCELLED;
191      throw new IllegalArgumentException("Unknown CarePlanStatus code '" + codeString + "'");
192    }
193
194    public Enumeration<CarePlanStatus> fromType(Base code) throws FHIRException {
195      if (code == null || code.isEmpty())
196        return null;
197      String codeString = ((PrimitiveType) code).asStringValue();
198      if (codeString == null || "".equals(codeString))
199        return null;
200      if ("proposed".equals(codeString))
201        return new Enumeration<CarePlanStatus>(this, CarePlanStatus.PROPOSED);
202      if ("draft".equals(codeString))
203        return new Enumeration<CarePlanStatus>(this, CarePlanStatus.DRAFT);
204      if ("active".equals(codeString))
205        return new Enumeration<CarePlanStatus>(this, CarePlanStatus.ACTIVE);
206      if ("completed".equals(codeString))
207        return new Enumeration<CarePlanStatus>(this, CarePlanStatus.COMPLETED);
208      if ("cancelled".equals(codeString))
209        return new Enumeration<CarePlanStatus>(this, CarePlanStatus.CANCELLED);
210      throw new FHIRException("Unknown CarePlanStatus code '" + codeString + "'");
211    }
212
213    public String toCode(CarePlanStatus code) {
214      if (code == CarePlanStatus.PROPOSED)
215        return "proposed";
216      if (code == CarePlanStatus.DRAFT)
217        return "draft";
218      if (code == CarePlanStatus.ACTIVE)
219        return "active";
220      if (code == CarePlanStatus.COMPLETED)
221        return "completed";
222      if (code == CarePlanStatus.CANCELLED)
223        return "cancelled";
224      return "?";
225    }
226  }
227
228  public enum CarePlanRelationship {
229    /**
230     * The referenced plan is considered to be part of this plan.
231     */
232    INCLUDES,
233    /**
234     * This plan takes the places of the referenced plan.
235     */
236    REPLACES,
237    /**
238     * This plan provides details about how to perform activities defined at a
239     * higher level by the referenced plan.
240     */
241    FULFILLS,
242    /**
243     * added to help the parsers
244     */
245    NULL;
246
247    public static CarePlanRelationship fromCode(String codeString) throws FHIRException {
248      if (codeString == null || "".equals(codeString))
249        return null;
250      if ("includes".equals(codeString))
251        return INCLUDES;
252      if ("replaces".equals(codeString))
253        return REPLACES;
254      if ("fulfills".equals(codeString))
255        return FULFILLS;
256      throw new FHIRException("Unknown CarePlanRelationship code '" + codeString + "'");
257    }
258
259    public String toCode() {
260      switch (this) {
261      case INCLUDES:
262        return "includes";
263      case REPLACES:
264        return "replaces";
265      case FULFILLS:
266        return "fulfills";
267      case NULL:
268        return null;
269      default:
270        return "?";
271      }
272    }
273
274    public String getSystem() {
275      switch (this) {
276      case INCLUDES:
277        return "http://hl7.org/fhir/care-plan-relationship";
278      case REPLACES:
279        return "http://hl7.org/fhir/care-plan-relationship";
280      case FULFILLS:
281        return "http://hl7.org/fhir/care-plan-relationship";
282      case NULL:
283        return null;
284      default:
285        return "?";
286      }
287    }
288
289    public String getDefinition() {
290      switch (this) {
291      case INCLUDES:
292        return "The referenced plan is considered to be part of this plan.";
293      case REPLACES:
294        return "This plan takes the places of the referenced plan.";
295      case FULFILLS:
296        return "This plan provides details about how to perform activities defined at a higher level by the referenced plan.";
297      case NULL:
298        return null;
299      default:
300        return "?";
301      }
302    }
303
304    public String getDisplay() {
305      switch (this) {
306      case INCLUDES:
307        return "Includes";
308      case REPLACES:
309        return "Replaces";
310      case FULFILLS:
311        return "Fulfills";
312      case NULL:
313        return null;
314      default:
315        return "?";
316      }
317    }
318  }
319
320  public static class CarePlanRelationshipEnumFactory implements EnumFactory<CarePlanRelationship> {
321    public CarePlanRelationship fromCode(String codeString) throws IllegalArgumentException {
322      if (codeString == null || "".equals(codeString))
323        if (codeString == null || "".equals(codeString))
324          return null;
325      if ("includes".equals(codeString))
326        return CarePlanRelationship.INCLUDES;
327      if ("replaces".equals(codeString))
328        return CarePlanRelationship.REPLACES;
329      if ("fulfills".equals(codeString))
330        return CarePlanRelationship.FULFILLS;
331      throw new IllegalArgumentException("Unknown CarePlanRelationship code '" + codeString + "'");
332    }
333
334    public Enumeration<CarePlanRelationship> fromType(Base code) throws FHIRException {
335      if (code == null || code.isEmpty())
336        return null;
337      String codeString = ((PrimitiveType) code).asStringValue();
338      if (codeString == null || "".equals(codeString))
339        return null;
340      if ("includes".equals(codeString))
341        return new Enumeration<CarePlanRelationship>(this, CarePlanRelationship.INCLUDES);
342      if ("replaces".equals(codeString))
343        return new Enumeration<CarePlanRelationship>(this, CarePlanRelationship.REPLACES);
344      if ("fulfills".equals(codeString))
345        return new Enumeration<CarePlanRelationship>(this, CarePlanRelationship.FULFILLS);
346      throw new FHIRException("Unknown CarePlanRelationship code '" + codeString + "'");
347    }
348
349    public String toCode(CarePlanRelationship code) {
350      if (code == CarePlanRelationship.INCLUDES)
351        return "includes";
352      if (code == CarePlanRelationship.REPLACES)
353        return "replaces";
354      if (code == CarePlanRelationship.FULFILLS)
355        return "fulfills";
356      return "?";
357    }
358  }
359
360  public enum CarePlanActivityStatus {
361    /**
362     * Activity is planned but no action has yet been taken.
363     */
364    NOTSTARTED,
365    /**
366     * Appointment or other booking has occurred but activity has not yet begun.
367     */
368    SCHEDULED,
369    /**
370     * Activity has been started but is not yet complete.
371     */
372    INPROGRESS,
373    /**
374     * Activity was started but has temporarily ceased with an expectation of
375     * resumption at a future time.
376     */
377    ONHOLD,
378    /**
379     * The activities have been completed (more or less) as planned.
380     */
381    COMPLETED,
382    /**
383     * The activities have been ended prior to completion (perhaps even before they
384     * were started).
385     */
386    CANCELLED,
387    /**
388     * added to help the parsers
389     */
390    NULL;
391
392    public static CarePlanActivityStatus fromCode(String codeString) throws FHIRException {
393      if (codeString == null || "".equals(codeString))
394        return null;
395      if ("not-started".equals(codeString))
396        return NOTSTARTED;
397      if ("scheduled".equals(codeString))
398        return SCHEDULED;
399      if ("in-progress".equals(codeString))
400        return INPROGRESS;
401      if ("on-hold".equals(codeString))
402        return ONHOLD;
403      if ("completed".equals(codeString))
404        return COMPLETED;
405      if ("cancelled".equals(codeString))
406        return CANCELLED;
407      throw new FHIRException("Unknown CarePlanActivityStatus code '" + codeString + "'");
408    }
409
410    public String toCode() {
411      switch (this) {
412      case NOTSTARTED:
413        return "not-started";
414      case SCHEDULED:
415        return "scheduled";
416      case INPROGRESS:
417        return "in-progress";
418      case ONHOLD:
419        return "on-hold";
420      case COMPLETED:
421        return "completed";
422      case CANCELLED:
423        return "cancelled";
424      case NULL:
425        return null;
426      default:
427        return "?";
428      }
429    }
430
431    public String getSystem() {
432      switch (this) {
433      case NOTSTARTED:
434        return "http://hl7.org/fhir/care-plan-activity-status";
435      case SCHEDULED:
436        return "http://hl7.org/fhir/care-plan-activity-status";
437      case INPROGRESS:
438        return "http://hl7.org/fhir/care-plan-activity-status";
439      case ONHOLD:
440        return "http://hl7.org/fhir/care-plan-activity-status";
441      case COMPLETED:
442        return "http://hl7.org/fhir/care-plan-activity-status";
443      case CANCELLED:
444        return "http://hl7.org/fhir/care-plan-activity-status";
445      case NULL:
446        return null;
447      default:
448        return "?";
449      }
450    }
451
452    public String getDefinition() {
453      switch (this) {
454      case NOTSTARTED:
455        return "Activity is planned but no action has yet been taken.";
456      case SCHEDULED:
457        return "Appointment or other booking has occurred but activity has not yet begun.";
458      case INPROGRESS:
459        return "Activity has been started but is not yet complete.";
460      case ONHOLD:
461        return "Activity was started but has temporarily ceased with an expectation of resumption at a future time.";
462      case COMPLETED:
463        return "The activities have been completed (more or less) as planned.";
464      case CANCELLED:
465        return "The activities have been ended prior to completion (perhaps even before they were started).";
466      case NULL:
467        return null;
468      default:
469        return "?";
470      }
471    }
472
473    public String getDisplay() {
474      switch (this) {
475      case NOTSTARTED:
476        return "Not Started";
477      case SCHEDULED:
478        return "Scheduled";
479      case INPROGRESS:
480        return "In Progress";
481      case ONHOLD:
482        return "On Hold";
483      case COMPLETED:
484        return "Completed";
485      case CANCELLED:
486        return "Cancelled";
487      case NULL:
488        return null;
489      default:
490        return "?";
491      }
492    }
493  }
494
495  public static class CarePlanActivityStatusEnumFactory implements EnumFactory<CarePlanActivityStatus> {
496    public CarePlanActivityStatus fromCode(String codeString) throws IllegalArgumentException {
497      if (codeString == null || "".equals(codeString))
498        if (codeString == null || "".equals(codeString))
499          return null;
500      if ("not-started".equals(codeString))
501        return CarePlanActivityStatus.NOTSTARTED;
502      if ("scheduled".equals(codeString))
503        return CarePlanActivityStatus.SCHEDULED;
504      if ("in-progress".equals(codeString))
505        return CarePlanActivityStatus.INPROGRESS;
506      if ("on-hold".equals(codeString))
507        return CarePlanActivityStatus.ONHOLD;
508      if ("completed".equals(codeString))
509        return CarePlanActivityStatus.COMPLETED;
510      if ("cancelled".equals(codeString))
511        return CarePlanActivityStatus.CANCELLED;
512      throw new IllegalArgumentException("Unknown CarePlanActivityStatus code '" + codeString + "'");
513    }
514
515    public Enumeration<CarePlanActivityStatus> fromType(Base code) throws FHIRException {
516      if (code == null || code.isEmpty())
517        return null;
518      String codeString = ((PrimitiveType) code).asStringValue();
519      if (codeString == null || "".equals(codeString))
520        return null;
521      if ("not-started".equals(codeString))
522        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.NOTSTARTED);
523      if ("scheduled".equals(codeString))
524        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.SCHEDULED);
525      if ("in-progress".equals(codeString))
526        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.INPROGRESS);
527      if ("on-hold".equals(codeString))
528        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.ONHOLD);
529      if ("completed".equals(codeString))
530        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.COMPLETED);
531      if ("cancelled".equals(codeString))
532        return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.CANCELLED);
533      throw new FHIRException("Unknown CarePlanActivityStatus code '" + codeString + "'");
534    }
535
536    public String toCode(CarePlanActivityStatus code) {
537      if (code == CarePlanActivityStatus.NOTSTARTED)
538        return "not-started";
539      if (code == CarePlanActivityStatus.SCHEDULED)
540        return "scheduled";
541      if (code == CarePlanActivityStatus.INPROGRESS)
542        return "in-progress";
543      if (code == CarePlanActivityStatus.ONHOLD)
544        return "on-hold";
545      if (code == CarePlanActivityStatus.COMPLETED)
546        return "completed";
547      if (code == CarePlanActivityStatus.CANCELLED)
548        return "cancelled";
549      return "?";
550    }
551  }
552
553  @Block()
554  public static class CarePlanRelatedPlanComponent extends BackboneElement implements IBaseBackboneElement {
555    /**
556     * Identifies the type of relationship this plan has to the target plan.
557     */
558    @Child(name = "code", type = { CodeType.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
559    @Description(shortDefinition = "includes | replaces | fulfills", formalDefinition = "Identifies the type of relationship this plan has to the target plan.")
560    protected Enumeration<CarePlanRelationship> code;
561
562    /**
563     * A reference to the plan to which a relationship is asserted.
564     */
565    @Child(name = "plan", type = { CarePlan.class }, order = 2, min = 1, max = 1, modifier = false, summary = false)
566    @Description(shortDefinition = "Plan relationship exists with", formalDefinition = "A reference to the plan to which a relationship is asserted.")
567    protected Reference plan;
568
569    /**
570     * The actual object that is the target of the reference (A reference to the
571     * plan to which a relationship is asserted.)
572     */
573    protected CarePlan planTarget;
574
575    private static final long serialVersionUID = 1875598050L;
576
577    /*
578     * Constructor
579     */
580    public CarePlanRelatedPlanComponent() {
581      super();
582    }
583
584    /*
585     * Constructor
586     */
587    public CarePlanRelatedPlanComponent(Reference plan) {
588      super();
589      this.plan = plan;
590    }
591
592    /**
593     * @return {@link #code} (Identifies the type of relationship this plan has to
594     *         the target plan.). This is the underlying object with id, value and
595     *         extensions. The accessor "getCode" gives direct access to the value
596     */
597    public Enumeration<CarePlanRelationship> getCodeElement() {
598      if (this.code == null)
599        if (Configuration.errorOnAutoCreate())
600          throw new Error("Attempt to auto-create CarePlanRelatedPlanComponent.code");
601        else if (Configuration.doAutoCreate())
602          this.code = new Enumeration<CarePlanRelationship>(new CarePlanRelationshipEnumFactory()); // bb
603      return this.code;
604    }
605
606    public boolean hasCodeElement() {
607      return this.code != null && !this.code.isEmpty();
608    }
609
610    public boolean hasCode() {
611      return this.code != null && !this.code.isEmpty();
612    }
613
614    /**
615     * @param value {@link #code} (Identifies the type of relationship this plan has
616     *              to the target plan.). This is the underlying object with id,
617     *              value and extensions. The accessor "getCode" gives direct access
618     *              to the value
619     */
620    public CarePlanRelatedPlanComponent setCodeElement(Enumeration<CarePlanRelationship> value) {
621      this.code = value;
622      return this;
623    }
624
625    /**
626     * @return Identifies the type of relationship this plan has to the target plan.
627     */
628    public CarePlanRelationship getCode() {
629      return this.code == null ? null : this.code.getValue();
630    }
631
632    /**
633     * @param value Identifies the type of relationship this plan has to the target
634     *              plan.
635     */
636    public CarePlanRelatedPlanComponent setCode(CarePlanRelationship value) {
637      if (value == null)
638        this.code = null;
639      else {
640        if (this.code == null)
641          this.code = new Enumeration<CarePlanRelationship>(new CarePlanRelationshipEnumFactory());
642        this.code.setValue(value);
643      }
644      return this;
645    }
646
647    /**
648     * @return {@link #plan} (A reference to the plan to which a relationship is
649     *         asserted.)
650     */
651    public Reference getPlan() {
652      if (this.plan == null)
653        if (Configuration.errorOnAutoCreate())
654          throw new Error("Attempt to auto-create CarePlanRelatedPlanComponent.plan");
655        else if (Configuration.doAutoCreate())
656          this.plan = new Reference(); // cc
657      return this.plan;
658    }
659
660    public boolean hasPlan() {
661      return this.plan != null && !this.plan.isEmpty();
662    }
663
664    /**
665     * @param value {@link #plan} (A reference to the plan to which a relationship
666     *              is asserted.)
667     */
668    public CarePlanRelatedPlanComponent setPlan(Reference value) {
669      this.plan = value;
670      return this;
671    }
672
673    /**
674     * @return {@link #plan} The actual object that is the target of the reference.
675     *         The reference library doesn't populate this, but you can use it to
676     *         hold the resource if you resolve it. (A reference to the plan to
677     *         which a relationship is asserted.)
678     */
679    public CarePlan getPlanTarget() {
680      if (this.planTarget == null)
681        if (Configuration.errorOnAutoCreate())
682          throw new Error("Attempt to auto-create CarePlanRelatedPlanComponent.plan");
683        else if (Configuration.doAutoCreate())
684          this.planTarget = new CarePlan(); // aa
685      return this.planTarget;
686    }
687
688    /**
689     * @param value {@link #plan} The actual object that is the target of the
690     *              reference. The reference library doesn't use these, but you can
691     *              use it to hold the resource if you resolve it. (A reference to
692     *              the plan to which a relationship is asserted.)
693     */
694    public CarePlanRelatedPlanComponent setPlanTarget(CarePlan value) {
695      this.planTarget = value;
696      return this;
697    }
698
699    protected void listChildren(List<Property> childrenList) {
700      super.listChildren(childrenList);
701      childrenList
702          .add(new Property("code", "code", "Identifies the type of relationship this plan has to the target plan.", 0,
703              java.lang.Integer.MAX_VALUE, code));
704      childrenList.add(new Property("plan", "Reference(CarePlan)",
705          "A reference to the plan to which a relationship is asserted.", 0, java.lang.Integer.MAX_VALUE, plan));
706    }
707
708    @Override
709    public void setProperty(String name, Base value) throws FHIRException {
710      if (name.equals("code"))
711        this.code = new CarePlanRelationshipEnumFactory().fromType(value); // Enumeration<CarePlanRelationship>
712      else if (name.equals("plan"))
713        this.plan = castToReference(value); // Reference
714      else
715        super.setProperty(name, value);
716    }
717
718    @Override
719    public Base addChild(String name) throws FHIRException {
720      if (name.equals("code")) {
721        throw new FHIRException("Cannot call addChild on a singleton property CarePlan.code");
722      } else if (name.equals("plan")) {
723        this.plan = new Reference();
724        return this.plan;
725      } else
726        return super.addChild(name);
727    }
728
729    public CarePlanRelatedPlanComponent copy() {
730      CarePlanRelatedPlanComponent dst = new CarePlanRelatedPlanComponent();
731      copyValues(dst);
732      dst.code = code == null ? null : code.copy();
733      dst.plan = plan == null ? null : plan.copy();
734      return dst;
735    }
736
737    @Override
738    public boolean equalsDeep(Base other) {
739      if (!super.equalsDeep(other))
740        return false;
741      if (!(other instanceof CarePlanRelatedPlanComponent))
742        return false;
743      CarePlanRelatedPlanComponent o = (CarePlanRelatedPlanComponent) other;
744      return compareDeep(code, o.code, true) && compareDeep(plan, o.plan, true);
745    }
746
747    @Override
748    public boolean equalsShallow(Base other) {
749      if (!super.equalsShallow(other))
750        return false;
751      if (!(other instanceof CarePlanRelatedPlanComponent))
752        return false;
753      CarePlanRelatedPlanComponent o = (CarePlanRelatedPlanComponent) other;
754      return compareValues(code, o.code, true);
755    }
756
757    public boolean isEmpty() {
758      return super.isEmpty() && (code == null || code.isEmpty()) && (plan == null || plan.isEmpty());
759    }
760
761    public String fhirType() {
762      return "CarePlan.relatedPlan";
763
764    }
765
766  }
767
768  @Block()
769  public static class CarePlanParticipantComponent extends BackboneElement implements IBaseBackboneElement {
770    /**
771     * Indicates specific responsibility of an individual within the care plan; e.g.
772     * "Primary physician", "Team coordinator", "Caregiver", etc.
773     */
774    @Child(name = "role", type = {
775        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
776    @Description(shortDefinition = "Type of involvement", formalDefinition = "Indicates specific responsibility of an individual within the care plan; e.g. \"Primary physician\", \"Team coordinator\", \"Caregiver\", etc.")
777    protected CodeableConcept role;
778
779    /**
780     * The specific person or organization who is participating/expected to
781     * participate in the care plan.
782     */
783    @Child(name = "member", type = { Practitioner.class, RelatedPerson.class, Patient.class,
784        Organization.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
785    @Description(shortDefinition = "Who is involved", formalDefinition = "The specific person or organization who is participating/expected to participate in the care plan.")
786    protected Reference member;
787
788    /**
789     * The actual object that is the target of the reference (The specific person or
790     * organization who is participating/expected to participate in the care plan.)
791     */
792    protected Resource memberTarget;
793
794    private static final long serialVersionUID = -466811117L;
795
796    /*
797     * Constructor
798     */
799    public CarePlanParticipantComponent() {
800      super();
801    }
802
803    /**
804     * @return {@link #role} (Indicates specific responsibility of an individual
805     *         within the care plan; e.g. "Primary physician", "Team coordinator",
806     *         "Caregiver", etc.)
807     */
808    public CodeableConcept getRole() {
809      if (this.role == null)
810        if (Configuration.errorOnAutoCreate())
811          throw new Error("Attempt to auto-create CarePlanParticipantComponent.role");
812        else if (Configuration.doAutoCreate())
813          this.role = new CodeableConcept(); // cc
814      return this.role;
815    }
816
817    public boolean hasRole() {
818      return this.role != null && !this.role.isEmpty();
819    }
820
821    /**
822     * @param value {@link #role} (Indicates specific responsibility of an
823     *              individual within the care plan; e.g. "Primary physician", "Team
824     *              coordinator", "Caregiver", etc.)
825     */
826    public CarePlanParticipantComponent setRole(CodeableConcept value) {
827      this.role = value;
828      return this;
829    }
830
831    /**
832     * @return {@link #member} (The specific person or organization who is
833     *         participating/expected to participate in the care plan.)
834     */
835    public Reference getMember() {
836      if (this.member == null)
837        if (Configuration.errorOnAutoCreate())
838          throw new Error("Attempt to auto-create CarePlanParticipantComponent.member");
839        else if (Configuration.doAutoCreate())
840          this.member = new Reference(); // cc
841      return this.member;
842    }
843
844    public boolean hasMember() {
845      return this.member != null && !this.member.isEmpty();
846    }
847
848    /**
849     * @param value {@link #member} (The specific person or organization who is
850     *              participating/expected to participate in the care plan.)
851     */
852    public CarePlanParticipantComponent setMember(Reference value) {
853      this.member = value;
854      return this;
855    }
856
857    /**
858     * @return {@link #member} The actual object that is the target of the
859     *         reference. The reference library doesn't populate this, but you can
860     *         use it to hold the resource if you resolve it. (The specific person
861     *         or organization who is participating/expected to participate in the
862     *         care plan.)
863     */
864    public Resource getMemberTarget() {
865      return this.memberTarget;
866    }
867
868    /**
869     * @param value {@link #member} The actual object that is the target of the
870     *              reference. The reference library doesn't use these, but you can
871     *              use it to hold the resource if you resolve it. (The specific
872     *              person or organization who is participating/expected to
873     *              participate in the care plan.)
874     */
875    public CarePlanParticipantComponent setMemberTarget(Resource value) {
876      this.memberTarget = value;
877      return this;
878    }
879
880    protected void listChildren(List<Property> childrenList) {
881      super.listChildren(childrenList);
882      childrenList.add(new Property("role", "CodeableConcept",
883          "Indicates specific responsibility of an individual within the care plan; e.g. \"Primary physician\", \"Team coordinator\", \"Caregiver\", etc.",
884          0, java.lang.Integer.MAX_VALUE, role));
885      childrenList.add(new Property("member", "Reference(Practitioner|RelatedPerson|Patient|Organization)",
886          "The specific person or organization who is participating/expected to participate in the care plan.", 0,
887          java.lang.Integer.MAX_VALUE, member));
888    }
889
890    @Override
891    public void setProperty(String name, Base value) throws FHIRException {
892      if (name.equals("role"))
893        this.role = castToCodeableConcept(value); // CodeableConcept
894      else if (name.equals("member"))
895        this.member = castToReference(value); // Reference
896      else
897        super.setProperty(name, value);
898    }
899
900    @Override
901    public Base addChild(String name) throws FHIRException {
902      if (name.equals("role")) {
903        this.role = new CodeableConcept();
904        return this.role;
905      } else if (name.equals("member")) {
906        this.member = new Reference();
907        return this.member;
908      } else
909        return super.addChild(name);
910    }
911
912    public CarePlanParticipantComponent copy() {
913      CarePlanParticipantComponent dst = new CarePlanParticipantComponent();
914      copyValues(dst);
915      dst.role = role == null ? null : role.copy();
916      dst.member = member == null ? null : member.copy();
917      return dst;
918    }
919
920    @Override
921    public boolean equalsDeep(Base other) {
922      if (!super.equalsDeep(other))
923        return false;
924      if (!(other instanceof CarePlanParticipantComponent))
925        return false;
926      CarePlanParticipantComponent o = (CarePlanParticipantComponent) other;
927      return compareDeep(role, o.role, true) && compareDeep(member, o.member, true);
928    }
929
930    @Override
931    public boolean equalsShallow(Base other) {
932      if (!super.equalsShallow(other))
933        return false;
934      if (!(other instanceof CarePlanParticipantComponent))
935        return false;
936      CarePlanParticipantComponent o = (CarePlanParticipantComponent) other;
937      return true;
938    }
939
940    public boolean isEmpty() {
941      return super.isEmpty() && (role == null || role.isEmpty()) && (member == null || member.isEmpty());
942    }
943
944    public String fhirType() {
945      return "CarePlan.participant";
946
947    }
948
949  }
950
951  @Block()
952  public static class CarePlanActivityComponent extends BackboneElement implements IBaseBackboneElement {
953    /**
954     * Resources that describe follow-on actions resulting from the plan, such as
955     * drug prescriptions, encounter records, appointments, etc.
956     */
957    @Child(name = "actionResulting", type = {}, order = 1, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
958    @Description(shortDefinition = "Appointments, orders, etc.", formalDefinition = "Resources that describe follow-on actions resulting from the plan, such as drug prescriptions, encounter records, appointments, etc.")
959    protected List<Reference> actionResulting;
960    /**
961     * The actual objects that are the target of the reference (Resources that
962     * describe follow-on actions resulting from the plan, such as drug
963     * prescriptions, encounter records, appointments, etc.)
964     */
965    protected List<Resource> actionResultingTarget;
966
967    /**
968     * Notes about the adherence/status/progress of the activity.
969     */
970    @Child(name = "progress", type = {
971        Annotation.class }, order = 2, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
972    @Description(shortDefinition = "Comments about the activity status/progress", formalDefinition = "Notes about the adherence/status/progress of the activity.")
973    protected List<Annotation> progress;
974
975    /**
976     * The details of the proposed activity represented in a specific resource.
977     */
978    @Child(name = "reference", type = { Appointment.class, CommunicationRequest.class, DeviceUseRequest.class,
979        DiagnosticOrder.class, MedicationOrder.class, NutritionOrder.class, Order.class, ProcedureRequest.class,
980        ProcessRequest.class, ReferralRequest.class, SupplyRequest.class,
981        VisionPrescription.class }, order = 3, min = 0, max = 1, modifier = false, summary = false)
982    @Description(shortDefinition = "Activity details defined in specific resource", formalDefinition = "The details of the proposed activity represented in a specific resource.")
983    protected Reference reference;
984
985    /**
986     * The actual object that is the target of the reference (The details of the
987     * proposed activity represented in a specific resource.)
988     */
989    protected Resource referenceTarget;
990
991    /**
992     * A simple summary of a planned activity suitable for a general care plan
993     * system (e.g. form driven) that doesn't know about specific resources such as
994     * procedure etc.
995     */
996    @Child(name = "detail", type = {}, order = 4, min = 0, max = 1, modifier = false, summary = false)
997    @Description(shortDefinition = "In-line definition of activity", formalDefinition = "A simple summary of a planned activity suitable for a general care plan system (e.g. form driven) that doesn't know about specific resources such as procedure etc.")
998    protected CarePlanActivityDetailComponent detail;
999
1000    private static final long serialVersionUID = 40181608L;
1001
1002    /*
1003     * Constructor
1004     */
1005    public CarePlanActivityComponent() {
1006      super();
1007    }
1008
1009    /**
1010     * @return {@link #actionResulting} (Resources that describe follow-on actions
1011     *         resulting from the plan, such as drug prescriptions, encounter
1012     *         records, appointments, etc.)
1013     */
1014    public List<Reference> getActionResulting() {
1015      if (this.actionResulting == null)
1016        this.actionResulting = new ArrayList<Reference>();
1017      return this.actionResulting;
1018    }
1019
1020    public boolean hasActionResulting() {
1021      if (this.actionResulting == null)
1022        return false;
1023      for (Reference item : this.actionResulting)
1024        if (!item.isEmpty())
1025          return true;
1026      return false;
1027    }
1028
1029    /**
1030     * @return {@link #actionResulting} (Resources that describe follow-on actions
1031     *         resulting from the plan, such as drug prescriptions, encounter
1032     *         records, appointments, etc.)
1033     */
1034    // syntactic sugar
1035    public Reference addActionResulting() { // 3
1036      Reference t = new Reference();
1037      if (this.actionResulting == null)
1038        this.actionResulting = new ArrayList<Reference>();
1039      this.actionResulting.add(t);
1040      return t;
1041    }
1042
1043    // syntactic sugar
1044    public CarePlanActivityComponent addActionResulting(Reference t) { // 3
1045      if (t == null)
1046        return this;
1047      if (this.actionResulting == null)
1048        this.actionResulting = new ArrayList<Reference>();
1049      this.actionResulting.add(t);
1050      return this;
1051    }
1052
1053    /**
1054     * @return {@link #actionResulting} (The actual objects that are the target of
1055     *         the reference. The reference library doesn't populate this, but you
1056     *         can use this to hold the resources if you resolvethemt. Resources
1057     *         that describe follow-on actions resulting from the plan, such as drug
1058     *         prescriptions, encounter records, appointments, etc.)
1059     */
1060    public List<Resource> getActionResultingTarget() {
1061      if (this.actionResultingTarget == null)
1062        this.actionResultingTarget = new ArrayList<Resource>();
1063      return this.actionResultingTarget;
1064    }
1065
1066    /**
1067     * @return {@link #progress} (Notes about the adherence/status/progress of the
1068     *         activity.)
1069     */
1070    public List<Annotation> getProgress() {
1071      if (this.progress == null)
1072        this.progress = new ArrayList<Annotation>();
1073      return this.progress;
1074    }
1075
1076    public boolean hasProgress() {
1077      if (this.progress == null)
1078        return false;
1079      for (Annotation item : this.progress)
1080        if (!item.isEmpty())
1081          return true;
1082      return false;
1083    }
1084
1085    /**
1086     * @return {@link #progress} (Notes about the adherence/status/progress of the
1087     *         activity.)
1088     */
1089    // syntactic sugar
1090    public Annotation addProgress() { // 3
1091      Annotation t = new Annotation();
1092      if (this.progress == null)
1093        this.progress = new ArrayList<Annotation>();
1094      this.progress.add(t);
1095      return t;
1096    }
1097
1098    // syntactic sugar
1099    public CarePlanActivityComponent addProgress(Annotation t) { // 3
1100      if (t == null)
1101        return this;
1102      if (this.progress == null)
1103        this.progress = new ArrayList<Annotation>();
1104      this.progress.add(t);
1105      return this;
1106    }
1107
1108    /**
1109     * @return {@link #reference} (The details of the proposed activity represented
1110     *         in a specific resource.)
1111     */
1112    public Reference getReference() {
1113      if (this.reference == null)
1114        if (Configuration.errorOnAutoCreate())
1115          throw new Error("Attempt to auto-create CarePlanActivityComponent.reference");
1116        else if (Configuration.doAutoCreate())
1117          this.reference = new Reference(); // cc
1118      return this.reference;
1119    }
1120
1121    public boolean hasReference() {
1122      return this.reference != null && !this.reference.isEmpty();
1123    }
1124
1125    /**
1126     * @param value {@link #reference} (The details of the proposed activity
1127     *              represented in a specific resource.)
1128     */
1129    public CarePlanActivityComponent setReference(Reference value) {
1130      this.reference = value;
1131      return this;
1132    }
1133
1134    /**
1135     * @return {@link #reference} The actual object that is the target of the
1136     *         reference. The reference library doesn't populate this, but you can
1137     *         use it to hold the resource if you resolve it. (The details of the
1138     *         proposed activity represented in a specific resource.)
1139     */
1140    public Resource getReferenceTarget() {
1141      return this.referenceTarget;
1142    }
1143
1144    /**
1145     * @param value {@link #reference} The actual object that is the target of the
1146     *              reference. The reference library doesn't use these, but you can
1147     *              use it to hold the resource if you resolve it. (The details of
1148     *              the proposed activity represented in a specific resource.)
1149     */
1150    public CarePlanActivityComponent setReferenceTarget(Resource value) {
1151      this.referenceTarget = value;
1152      return this;
1153    }
1154
1155    /**
1156     * @return {@link #detail} (A simple summary of a planned activity suitable for
1157     *         a general care plan system (e.g. form driven) that doesn't know about
1158     *         specific resources such as procedure etc.)
1159     */
1160    public CarePlanActivityDetailComponent getDetail() {
1161      if (this.detail == null)
1162        if (Configuration.errorOnAutoCreate())
1163          throw new Error("Attempt to auto-create CarePlanActivityComponent.detail");
1164        else if (Configuration.doAutoCreate())
1165          this.detail = new CarePlanActivityDetailComponent(); // cc
1166      return this.detail;
1167    }
1168
1169    public boolean hasDetail() {
1170      return this.detail != null && !this.detail.isEmpty();
1171    }
1172
1173    /**
1174     * @param value {@link #detail} (A simple summary of a planned activity suitable
1175     *              for a general care plan system (e.g. form driven) that doesn't
1176     *              know about specific resources such as procedure etc.)
1177     */
1178    public CarePlanActivityComponent setDetail(CarePlanActivityDetailComponent value) {
1179      this.detail = value;
1180      return this;
1181    }
1182
1183    protected void listChildren(List<Property> childrenList) {
1184      super.listChildren(childrenList);
1185      childrenList.add(new Property("actionResulting", "Reference(Any)",
1186          "Resources that describe follow-on actions resulting from the plan, such as drug prescriptions, encounter records, appointments, etc.",
1187          0, java.lang.Integer.MAX_VALUE, actionResulting));
1188      childrenList.add(new Property("progress", "Annotation",
1189          "Notes about the adherence/status/progress of the activity.", 0, java.lang.Integer.MAX_VALUE, progress));
1190      childrenList.add(new Property("reference",
1191          "Reference(Appointment|CommunicationRequest|DeviceUseRequest|DiagnosticOrder|MedicationOrder|NutritionOrder|Order|ProcedureRequest|ProcessRequest|ReferralRequest|SupplyRequest|VisionPrescription)",
1192          "The details of the proposed activity represented in a specific resource.", 0, java.lang.Integer.MAX_VALUE,
1193          reference));
1194      childrenList.add(new Property("detail", "",
1195          "A simple summary of a planned activity suitable for a general care plan system (e.g. form driven) that doesn't know about specific resources such as procedure etc.",
1196          0, java.lang.Integer.MAX_VALUE, detail));
1197    }
1198
1199    @Override
1200    public void setProperty(String name, Base value) throws FHIRException {
1201      if (name.equals("actionResulting"))
1202        this.getActionResulting().add(castToReference(value));
1203      else if (name.equals("progress"))
1204        this.getProgress().add(castToAnnotation(value));
1205      else if (name.equals("reference"))
1206        this.reference = castToReference(value); // Reference
1207      else if (name.equals("detail"))
1208        this.detail = (CarePlanActivityDetailComponent) value; // CarePlanActivityDetailComponent
1209      else
1210        super.setProperty(name, value);
1211    }
1212
1213    @Override
1214    public Base addChild(String name) throws FHIRException {
1215      if (name.equals("actionResulting")) {
1216        return addActionResulting();
1217      } else if (name.equals("progress")) {
1218        return addProgress();
1219      } else if (name.equals("reference")) {
1220        this.reference = new Reference();
1221        return this.reference;
1222      } else if (name.equals("detail")) {
1223        this.detail = new CarePlanActivityDetailComponent();
1224        return this.detail;
1225      } else
1226        return super.addChild(name);
1227    }
1228
1229    public CarePlanActivityComponent copy() {
1230      CarePlanActivityComponent dst = new CarePlanActivityComponent();
1231      copyValues(dst);
1232      if (actionResulting != null) {
1233        dst.actionResulting = new ArrayList<Reference>();
1234        for (Reference i : actionResulting)
1235          dst.actionResulting.add(i.copy());
1236      }
1237      ;
1238      if (progress != null) {
1239        dst.progress = new ArrayList<Annotation>();
1240        for (Annotation i : progress)
1241          dst.progress.add(i.copy());
1242      }
1243      ;
1244      dst.reference = reference == null ? null : reference.copy();
1245      dst.detail = detail == null ? null : detail.copy();
1246      return dst;
1247    }
1248
1249    @Override
1250    public boolean equalsDeep(Base other) {
1251      if (!super.equalsDeep(other))
1252        return false;
1253      if (!(other instanceof CarePlanActivityComponent))
1254        return false;
1255      CarePlanActivityComponent o = (CarePlanActivityComponent) other;
1256      return compareDeep(actionResulting, o.actionResulting, true) && compareDeep(progress, o.progress, true)
1257          && compareDeep(reference, o.reference, true) && compareDeep(detail, o.detail, true);
1258    }
1259
1260    @Override
1261    public boolean equalsShallow(Base other) {
1262      if (!super.equalsShallow(other))
1263        return false;
1264      if (!(other instanceof CarePlanActivityComponent))
1265        return false;
1266      CarePlanActivityComponent o = (CarePlanActivityComponent) other;
1267      return true;
1268    }
1269
1270    public boolean isEmpty() {
1271      return super.isEmpty() && (actionResulting == null || actionResulting.isEmpty())
1272          && (progress == null || progress.isEmpty()) && (reference == null || reference.isEmpty())
1273          && (detail == null || detail.isEmpty());
1274    }
1275
1276    public String fhirType() {
1277      return "CarePlan.activity";
1278
1279    }
1280
1281  }
1282
1283  @Block()
1284  public static class CarePlanActivityDetailComponent extends BackboneElement implements IBaseBackboneElement {
1285    /**
1286     * High-level categorization of the type of activity in a care plan.
1287     */
1288    @Child(name = "category", type = {
1289        CodeableConcept.class }, order = 1, min = 0, max = 1, modifier = false, summary = false)
1290    @Description(shortDefinition = "diet | drug | encounter | observation | procedure | supply | other", formalDefinition = "High-level categorization of the type of activity in a care plan.")
1291    protected CodeableConcept category;
1292
1293    /**
1294     * Detailed description of the type of planned activity; e.g. What lab test,
1295     * what procedure, what kind of encounter.
1296     */
1297    @Child(name = "code", type = {
1298        CodeableConcept.class }, order = 2, min = 0, max = 1, modifier = false, summary = false)
1299    @Description(shortDefinition = "Detail type of activity", formalDefinition = "Detailed description of the type of planned activity; e.g. What lab test, what procedure, what kind of encounter.")
1300    protected CodeableConcept code;
1301
1302    /**
1303     * Provides the rationale that drove the inclusion of this particular activity
1304     * as part of the plan.
1305     */
1306    @Child(name = "reasonCode", type = {
1307        CodeableConcept.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1308    @Description(shortDefinition = "Why activity should be done", formalDefinition = "Provides the rationale that drove the inclusion of this particular activity as part of the plan.")
1309    protected List<CodeableConcept> reasonCode;
1310
1311    /**
1312     * Provides the health condition(s) that drove the inclusion of this particular
1313     * activity as part of the plan.
1314     */
1315    @Child(name = "reasonReference", type = {
1316        Condition.class }, order = 4, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1317    @Description(shortDefinition = "Condition triggering need for activity", formalDefinition = "Provides the health condition(s) that drove the inclusion of this particular activity as part of the plan.")
1318    protected List<Reference> reasonReference;
1319    /**
1320     * The actual objects that are the target of the reference (Provides the health
1321     * condition(s) that drove the inclusion of this particular activity as part of
1322     * the plan.)
1323     */
1324    protected List<Condition> reasonReferenceTarget;
1325
1326    /**
1327     * Internal reference that identifies the goals that this activity is intended
1328     * to contribute towards meeting.
1329     */
1330    @Child(name = "goal", type = {
1331        Goal.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1332    @Description(shortDefinition = "Goals this activity relates to", formalDefinition = "Internal reference that identifies the goals that this activity is intended to contribute towards meeting.")
1333    protected List<Reference> goal;
1334    /**
1335     * The actual objects that are the target of the reference (Internal reference
1336     * that identifies the goals that this activity is intended to contribute
1337     * towards meeting.)
1338     */
1339    protected List<Goal> goalTarget;
1340
1341    /**
1342     * Identifies what progress is being made for the specific activity.
1343     */
1344    @Child(name = "status", type = { CodeType.class }, order = 6, min = 0, max = 1, modifier = true, summary = false)
1345    @Description(shortDefinition = "not-started | scheduled | in-progress | on-hold | completed | cancelled", formalDefinition = "Identifies what progress is being made for the specific activity.")
1346    protected Enumeration<CarePlanActivityStatus> status;
1347
1348    /**
1349     * Provides reason why the activity isn't yet started, is on hold, was
1350     * cancelled, etc.
1351     */
1352    @Child(name = "statusReason", type = {
1353        CodeableConcept.class }, order = 7, min = 0, max = 1, modifier = false, summary = false)
1354    @Description(shortDefinition = "Reason for current status", formalDefinition = "Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.")
1355    protected CodeableConcept statusReason;
1356
1357    /**
1358     * If true, indicates that the described activity is one that must NOT be
1359     * engaged in when following the plan.
1360     */
1361    @Child(name = "prohibited", type = {
1362        BooleanType.class }, order = 8, min = 1, max = 1, modifier = true, summary = false)
1363    @Description(shortDefinition = "Do NOT do", formalDefinition = "If true, indicates that the described activity is one that must NOT be engaged in when following the plan.")
1364    protected BooleanType prohibited;
1365
1366    /**
1367     * The period, timing or frequency upon which the described activity is to
1368     * occur.
1369     */
1370    @Child(name = "scheduled", type = { Timing.class, Period.class,
1371        StringType.class }, order = 9, min = 0, max = 1, modifier = false, summary = false)
1372    @Description(shortDefinition = "When activity is to occur", formalDefinition = "The period, timing or frequency upon which the described activity is to occur.")
1373    protected Type scheduled;
1374
1375    /**
1376     * Identifies the facility where the activity will occur; e.g. home, hospital,
1377     * specific clinic, etc.
1378     */
1379    @Child(name = "location", type = {
1380        Location.class }, order = 10, min = 0, max = 1, modifier = false, summary = false)
1381    @Description(shortDefinition = "Where it should happen", formalDefinition = "Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.")
1382    protected Reference location;
1383
1384    /**
1385     * The actual object that is the target of the reference (Identifies the
1386     * facility where the activity will occur; e.g. home, hospital, specific clinic,
1387     * etc.)
1388     */
1389    protected Location locationTarget;
1390
1391    /**
1392     * Identifies who's expected to be involved in the activity.
1393     */
1394    @Child(name = "performer", type = { Practitioner.class, Organization.class, RelatedPerson.class,
1395        Patient.class }, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
1396    @Description(shortDefinition = "Who will be responsible?", formalDefinition = "Identifies who's expected to be involved in the activity.")
1397    protected List<Reference> performer;
1398    /**
1399     * The actual objects that are the target of the reference (Identifies who's
1400     * expected to be involved in the activity.)
1401     */
1402    protected List<Resource> performerTarget;
1403
1404    /**
1405     * Identifies the food, drug or other product to be consumed or supplied in the
1406     * activity.
1407     */
1408    @Child(name = "product", type = { CodeableConcept.class, Medication.class,
1409        Substance.class }, order = 12, min = 0, max = 1, modifier = false, summary = false)
1410    @Description(shortDefinition = "What is to be administered/supplied", formalDefinition = "Identifies the food, drug or other product to be consumed or supplied in the activity.")
1411    protected Type product;
1412
1413    /**
1414     * Identifies the quantity expected to be consumed in a given day.
1415     */
1416    @Child(name = "dailyAmount", type = {
1417        SimpleQuantity.class }, order = 13, min = 0, max = 1, modifier = false, summary = false)
1418    @Description(shortDefinition = "How to consume/day?", formalDefinition = "Identifies the quantity expected to be consumed in a given day.")
1419    protected SimpleQuantity dailyAmount;
1420
1421    /**
1422     * Identifies the quantity expected to be supplied, administered or consumed by
1423     * the subject.
1424     */
1425    @Child(name = "quantity", type = {
1426        SimpleQuantity.class }, order = 14, min = 0, max = 1, modifier = false, summary = false)
1427    @Description(shortDefinition = "How much to administer/supply/consume", formalDefinition = "Identifies the quantity expected to be supplied, administered or consumed by the subject.")
1428    protected SimpleQuantity quantity;
1429
1430    /**
1431     * This provides a textual description of constraints on the intended activity
1432     * occurrence, including relation to other activities. It may also include
1433     * objectives, pre-conditions and end-conditions. Finally, it may convey
1434     * specifics about the activity such as body site, method, route, etc.
1435     */
1436    @Child(name = "description", type = {
1437        StringType.class }, order = 15, min = 0, max = 1, modifier = false, summary = false)
1438    @Description(shortDefinition = "Extra info describing activity to perform", formalDefinition = "This provides a textual description of constraints on the intended activity occurrence, including relation to other activities.  It may also include objectives, pre-conditions and end-conditions.  Finally, it may convey specifics about the activity such as body site, method, route, etc.")
1439    protected StringType description;
1440
1441    private static final long serialVersionUID = -1763965702L;
1442
1443    /*
1444     * Constructor
1445     */
1446    public CarePlanActivityDetailComponent() {
1447      super();
1448    }
1449
1450    /*
1451     * Constructor
1452     */
1453    public CarePlanActivityDetailComponent(BooleanType prohibited) {
1454      super();
1455      this.prohibited = prohibited;
1456    }
1457
1458    /**
1459     * @return {@link #category} (High-level categorization of the type of activity
1460     *         in a care plan.)
1461     */
1462    public CodeableConcept getCategory() {
1463      if (this.category == null)
1464        if (Configuration.errorOnAutoCreate())
1465          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.category");
1466        else if (Configuration.doAutoCreate())
1467          this.category = new CodeableConcept(); // cc
1468      return this.category;
1469    }
1470
1471    public boolean hasCategory() {
1472      return this.category != null && !this.category.isEmpty();
1473    }
1474
1475    /**
1476     * @param value {@link #category} (High-level categorization of the type of
1477     *              activity in a care plan.)
1478     */
1479    public CarePlanActivityDetailComponent setCategory(CodeableConcept value) {
1480      this.category = value;
1481      return this;
1482    }
1483
1484    /**
1485     * @return {@link #code} (Detailed description of the type of planned activity;
1486     *         e.g. What lab test, what procedure, what kind of encounter.)
1487     */
1488    public CodeableConcept getCode() {
1489      if (this.code == null)
1490        if (Configuration.errorOnAutoCreate())
1491          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.code");
1492        else if (Configuration.doAutoCreate())
1493          this.code = new CodeableConcept(); // cc
1494      return this.code;
1495    }
1496
1497    public boolean hasCode() {
1498      return this.code != null && !this.code.isEmpty();
1499    }
1500
1501    /**
1502     * @param value {@link #code} (Detailed description of the type of planned
1503     *              activity; e.g. What lab test, what procedure, what kind of
1504     *              encounter.)
1505     */
1506    public CarePlanActivityDetailComponent setCode(CodeableConcept value) {
1507      this.code = value;
1508      return this;
1509    }
1510
1511    /**
1512     * @return {@link #reasonCode} (Provides the rationale that drove the inclusion
1513     *         of this particular activity as part of the plan.)
1514     */
1515    public List<CodeableConcept> getReasonCode() {
1516      if (this.reasonCode == null)
1517        this.reasonCode = new ArrayList<CodeableConcept>();
1518      return this.reasonCode;
1519    }
1520
1521    public boolean hasReasonCode() {
1522      if (this.reasonCode == null)
1523        return false;
1524      for (CodeableConcept item : this.reasonCode)
1525        if (!item.isEmpty())
1526          return true;
1527      return false;
1528    }
1529
1530    /**
1531     * @return {@link #reasonCode} (Provides the rationale that drove the inclusion
1532     *         of this particular activity as part of the plan.)
1533     */
1534    // syntactic sugar
1535    public CodeableConcept addReasonCode() { // 3
1536      CodeableConcept t = new CodeableConcept();
1537      if (this.reasonCode == null)
1538        this.reasonCode = new ArrayList<CodeableConcept>();
1539      this.reasonCode.add(t);
1540      return t;
1541    }
1542
1543    // syntactic sugar
1544    public CarePlanActivityDetailComponent addReasonCode(CodeableConcept t) { // 3
1545      if (t == null)
1546        return this;
1547      if (this.reasonCode == null)
1548        this.reasonCode = new ArrayList<CodeableConcept>();
1549      this.reasonCode.add(t);
1550      return this;
1551    }
1552
1553    /**
1554     * @return {@link #reasonReference} (Provides the health condition(s) that drove
1555     *         the inclusion of this particular activity as part of the plan.)
1556     */
1557    public List<Reference> getReasonReference() {
1558      if (this.reasonReference == null)
1559        this.reasonReference = new ArrayList<Reference>();
1560      return this.reasonReference;
1561    }
1562
1563    public boolean hasReasonReference() {
1564      if (this.reasonReference == null)
1565        return false;
1566      for (Reference item : this.reasonReference)
1567        if (!item.isEmpty())
1568          return true;
1569      return false;
1570    }
1571
1572    /**
1573     * @return {@link #reasonReference} (Provides the health condition(s) that drove
1574     *         the inclusion of this particular activity as part of the plan.)
1575     */
1576    // syntactic sugar
1577    public Reference addReasonReference() { // 3
1578      Reference t = new Reference();
1579      if (this.reasonReference == null)
1580        this.reasonReference = new ArrayList<Reference>();
1581      this.reasonReference.add(t);
1582      return t;
1583    }
1584
1585    // syntactic sugar
1586    public CarePlanActivityDetailComponent addReasonReference(Reference t) { // 3
1587      if (t == null)
1588        return this;
1589      if (this.reasonReference == null)
1590        this.reasonReference = new ArrayList<Reference>();
1591      this.reasonReference.add(t);
1592      return this;
1593    }
1594
1595    /**
1596     * @return {@link #reasonReference} (The actual objects that are the target of
1597     *         the reference. The reference library doesn't populate this, but you
1598     *         can use this to hold the resources if you resolvethemt. Provides the
1599     *         health condition(s) that drove the inclusion of this particular
1600     *         activity as part of the plan.)
1601     */
1602    public List<Condition> getReasonReferenceTarget() {
1603      if (this.reasonReferenceTarget == null)
1604        this.reasonReferenceTarget = new ArrayList<Condition>();
1605      return this.reasonReferenceTarget;
1606    }
1607
1608    // syntactic sugar
1609    /**
1610     * @return {@link #reasonReference} (Add an actual object that is the target of
1611     *         the reference. The reference library doesn't use these, but you can
1612     *         use this to hold the resources if you resolvethemt. Provides the
1613     *         health condition(s) that drove the inclusion of this particular
1614     *         activity as part of the plan.)
1615     */
1616    public Condition addReasonReferenceTarget() {
1617      Condition r = new Condition();
1618      if (this.reasonReferenceTarget == null)
1619        this.reasonReferenceTarget = new ArrayList<Condition>();
1620      this.reasonReferenceTarget.add(r);
1621      return r;
1622    }
1623
1624    /**
1625     * @return {@link #goal} (Internal reference that identifies the goals that this
1626     *         activity is intended to contribute towards meeting.)
1627     */
1628    public List<Reference> getGoal() {
1629      if (this.goal == null)
1630        this.goal = new ArrayList<Reference>();
1631      return this.goal;
1632    }
1633
1634    public boolean hasGoal() {
1635      if (this.goal == null)
1636        return false;
1637      for (Reference item : this.goal)
1638        if (!item.isEmpty())
1639          return true;
1640      return false;
1641    }
1642
1643    /**
1644     * @return {@link #goal} (Internal reference that identifies the goals that this
1645     *         activity is intended to contribute towards meeting.)
1646     */
1647    // syntactic sugar
1648    public Reference addGoal() { // 3
1649      Reference t = new Reference();
1650      if (this.goal == null)
1651        this.goal = new ArrayList<Reference>();
1652      this.goal.add(t);
1653      return t;
1654    }
1655
1656    // syntactic sugar
1657    public CarePlanActivityDetailComponent addGoal(Reference t) { // 3
1658      if (t == null)
1659        return this;
1660      if (this.goal == null)
1661        this.goal = new ArrayList<Reference>();
1662      this.goal.add(t);
1663      return this;
1664    }
1665
1666    /**
1667     * @return {@link #goal} (The actual objects that are the target of the
1668     *         reference. The reference library doesn't populate this, but you can
1669     *         use this to hold the resources if you resolvethemt. Internal
1670     *         reference that identifies the goals that this activity is intended to
1671     *         contribute towards meeting.)
1672     */
1673    public List<Goal> getGoalTarget() {
1674      if (this.goalTarget == null)
1675        this.goalTarget = new ArrayList<Goal>();
1676      return this.goalTarget;
1677    }
1678
1679    // syntactic sugar
1680    /**
1681     * @return {@link #goal} (Add an actual object that is the target of the
1682     *         reference. The reference library doesn't use these, but you can use
1683     *         this to hold the resources if you resolvethemt. Internal reference
1684     *         that identifies the goals that this activity is intended to
1685     *         contribute towards meeting.)
1686     */
1687    public Goal addGoalTarget() {
1688      Goal r = new Goal();
1689      if (this.goalTarget == null)
1690        this.goalTarget = new ArrayList<Goal>();
1691      this.goalTarget.add(r);
1692      return r;
1693    }
1694
1695    /**
1696     * @return {@link #status} (Identifies what progress is being made for the
1697     *         specific activity.). This is the underlying object with id, value and
1698     *         extensions. The accessor "getStatus" gives direct access to the value
1699     */
1700    public Enumeration<CarePlanActivityStatus> getStatusElement() {
1701      if (this.status == null)
1702        if (Configuration.errorOnAutoCreate())
1703          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.status");
1704        else if (Configuration.doAutoCreate())
1705          this.status = new Enumeration<CarePlanActivityStatus>(new CarePlanActivityStatusEnumFactory()); // bb
1706      return this.status;
1707    }
1708
1709    public boolean hasStatusElement() {
1710      return this.status != null && !this.status.isEmpty();
1711    }
1712
1713    public boolean hasStatus() {
1714      return this.status != null && !this.status.isEmpty();
1715    }
1716
1717    /**
1718     * @param value {@link #status} (Identifies what progress is being made for the
1719     *              specific activity.). This is the underlying object with id,
1720     *              value and extensions. The accessor "getStatus" gives direct
1721     *              access to the value
1722     */
1723    public CarePlanActivityDetailComponent setStatusElement(Enumeration<CarePlanActivityStatus> value) {
1724      this.status = value;
1725      return this;
1726    }
1727
1728    /**
1729     * @return Identifies what progress is being made for the specific activity.
1730     */
1731    public CarePlanActivityStatus getStatus() {
1732      return this.status == null ? null : this.status.getValue();
1733    }
1734
1735    /**
1736     * @param value Identifies what progress is being made for the specific
1737     *              activity.
1738     */
1739    public CarePlanActivityDetailComponent setStatus(CarePlanActivityStatus value) {
1740      if (value == null)
1741        this.status = null;
1742      else {
1743        if (this.status == null)
1744          this.status = new Enumeration<CarePlanActivityStatus>(new CarePlanActivityStatusEnumFactory());
1745        this.status.setValue(value);
1746      }
1747      return this;
1748    }
1749
1750    /**
1751     * @return {@link #statusReason} (Provides reason why the activity isn't yet
1752     *         started, is on hold, was cancelled, etc.)
1753     */
1754    public CodeableConcept getStatusReason() {
1755      if (this.statusReason == null)
1756        if (Configuration.errorOnAutoCreate())
1757          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.statusReason");
1758        else if (Configuration.doAutoCreate())
1759          this.statusReason = new CodeableConcept(); // cc
1760      return this.statusReason;
1761    }
1762
1763    public boolean hasStatusReason() {
1764      return this.statusReason != null && !this.statusReason.isEmpty();
1765    }
1766
1767    /**
1768     * @param value {@link #statusReason} (Provides reason why the activity isn't
1769     *              yet started, is on hold, was cancelled, etc.)
1770     */
1771    public CarePlanActivityDetailComponent setStatusReason(CodeableConcept value) {
1772      this.statusReason = value;
1773      return this;
1774    }
1775
1776    /**
1777     * @return {@link #prohibited} (If true, indicates that the described activity
1778     *         is one that must NOT be engaged in when following the plan.). This is
1779     *         the underlying object with id, value and extensions. The accessor
1780     *         "getProhibited" gives direct access to the value
1781     */
1782    public BooleanType getProhibitedElement() {
1783      if (this.prohibited == null)
1784        if (Configuration.errorOnAutoCreate())
1785          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.prohibited");
1786        else if (Configuration.doAutoCreate())
1787          this.prohibited = new BooleanType(); // bb
1788      return this.prohibited;
1789    }
1790
1791    public boolean hasProhibitedElement() {
1792      return this.prohibited != null && !this.prohibited.isEmpty();
1793    }
1794
1795    public boolean hasProhibited() {
1796      return this.prohibited != null && !this.prohibited.isEmpty();
1797    }
1798
1799    /**
1800     * @param value {@link #prohibited} (If true, indicates that the described
1801     *              activity is one that must NOT be engaged in when following the
1802     *              plan.). This is the underlying object with id, value and
1803     *              extensions. The accessor "getProhibited" gives direct access to
1804     *              the value
1805     */
1806    public CarePlanActivityDetailComponent setProhibitedElement(BooleanType value) {
1807      this.prohibited = value;
1808      return this;
1809    }
1810
1811    /**
1812     * @return If true, indicates that the described activity is one that must NOT
1813     *         be engaged in when following the plan.
1814     */
1815    public boolean getProhibited() {
1816      return this.prohibited == null || this.prohibited.isEmpty() ? false : this.prohibited.getValue();
1817    }
1818
1819    /**
1820     * @param value If true, indicates that the described activity is one that must
1821     *              NOT be engaged in when following the plan.
1822     */
1823    public CarePlanActivityDetailComponent setProhibited(boolean value) {
1824      if (this.prohibited == null)
1825        this.prohibited = new BooleanType();
1826      this.prohibited.setValue(value);
1827      return this;
1828    }
1829
1830    /**
1831     * @return {@link #scheduled} (The period, timing or frequency upon which the
1832     *         described activity is to occur.)
1833     */
1834    public Type getScheduled() {
1835      return this.scheduled;
1836    }
1837
1838    /**
1839     * @return {@link #scheduled} (The period, timing or frequency upon which the
1840     *         described activity is to occur.)
1841     */
1842    public Timing getScheduledTiming() throws FHIRException {
1843      if (!(this.scheduled instanceof Timing))
1844        throw new FHIRException("Type mismatch: the type Timing was expected, but "
1845            + this.scheduled.getClass().getName() + " was encountered");
1846      return (Timing) this.scheduled;
1847    }
1848
1849    public boolean hasScheduledTiming() {
1850      return this.scheduled instanceof Timing;
1851    }
1852
1853    /**
1854     * @return {@link #scheduled} (The period, timing or frequency upon which the
1855     *         described activity is to occur.)
1856     */
1857    public Period getScheduledPeriod() throws FHIRException {
1858      if (!(this.scheduled instanceof Period))
1859        throw new FHIRException("Type mismatch: the type Period was expected, but "
1860            + this.scheduled.getClass().getName() + " was encountered");
1861      return (Period) this.scheduled;
1862    }
1863
1864    public boolean hasScheduledPeriod() {
1865      return this.scheduled instanceof Period;
1866    }
1867
1868    /**
1869     * @return {@link #scheduled} (The period, timing or frequency upon which the
1870     *         described activity is to occur.)
1871     */
1872    public StringType getScheduledStringType() throws FHIRException {
1873      if (!(this.scheduled instanceof StringType))
1874        throw new FHIRException("Type mismatch: the type StringType was expected, but "
1875            + this.scheduled.getClass().getName() + " was encountered");
1876      return (StringType) this.scheduled;
1877    }
1878
1879    public boolean hasScheduledStringType() {
1880      return this.scheduled instanceof StringType;
1881    }
1882
1883    public boolean hasScheduled() {
1884      return this.scheduled != null && !this.scheduled.isEmpty();
1885    }
1886
1887    /**
1888     * @param value {@link #scheduled} (The period, timing or frequency upon which
1889     *              the described activity is to occur.)
1890     */
1891    public CarePlanActivityDetailComponent setScheduled(Type value) {
1892      this.scheduled = value;
1893      return this;
1894    }
1895
1896    /**
1897     * @return {@link #location} (Identifies the facility where the activity will
1898     *         occur; e.g. home, hospital, specific clinic, etc.)
1899     */
1900    public Reference getLocation() {
1901      if (this.location == null)
1902        if (Configuration.errorOnAutoCreate())
1903          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.location");
1904        else if (Configuration.doAutoCreate())
1905          this.location = new Reference(); // cc
1906      return this.location;
1907    }
1908
1909    public boolean hasLocation() {
1910      return this.location != null && !this.location.isEmpty();
1911    }
1912
1913    /**
1914     * @param value {@link #location} (Identifies the facility where the activity
1915     *              will occur; e.g. home, hospital, specific clinic, etc.)
1916     */
1917    public CarePlanActivityDetailComponent setLocation(Reference value) {
1918      this.location = value;
1919      return this;
1920    }
1921
1922    /**
1923     * @return {@link #location} The actual object that is the target of the
1924     *         reference. The reference library doesn't populate this, but you can
1925     *         use it to hold the resource if you resolve it. (Identifies the
1926     *         facility where the activity will occur; e.g. home, hospital, specific
1927     *         clinic, etc.)
1928     */
1929    public Location getLocationTarget() {
1930      if (this.locationTarget == null)
1931        if (Configuration.errorOnAutoCreate())
1932          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.location");
1933        else if (Configuration.doAutoCreate())
1934          this.locationTarget = new Location(); // aa
1935      return this.locationTarget;
1936    }
1937
1938    /**
1939     * @param value {@link #location} The actual object that is the target of the
1940     *              reference. The reference library doesn't use these, but you can
1941     *              use it to hold the resource if you resolve it. (Identifies the
1942     *              facility where the activity will occur; e.g. home, hospital,
1943     *              specific clinic, etc.)
1944     */
1945    public CarePlanActivityDetailComponent setLocationTarget(Location value) {
1946      this.locationTarget = value;
1947      return this;
1948    }
1949
1950    /**
1951     * @return {@link #performer} (Identifies who's expected to be involved in the
1952     *         activity.)
1953     */
1954    public List<Reference> getPerformer() {
1955      if (this.performer == null)
1956        this.performer = new ArrayList<Reference>();
1957      return this.performer;
1958    }
1959
1960    public boolean hasPerformer() {
1961      if (this.performer == null)
1962        return false;
1963      for (Reference item : this.performer)
1964        if (!item.isEmpty())
1965          return true;
1966      return false;
1967    }
1968
1969    /**
1970     * @return {@link #performer} (Identifies who's expected to be involved in the
1971     *         activity.)
1972     */
1973    // syntactic sugar
1974    public Reference addPerformer() { // 3
1975      Reference t = new Reference();
1976      if (this.performer == null)
1977        this.performer = new ArrayList<Reference>();
1978      this.performer.add(t);
1979      return t;
1980    }
1981
1982    // syntactic sugar
1983    public CarePlanActivityDetailComponent addPerformer(Reference t) { // 3
1984      if (t == null)
1985        return this;
1986      if (this.performer == null)
1987        this.performer = new ArrayList<Reference>();
1988      this.performer.add(t);
1989      return this;
1990    }
1991
1992    /**
1993     * @return {@link #performer} (The actual objects that are the target of the
1994     *         reference. The reference library doesn't populate this, but you can
1995     *         use this to hold the resources if you resolvethemt. Identifies who's
1996     *         expected to be involved in the activity.)
1997     */
1998    public List<Resource> getPerformerTarget() {
1999      if (this.performerTarget == null)
2000        this.performerTarget = new ArrayList<Resource>();
2001      return this.performerTarget;
2002    }
2003
2004    /**
2005     * @return {@link #product} (Identifies the food, drug or other product to be
2006     *         consumed or supplied in the activity.)
2007     */
2008    public Type getProduct() {
2009      return this.product;
2010    }
2011
2012    /**
2013     * @return {@link #product} (Identifies the food, drug or other product to be
2014     *         consumed or supplied in the activity.)
2015     */
2016    public CodeableConcept getProductCodeableConcept() throws FHIRException {
2017      if (!(this.product instanceof CodeableConcept))
2018        throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
2019            + this.product.getClass().getName() + " was encountered");
2020      return (CodeableConcept) this.product;
2021    }
2022
2023    public boolean hasProductCodeableConcept() {
2024      return this.product instanceof CodeableConcept;
2025    }
2026
2027    /**
2028     * @return {@link #product} (Identifies the food, drug or other product to be
2029     *         consumed or supplied in the activity.)
2030     */
2031    public Reference getProductReference() throws FHIRException {
2032      if (!(this.product instanceof Reference))
2033        throw new FHIRException("Type mismatch: the type Reference was expected, but "
2034            + this.product.getClass().getName() + " was encountered");
2035      return (Reference) this.product;
2036    }
2037
2038    public boolean hasProductReference() {
2039      return this.product instanceof Reference;
2040    }
2041
2042    public boolean hasProduct() {
2043      return this.product != null && !this.product.isEmpty();
2044    }
2045
2046    /**
2047     * @param value {@link #product} (Identifies the food, drug or other product to
2048     *              be consumed or supplied in the activity.)
2049     */
2050    public CarePlanActivityDetailComponent setProduct(Type value) {
2051      this.product = value;
2052      return this;
2053    }
2054
2055    /**
2056     * @return {@link #dailyAmount} (Identifies the quantity expected to be consumed
2057     *         in a given day.)
2058     */
2059    public SimpleQuantity getDailyAmount() {
2060      if (this.dailyAmount == null)
2061        if (Configuration.errorOnAutoCreate())
2062          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.dailyAmount");
2063        else if (Configuration.doAutoCreate())
2064          this.dailyAmount = new SimpleQuantity(); // cc
2065      return this.dailyAmount;
2066    }
2067
2068    public boolean hasDailyAmount() {
2069      return this.dailyAmount != null && !this.dailyAmount.isEmpty();
2070    }
2071
2072    /**
2073     * @param value {@link #dailyAmount} (Identifies the quantity expected to be
2074     *              consumed in a given day.)
2075     */
2076    public CarePlanActivityDetailComponent setDailyAmount(SimpleQuantity value) {
2077      this.dailyAmount = value;
2078      return this;
2079    }
2080
2081    /**
2082     * @return {@link #quantity} (Identifies the quantity expected to be supplied,
2083     *         administered or consumed by the subject.)
2084     */
2085    public SimpleQuantity getQuantity() {
2086      if (this.quantity == null)
2087        if (Configuration.errorOnAutoCreate())
2088          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.quantity");
2089        else if (Configuration.doAutoCreate())
2090          this.quantity = new SimpleQuantity(); // cc
2091      return this.quantity;
2092    }
2093
2094    public boolean hasQuantity() {
2095      return this.quantity != null && !this.quantity.isEmpty();
2096    }
2097
2098    /**
2099     * @param value {@link #quantity} (Identifies the quantity expected to be
2100     *              supplied, administered or consumed by the subject.)
2101     */
2102    public CarePlanActivityDetailComponent setQuantity(SimpleQuantity value) {
2103      this.quantity = value;
2104      return this;
2105    }
2106
2107    /**
2108     * @return {@link #description} (This provides a textual description of
2109     *         constraints on the intended activity occurrence, including relation
2110     *         to other activities. It may also include objectives, pre-conditions
2111     *         and end-conditions. Finally, it may convey specifics about the
2112     *         activity such as body site, method, route, etc.). This is the
2113     *         underlying object with id, value and extensions. The accessor
2114     *         "getDescription" gives direct access to the value
2115     */
2116    public StringType getDescriptionElement() {
2117      if (this.description == null)
2118        if (Configuration.errorOnAutoCreate())
2119          throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.description");
2120        else if (Configuration.doAutoCreate())
2121          this.description = new StringType(); // bb
2122      return this.description;
2123    }
2124
2125    public boolean hasDescriptionElement() {
2126      return this.description != null && !this.description.isEmpty();
2127    }
2128
2129    public boolean hasDescription() {
2130      return this.description != null && !this.description.isEmpty();
2131    }
2132
2133    /**
2134     * @param value {@link #description} (This provides a textual description of
2135     *              constraints on the intended activity occurrence, including
2136     *              relation to other activities. It may also include objectives,
2137     *              pre-conditions and end-conditions. Finally, it may convey
2138     *              specifics about the activity such as body site, method, route,
2139     *              etc.). This is the underlying object with id, value and
2140     *              extensions. The accessor "getDescription" gives direct access to
2141     *              the value
2142     */
2143    public CarePlanActivityDetailComponent setDescriptionElement(StringType value) {
2144      this.description = value;
2145      return this;
2146    }
2147
2148    /**
2149     * @return This provides a textual description of constraints on the intended
2150     *         activity occurrence, including relation to other activities. It may
2151     *         also include objectives, pre-conditions and end-conditions. Finally,
2152     *         it may convey specifics about the activity such as body site, method,
2153     *         route, etc.
2154     */
2155    public String getDescription() {
2156      return this.description == null ? null : this.description.getValue();
2157    }
2158
2159    /**
2160     * @param value This provides a textual description of constraints on the
2161     *              intended activity occurrence, including relation to other
2162     *              activities. It may also include objectives, pre-conditions and
2163     *              end-conditions. Finally, it may convey specifics about the
2164     *              activity such as body site, method, route, etc.
2165     */
2166    public CarePlanActivityDetailComponent setDescription(String value) {
2167      if (Utilities.noString(value))
2168        this.description = null;
2169      else {
2170        if (this.description == null)
2171          this.description = new StringType();
2172        this.description.setValue(value);
2173      }
2174      return this;
2175    }
2176
2177    protected void listChildren(List<Property> childrenList) {
2178      super.listChildren(childrenList);
2179      childrenList.add(new Property("category", "CodeableConcept",
2180          "High-level categorization of the type of activity in a care plan.", 0, java.lang.Integer.MAX_VALUE,
2181          category));
2182      childrenList.add(new Property("code", "CodeableConcept",
2183          "Detailed description of the type of planned activity; e.g. What lab test, what procedure, what kind of encounter.",
2184          0, java.lang.Integer.MAX_VALUE, code));
2185      childrenList.add(new Property("reasonCode", "CodeableConcept",
2186          "Provides the rationale that drove the inclusion of this particular activity as part of the plan.", 0,
2187          java.lang.Integer.MAX_VALUE, reasonCode));
2188      childrenList.add(new Property("reasonReference", "Reference(Condition)",
2189          "Provides the health condition(s) that drove the inclusion of this particular activity as part of the plan.",
2190          0, java.lang.Integer.MAX_VALUE, reasonReference));
2191      childrenList.add(new Property("goal", "Reference(Goal)",
2192          "Internal reference that identifies the goals that this activity is intended to contribute towards meeting.",
2193          0, java.lang.Integer.MAX_VALUE, goal));
2194      childrenList.add(new Property("status", "code",
2195          "Identifies what progress is being made for the specific activity.", 0, java.lang.Integer.MAX_VALUE, status));
2196      childrenList.add(new Property("statusReason", "CodeableConcept",
2197          "Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.", 0,
2198          java.lang.Integer.MAX_VALUE, statusReason));
2199      childrenList.add(new Property("prohibited", "boolean",
2200          "If true, indicates that the described activity is one that must NOT be engaged in when following the plan.",
2201          0, java.lang.Integer.MAX_VALUE, prohibited));
2202      childrenList.add(new Property("scheduled[x]", "Timing|Period|string",
2203          "The period, timing or frequency upon which the described activity is to occur.", 0,
2204          java.lang.Integer.MAX_VALUE, scheduled));
2205      childrenList.add(new Property("location", "Reference(Location)",
2206          "Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.", 0,
2207          java.lang.Integer.MAX_VALUE, location));
2208      childrenList.add(new Property("performer", "Reference(Practitioner|Organization|RelatedPerson|Patient)",
2209          "Identifies who's expected to be involved in the activity.", 0, java.lang.Integer.MAX_VALUE, performer));
2210      childrenList.add(new Property("product[x]", "CodeableConcept|Reference(Medication|Substance)",
2211          "Identifies the food, drug or other product to be consumed or supplied in the activity.", 0,
2212          java.lang.Integer.MAX_VALUE, product));
2213      childrenList.add(new Property("dailyAmount", "SimpleQuantity",
2214          "Identifies the quantity expected to be consumed in a given day.", 0, java.lang.Integer.MAX_VALUE,
2215          dailyAmount));
2216      childrenList.add(new Property("quantity", "SimpleQuantity",
2217          "Identifies the quantity expected to be supplied, administered or consumed by the subject.", 0,
2218          java.lang.Integer.MAX_VALUE, quantity));
2219      childrenList.add(new Property("description", "string",
2220          "This provides a textual description of constraints on the intended activity occurrence, including relation to other activities.  It may also include objectives, pre-conditions and end-conditions.  Finally, it may convey specifics about the activity such as body site, method, route, etc.",
2221          0, java.lang.Integer.MAX_VALUE, description));
2222    }
2223
2224    @Override
2225    public void setProperty(String name, Base value) throws FHIRException {
2226      if (name.equals("category"))
2227        this.category = castToCodeableConcept(value); // CodeableConcept
2228      else if (name.equals("code"))
2229        this.code = castToCodeableConcept(value); // CodeableConcept
2230      else if (name.equals("reasonCode"))
2231        this.getReasonCode().add(castToCodeableConcept(value));
2232      else if (name.equals("reasonReference"))
2233        this.getReasonReference().add(castToReference(value));
2234      else if (name.equals("goal"))
2235        this.getGoal().add(castToReference(value));
2236      else if (name.equals("status"))
2237        this.status = new CarePlanActivityStatusEnumFactory().fromType(value); // Enumeration<CarePlanActivityStatus>
2238      else if (name.equals("statusReason"))
2239        this.statusReason = castToCodeableConcept(value); // CodeableConcept
2240      else if (name.equals("prohibited"))
2241        this.prohibited = castToBoolean(value); // BooleanType
2242      else if (name.equals("scheduled[x]"))
2243        this.scheduled = (Type) value; // Type
2244      else if (name.equals("location"))
2245        this.location = castToReference(value); // Reference
2246      else if (name.equals("performer"))
2247        this.getPerformer().add(castToReference(value));
2248      else if (name.equals("product[x]"))
2249        this.product = (Type) value; // Type
2250      else if (name.equals("dailyAmount"))
2251        this.dailyAmount = castToSimpleQuantity(value); // SimpleQuantity
2252      else if (name.equals("quantity"))
2253        this.quantity = castToSimpleQuantity(value); // SimpleQuantity
2254      else if (name.equals("description"))
2255        this.description = castToString(value); // StringType
2256      else
2257        super.setProperty(name, value);
2258    }
2259
2260    @Override
2261    public Base addChild(String name) throws FHIRException {
2262      if (name.equals("category")) {
2263        this.category = new CodeableConcept();
2264        return this.category;
2265      } else if (name.equals("code")) {
2266        this.code = new CodeableConcept();
2267        return this.code;
2268      } else if (name.equals("reasonCode")) {
2269        return addReasonCode();
2270      } else if (name.equals("reasonReference")) {
2271        return addReasonReference();
2272      } else if (name.equals("goal")) {
2273        return addGoal();
2274      } else if (name.equals("status")) {
2275        throw new FHIRException("Cannot call addChild on a singleton property CarePlan.status");
2276      } else if (name.equals("statusReason")) {
2277        this.statusReason = new CodeableConcept();
2278        return this.statusReason;
2279      } else if (name.equals("prohibited")) {
2280        throw new FHIRException("Cannot call addChild on a singleton property CarePlan.prohibited");
2281      } else if (name.equals("scheduledTiming")) {
2282        this.scheduled = new Timing();
2283        return this.scheduled;
2284      } else if (name.equals("scheduledPeriod")) {
2285        this.scheduled = new Period();
2286        return this.scheduled;
2287      } else if (name.equals("scheduledString")) {
2288        this.scheduled = new StringType();
2289        return this.scheduled;
2290      } else if (name.equals("location")) {
2291        this.location = new Reference();
2292        return this.location;
2293      } else if (name.equals("performer")) {
2294        return addPerformer();
2295      } else if (name.equals("productCodeableConcept")) {
2296        this.product = new CodeableConcept();
2297        return this.product;
2298      } else if (name.equals("productReference")) {
2299        this.product = new Reference();
2300        return this.product;
2301      } else if (name.equals("dailyAmount")) {
2302        this.dailyAmount = new SimpleQuantity();
2303        return this.dailyAmount;
2304      } else if (name.equals("quantity")) {
2305        this.quantity = new SimpleQuantity();
2306        return this.quantity;
2307      } else if (name.equals("description")) {
2308        throw new FHIRException("Cannot call addChild on a singleton property CarePlan.description");
2309      } else
2310        return super.addChild(name);
2311    }
2312
2313    public CarePlanActivityDetailComponent copy() {
2314      CarePlanActivityDetailComponent dst = new CarePlanActivityDetailComponent();
2315      copyValues(dst);
2316      dst.category = category == null ? null : category.copy();
2317      dst.code = code == null ? null : code.copy();
2318      if (reasonCode != null) {
2319        dst.reasonCode = new ArrayList<CodeableConcept>();
2320        for (CodeableConcept i : reasonCode)
2321          dst.reasonCode.add(i.copy());
2322      }
2323      ;
2324      if (reasonReference != null) {
2325        dst.reasonReference = new ArrayList<Reference>();
2326        for (Reference i : reasonReference)
2327          dst.reasonReference.add(i.copy());
2328      }
2329      ;
2330      if (goal != null) {
2331        dst.goal = new ArrayList<Reference>();
2332        for (Reference i : goal)
2333          dst.goal.add(i.copy());
2334      }
2335      ;
2336      dst.status = status == null ? null : status.copy();
2337      dst.statusReason = statusReason == null ? null : statusReason.copy();
2338      dst.prohibited = prohibited == null ? null : prohibited.copy();
2339      dst.scheduled = scheduled == null ? null : scheduled.copy();
2340      dst.location = location == null ? null : location.copy();
2341      if (performer != null) {
2342        dst.performer = new ArrayList<Reference>();
2343        for (Reference i : performer)
2344          dst.performer.add(i.copy());
2345      }
2346      ;
2347      dst.product = product == null ? null : product.copy();
2348      dst.dailyAmount = dailyAmount == null ? null : dailyAmount.copy();
2349      dst.quantity = quantity == null ? null : quantity.copy();
2350      dst.description = description == null ? null : description.copy();
2351      return dst;
2352    }
2353
2354    @Override
2355    public boolean equalsDeep(Base other) {
2356      if (!super.equalsDeep(other))
2357        return false;
2358      if (!(other instanceof CarePlanActivityDetailComponent))
2359        return false;
2360      CarePlanActivityDetailComponent o = (CarePlanActivityDetailComponent) other;
2361      return compareDeep(category, o.category, true) && compareDeep(code, o.code, true)
2362          && compareDeep(reasonCode, o.reasonCode, true) && compareDeep(reasonReference, o.reasonReference, true)
2363          && compareDeep(goal, o.goal, true) && compareDeep(status, o.status, true)
2364          && compareDeep(statusReason, o.statusReason, true) && compareDeep(prohibited, o.prohibited, true)
2365          && compareDeep(scheduled, o.scheduled, true) && compareDeep(location, o.location, true)
2366          && compareDeep(performer, o.performer, true) && compareDeep(product, o.product, true)
2367          && compareDeep(dailyAmount, o.dailyAmount, true) && compareDeep(quantity, o.quantity, true)
2368          && compareDeep(description, o.description, true);
2369    }
2370
2371    @Override
2372    public boolean equalsShallow(Base other) {
2373      if (!super.equalsShallow(other))
2374        return false;
2375      if (!(other instanceof CarePlanActivityDetailComponent))
2376        return false;
2377      CarePlanActivityDetailComponent o = (CarePlanActivityDetailComponent) other;
2378      return compareValues(status, o.status, true) && compareValues(prohibited, o.prohibited, true)
2379          && compareValues(description, o.description, true);
2380    }
2381
2382    public boolean isEmpty() {
2383      return super.isEmpty() && (category == null || category.isEmpty()) && (code == null || code.isEmpty())
2384          && (reasonCode == null || reasonCode.isEmpty()) && (reasonReference == null || reasonReference.isEmpty())
2385          && (goal == null || goal.isEmpty()) && (status == null || status.isEmpty())
2386          && (statusReason == null || statusReason.isEmpty()) && (prohibited == null || prohibited.isEmpty())
2387          && (scheduled == null || scheduled.isEmpty()) && (location == null || location.isEmpty())
2388          && (performer == null || performer.isEmpty()) && (product == null || product.isEmpty())
2389          && (dailyAmount == null || dailyAmount.isEmpty()) && (quantity == null || quantity.isEmpty())
2390          && (description == null || description.isEmpty());
2391    }
2392
2393    public String fhirType() {
2394      return "CarePlan.activity.detail";
2395
2396    }
2397
2398  }
2399
2400  /**
2401   * This records identifiers associated with this care plan that are defined by
2402   * business processes and/or used to refer to it when a direct URL reference to
2403   * the resource itself is not appropriate (e.g. in CDA documents, or in written
2404   * / printed documentation).
2405   */
2406  @Child(name = "identifier", type = {
2407      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2408  @Description(shortDefinition = "External Ids for this plan", 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).")
2409  protected List<Identifier> identifier;
2410
2411  /**
2412   * Identifies the patient or group whose intended care is described by the plan.
2413   */
2414  @Child(name = "subject", type = { Patient.class,
2415      Group.class }, order = 1, min = 0, max = 1, modifier = false, summary = true)
2416  @Description(shortDefinition = "Who care plan is for", formalDefinition = "Identifies the patient or group whose intended care is described by the plan.")
2417  protected Reference subject;
2418
2419  /**
2420   * The actual object that is the target of the reference (Identifies the patient
2421   * or group whose intended care is described by the plan.)
2422   */
2423  protected Resource subjectTarget;
2424
2425  /**
2426   * Indicates whether the plan is currently being acted upon, represents future
2427   * intentions or is now a historical record.
2428   */
2429  @Child(name = "status", type = { CodeType.class }, order = 2, min = 1, max = 1, modifier = true, summary = true)
2430  @Description(shortDefinition = "proposed | draft | active | completed | cancelled", formalDefinition = "Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.")
2431  protected Enumeration<CarePlanStatus> status;
2432
2433  /**
2434   * Identifies the context in which this particular CarePlan is defined.
2435   */
2436  @Child(name = "context", type = { Encounter.class,
2437      EpisodeOfCare.class }, order = 3, min = 0, max = 1, modifier = false, summary = true)
2438  @Description(shortDefinition = "Created in context of", formalDefinition = "Identifies the context in which this particular CarePlan is defined.")
2439  protected Reference context;
2440
2441  /**
2442   * The actual object that is the target of the reference (Identifies the context
2443   * in which this particular CarePlan is defined.)
2444   */
2445  protected Resource contextTarget;
2446
2447  /**
2448   * Indicates when the plan did (or is intended to) come into effect and end.
2449   */
2450  @Child(name = "period", type = { Period.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
2451  @Description(shortDefinition = "Time period plan covers", formalDefinition = "Indicates when the plan did (or is intended to) come into effect and end.")
2452  protected Period period;
2453
2454  /**
2455   * Identifies the individual(s) or ogranization who is responsible for the
2456   * content of the care plan.
2457   */
2458  @Child(name = "author", type = { Patient.class, Practitioner.class, RelatedPerson.class,
2459      Organization.class }, order = 5, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2460  @Description(shortDefinition = "Who is responsible for contents of the plan", formalDefinition = "Identifies the individual(s) or ogranization who is responsible for the content of the care plan.")
2461  protected List<Reference> author;
2462  /**
2463   * The actual objects that are the target of the reference (Identifies the
2464   * individual(s) or ogranization who is responsible for the content of the care
2465   * plan.)
2466   */
2467  protected List<Resource> authorTarget;
2468
2469  /**
2470   * Identifies the most recent date on which the plan has been revised.
2471   */
2472  @Child(name = "modified", type = {
2473      DateTimeType.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
2474  @Description(shortDefinition = "When last updated", formalDefinition = "Identifies the most recent date on which the plan has been revised.")
2475  protected DateTimeType modified;
2476
2477  /**
2478   * Identifies what "kind" of plan this is to support differentiation between
2479   * multiple co-existing plans; e.g. "Home health", "psychiatric", "asthma",
2480   * "disease management", "wellness plan", etc.
2481   */
2482  @Child(name = "category", type = {
2483      CodeableConcept.class }, order = 7, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2484  @Description(shortDefinition = "Type of plan", formalDefinition = "Identifies what \"kind\" of plan this is to support differentiation between multiple co-existing plans; e.g. \"Home health\", \"psychiatric\", \"asthma\", \"disease management\", \"wellness plan\", etc.")
2485  protected List<CodeableConcept> category;
2486
2487  /**
2488   * A description of the scope and nature of the plan.
2489   */
2490  @Child(name = "description", type = {
2491      StringType.class }, order = 8, min = 0, max = 1, modifier = false, summary = true)
2492  @Description(shortDefinition = "Summary of nature of plan", formalDefinition = "A description of the scope and nature of the plan.")
2493  protected StringType description;
2494
2495  /**
2496   * Identifies the conditions/problems/concerns/diagnoses/etc. whose management
2497   * and/or mitigation are handled by this plan.
2498   */
2499  @Child(name = "addresses", type = {
2500      Condition.class }, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
2501  @Description(shortDefinition = "Health issues this plan addresses", formalDefinition = "Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.")
2502  protected List<Reference> addresses;
2503  /**
2504   * The actual objects that are the target of the reference (Identifies the
2505   * conditions/problems/concerns/diagnoses/etc. whose management and/or
2506   * mitigation are handled by this plan.)
2507   */
2508  protected List<Condition> addressesTarget;
2509
2510  /**
2511   * Identifies portions of the patient's record that specifically influenced the
2512   * formation of the plan. These might include co-morbidities, recent procedures,
2513   * limitations, recent assessments, etc.
2514   */
2515  @Child(name = "support", type = {}, order = 10, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2516  @Description(shortDefinition = "Information considered as part of plan", formalDefinition = "Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include co-morbidities, recent procedures, limitations, recent assessments, etc.")
2517  protected List<Reference> support;
2518  /**
2519   * The actual objects that are the target of the reference (Identifies portions
2520   * of the patient's record that specifically influenced the formation of the
2521   * plan. These might include co-morbidities, recent procedures, limitations,
2522   * recent assessments, etc.)
2523   */
2524  protected List<Resource> supportTarget;
2525
2526  /**
2527   * Identifies CarePlans with some sort of formal relationship to the current
2528   * plan.
2529   */
2530  @Child(name = "relatedPlan", type = {}, order = 11, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2531  @Description(shortDefinition = "Plans related to this one", formalDefinition = "Identifies CarePlans with some sort of formal relationship to the current plan.")
2532  protected List<CarePlanRelatedPlanComponent> relatedPlan;
2533
2534  /**
2535   * Identifies all people and organizations who are expected to be involved in
2536   * the care envisioned by this plan.
2537   */
2538  @Child(name = "participant", type = {}, order = 12, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2539  @Description(shortDefinition = "Who's involved in plan?", formalDefinition = "Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.")
2540  protected List<CarePlanParticipantComponent> participant;
2541
2542  /**
2543   * Describes the intended objective(s) of carrying out the care plan.
2544   */
2545  @Child(name = "goal", type = {
2546      Goal.class }, order = 13, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2547  @Description(shortDefinition = "Desired outcome of plan", formalDefinition = "Describes the intended objective(s) of carrying out the care plan.")
2548  protected List<Reference> goal;
2549  /**
2550   * The actual objects that are the target of the reference (Describes the
2551   * intended objective(s) of carrying out the care plan.)
2552   */
2553  protected List<Goal> goalTarget;
2554
2555  /**
2556   * Identifies a planned action to occur as part of the plan. For example, a
2557   * medication to be used, lab tests to perform, self-monitoring, education, etc.
2558   */
2559  @Child(name = "activity", type = {}, order = 14, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = false)
2560  @Description(shortDefinition = "Action to occur as part of plan", formalDefinition = "Identifies a planned action to occur as part of the plan.  For example, a medication to be used, lab tests to perform, self-monitoring, education, etc.")
2561  protected List<CarePlanActivityComponent> activity;
2562
2563  /**
2564   * General notes about the care plan not covered elsewhere.
2565   */
2566  @Child(name = "note", type = { Annotation.class }, order = 15, min = 0, max = 1, modifier = false, summary = false)
2567  @Description(shortDefinition = "Comments about the plan", formalDefinition = "General notes about the care plan not covered elsewhere.")
2568  protected Annotation note;
2569
2570  private static final long serialVersionUID = -307500543L;
2571
2572  /*
2573   * Constructor
2574   */
2575  public CarePlan() {
2576    super();
2577  }
2578
2579  /*
2580   * Constructor
2581   */
2582  public CarePlan(Enumeration<CarePlanStatus> status) {
2583    super();
2584    this.status = status;
2585  }
2586
2587  /**
2588   * @return {@link #identifier} (This records identifiers associated with this
2589   *         care plan that are defined by business processes and/or used to refer
2590   *         to it when a direct URL reference to the resource itself is not
2591   *         appropriate (e.g. in CDA documents, or in written / printed
2592   *         documentation).)
2593   */
2594  public List<Identifier> getIdentifier() {
2595    if (this.identifier == null)
2596      this.identifier = new ArrayList<Identifier>();
2597    return this.identifier;
2598  }
2599
2600  public boolean hasIdentifier() {
2601    if (this.identifier == null)
2602      return false;
2603    for (Identifier item : this.identifier)
2604      if (!item.isEmpty())
2605        return true;
2606    return false;
2607  }
2608
2609  /**
2610   * @return {@link #identifier} (This records identifiers associated with this
2611   *         care plan that are defined by business processes and/or used to refer
2612   *         to it when a direct URL reference to the resource itself is not
2613   *         appropriate (e.g. in CDA documents, or in written / printed
2614   *         documentation).)
2615   */
2616  // syntactic sugar
2617  public Identifier addIdentifier() { // 3
2618    Identifier t = new Identifier();
2619    if (this.identifier == null)
2620      this.identifier = new ArrayList<Identifier>();
2621    this.identifier.add(t);
2622    return t;
2623  }
2624
2625  // syntactic sugar
2626  public CarePlan addIdentifier(Identifier t) { // 3
2627    if (t == null)
2628      return this;
2629    if (this.identifier == null)
2630      this.identifier = new ArrayList<Identifier>();
2631    this.identifier.add(t);
2632    return this;
2633  }
2634
2635  /**
2636   * @return {@link #subject} (Identifies the patient or group whose intended care
2637   *         is described by the plan.)
2638   */
2639  public Reference getSubject() {
2640    if (this.subject == null)
2641      if (Configuration.errorOnAutoCreate())
2642        throw new Error("Attempt to auto-create CarePlan.subject");
2643      else if (Configuration.doAutoCreate())
2644        this.subject = new Reference(); // cc
2645    return this.subject;
2646  }
2647
2648  public boolean hasSubject() {
2649    return this.subject != null && !this.subject.isEmpty();
2650  }
2651
2652  /**
2653   * @param value {@link #subject} (Identifies the patient or group whose intended
2654   *              care is described by the plan.)
2655   */
2656  public CarePlan setSubject(Reference value) {
2657    this.subject = value;
2658    return this;
2659  }
2660
2661  /**
2662   * @return {@link #subject} The actual object that is the target of the
2663   *         reference. The reference library doesn't populate this, but you can
2664   *         use it to hold the resource if you resolve it. (Identifies the
2665   *         patient or group whose intended care is described by the plan.)
2666   */
2667  public Resource getSubjectTarget() {
2668    return this.subjectTarget;
2669  }
2670
2671  /**
2672   * @param value {@link #subject} The actual object that is the target of the
2673   *              reference. The reference library doesn't use these, but you can
2674   *              use it to hold the resource if you resolve it. (Identifies the
2675   *              patient or group whose intended care is described by the plan.)
2676   */
2677  public CarePlan setSubjectTarget(Resource value) {
2678    this.subjectTarget = value;
2679    return this;
2680  }
2681
2682  /**
2683   * @return {@link #status} (Indicates whether the plan is currently being acted
2684   *         upon, represents future intentions or is now a historical record.).
2685   *         This is the underlying object with id, value and extensions. The
2686   *         accessor "getStatus" gives direct access to the value
2687   */
2688  public Enumeration<CarePlanStatus> getStatusElement() {
2689    if (this.status == null)
2690      if (Configuration.errorOnAutoCreate())
2691        throw new Error("Attempt to auto-create CarePlan.status");
2692      else if (Configuration.doAutoCreate())
2693        this.status = new Enumeration<CarePlanStatus>(new CarePlanStatusEnumFactory()); // bb
2694    return this.status;
2695  }
2696
2697  public boolean hasStatusElement() {
2698    return this.status != null && !this.status.isEmpty();
2699  }
2700
2701  public boolean hasStatus() {
2702    return this.status != null && !this.status.isEmpty();
2703  }
2704
2705  /**
2706   * @param value {@link #status} (Indicates whether the plan is currently being
2707   *              acted upon, represents future intentions or is now a historical
2708   *              record.). This is the underlying object with id, value and
2709   *              extensions. The accessor "getStatus" gives direct access to the
2710   *              value
2711   */
2712  public CarePlan setStatusElement(Enumeration<CarePlanStatus> value) {
2713    this.status = value;
2714    return this;
2715  }
2716
2717  /**
2718   * @return Indicates whether the plan is currently being acted upon, represents
2719   *         future intentions or is now a historical record.
2720   */
2721  public CarePlanStatus getStatus() {
2722    return this.status == null ? null : this.status.getValue();
2723  }
2724
2725  /**
2726   * @param value Indicates whether the plan is currently being acted upon,
2727   *              represents future intentions or is now a historical record.
2728   */
2729  public CarePlan setStatus(CarePlanStatus value) {
2730    if (this.status == null)
2731      this.status = new Enumeration<CarePlanStatus>(new CarePlanStatusEnumFactory());
2732    this.status.setValue(value);
2733    return this;
2734  }
2735
2736  /**
2737   * @return {@link #context} (Identifies the context in which this particular
2738   *         CarePlan is defined.)
2739   */
2740  public Reference getContext() {
2741    if (this.context == null)
2742      if (Configuration.errorOnAutoCreate())
2743        throw new Error("Attempt to auto-create CarePlan.context");
2744      else if (Configuration.doAutoCreate())
2745        this.context = new Reference(); // cc
2746    return this.context;
2747  }
2748
2749  public boolean hasContext() {
2750    return this.context != null && !this.context.isEmpty();
2751  }
2752
2753  /**
2754   * @param value {@link #context} (Identifies the context in which this
2755   *              particular CarePlan is defined.)
2756   */
2757  public CarePlan setContext(Reference value) {
2758    this.context = value;
2759    return this;
2760  }
2761
2762  /**
2763   * @return {@link #context} The actual object that is the target of the
2764   *         reference. The reference library doesn't populate this, but you can
2765   *         use it to hold the resource if you resolve it. (Identifies the
2766   *         context in which this particular CarePlan is defined.)
2767   */
2768  public Resource getContextTarget() {
2769    return this.contextTarget;
2770  }
2771
2772  /**
2773   * @param value {@link #context} The actual object that is the target of the
2774   *              reference. The reference library doesn't use these, but you can
2775   *              use it to hold the resource if you resolve it. (Identifies the
2776   *              context in which this particular CarePlan is defined.)
2777   */
2778  public CarePlan setContextTarget(Resource value) {
2779    this.contextTarget = value;
2780    return this;
2781  }
2782
2783  /**
2784   * @return {@link #period} (Indicates when the plan did (or is intended to) come
2785   *         into effect and end.)
2786   */
2787  public Period getPeriod() {
2788    if (this.period == null)
2789      if (Configuration.errorOnAutoCreate())
2790        throw new Error("Attempt to auto-create CarePlan.period");
2791      else if (Configuration.doAutoCreate())
2792        this.period = new Period(); // cc
2793    return this.period;
2794  }
2795
2796  public boolean hasPeriod() {
2797    return this.period != null && !this.period.isEmpty();
2798  }
2799
2800  /**
2801   * @param value {@link #period} (Indicates when the plan did (or is intended to)
2802   *              come into effect and end.)
2803   */
2804  public CarePlan setPeriod(Period value) {
2805    this.period = value;
2806    return this;
2807  }
2808
2809  /**
2810   * @return {@link #author} (Identifies the individual(s) or ogranization who is
2811   *         responsible for the content of the care plan.)
2812   */
2813  public List<Reference> getAuthor() {
2814    if (this.author == null)
2815      this.author = new ArrayList<Reference>();
2816    return this.author;
2817  }
2818
2819  public boolean hasAuthor() {
2820    if (this.author == null)
2821      return false;
2822    for (Reference item : this.author)
2823      if (!item.isEmpty())
2824        return true;
2825    return false;
2826  }
2827
2828  /**
2829   * @return {@link #author} (Identifies the individual(s) or ogranization who is
2830   *         responsible for the content of the care plan.)
2831   */
2832  // syntactic sugar
2833  public Reference addAuthor() { // 3
2834    Reference t = new Reference();
2835    if (this.author == null)
2836      this.author = new ArrayList<Reference>();
2837    this.author.add(t);
2838    return t;
2839  }
2840
2841  // syntactic sugar
2842  public CarePlan addAuthor(Reference t) { // 3
2843    if (t == null)
2844      return this;
2845    if (this.author == null)
2846      this.author = new ArrayList<Reference>();
2847    this.author.add(t);
2848    return this;
2849  }
2850
2851  /**
2852   * @return {@link #author} (The actual objects that are the target of the
2853   *         reference. The reference library doesn't populate this, but you can
2854   *         use this to hold the resources if you resolvethemt. Identifies the
2855   *         individual(s) or ogranization who is responsible for the content of
2856   *         the care plan.)
2857   */
2858  public List<Resource> getAuthorTarget() {
2859    if (this.authorTarget == null)
2860      this.authorTarget = new ArrayList<Resource>();
2861    return this.authorTarget;
2862  }
2863
2864  /**
2865   * @return {@link #modified} (Identifies the most recent date on which the plan
2866   *         has been revised.). This is the underlying object with id, value and
2867   *         extensions. The accessor "getModified" gives direct access to the
2868   *         value
2869   */
2870  public DateTimeType getModifiedElement() {
2871    if (this.modified == null)
2872      if (Configuration.errorOnAutoCreate())
2873        throw new Error("Attempt to auto-create CarePlan.modified");
2874      else if (Configuration.doAutoCreate())
2875        this.modified = new DateTimeType(); // bb
2876    return this.modified;
2877  }
2878
2879  public boolean hasModifiedElement() {
2880    return this.modified != null && !this.modified.isEmpty();
2881  }
2882
2883  public boolean hasModified() {
2884    return this.modified != null && !this.modified.isEmpty();
2885  }
2886
2887  /**
2888   * @param value {@link #modified} (Identifies the most recent date on which the
2889   *              plan has been revised.). This is the underlying object with id,
2890   *              value and extensions. The accessor "getModified" gives direct
2891   *              access to the value
2892   */
2893  public CarePlan setModifiedElement(DateTimeType value) {
2894    this.modified = value;
2895    return this;
2896  }
2897
2898  /**
2899   * @return Identifies the most recent date on which the plan has been revised.
2900   */
2901  public Date getModified() {
2902    return this.modified == null ? null : this.modified.getValue();
2903  }
2904
2905  /**
2906   * @param value Identifies the most recent date on which the plan has been
2907   *              revised.
2908   */
2909  public CarePlan setModified(Date value) {
2910    if (value == null)
2911      this.modified = null;
2912    else {
2913      if (this.modified == null)
2914        this.modified = new DateTimeType();
2915      this.modified.setValue(value);
2916    }
2917    return this;
2918  }
2919
2920  /**
2921   * @return {@link #category} (Identifies what "kind" of plan this is to support
2922   *         differentiation between multiple co-existing plans; e.g. "Home
2923   *         health", "psychiatric", "asthma", "disease management", "wellness
2924   *         plan", etc.)
2925   */
2926  public List<CodeableConcept> getCategory() {
2927    if (this.category == null)
2928      this.category = new ArrayList<CodeableConcept>();
2929    return this.category;
2930  }
2931
2932  public boolean hasCategory() {
2933    if (this.category == null)
2934      return false;
2935    for (CodeableConcept item : this.category)
2936      if (!item.isEmpty())
2937        return true;
2938    return false;
2939  }
2940
2941  /**
2942   * @return {@link #category} (Identifies what "kind" of plan this is to support
2943   *         differentiation between multiple co-existing plans; e.g. "Home
2944   *         health", "psychiatric", "asthma", "disease management", "wellness
2945   *         plan", etc.)
2946   */
2947  // syntactic sugar
2948  public CodeableConcept addCategory() { // 3
2949    CodeableConcept t = new CodeableConcept();
2950    if (this.category == null)
2951      this.category = new ArrayList<CodeableConcept>();
2952    this.category.add(t);
2953    return t;
2954  }
2955
2956  // syntactic sugar
2957  public CarePlan addCategory(CodeableConcept t) { // 3
2958    if (t == null)
2959      return this;
2960    if (this.category == null)
2961      this.category = new ArrayList<CodeableConcept>();
2962    this.category.add(t);
2963    return this;
2964  }
2965
2966  /**
2967   * @return {@link #description} (A description of the scope and nature of the
2968   *         plan.). This is the underlying object with id, value and extensions.
2969   *         The accessor "getDescription" gives direct access to the value
2970   */
2971  public StringType getDescriptionElement() {
2972    if (this.description == null)
2973      if (Configuration.errorOnAutoCreate())
2974        throw new Error("Attempt to auto-create CarePlan.description");
2975      else if (Configuration.doAutoCreate())
2976        this.description = new StringType(); // bb
2977    return this.description;
2978  }
2979
2980  public boolean hasDescriptionElement() {
2981    return this.description != null && !this.description.isEmpty();
2982  }
2983
2984  public boolean hasDescription() {
2985    return this.description != null && !this.description.isEmpty();
2986  }
2987
2988  /**
2989   * @param value {@link #description} (A description of the scope and nature of
2990   *              the plan.). This is the underlying object with id, value and
2991   *              extensions. The accessor "getDescription" gives direct access to
2992   *              the value
2993   */
2994  public CarePlan setDescriptionElement(StringType value) {
2995    this.description = value;
2996    return this;
2997  }
2998
2999  /**
3000   * @return A description of the scope and nature of the plan.
3001   */
3002  public String getDescription() {
3003    return this.description == null ? null : this.description.getValue();
3004  }
3005
3006  /**
3007   * @param value A description of the scope and nature of the plan.
3008   */
3009  public CarePlan setDescription(String value) {
3010    if (Utilities.noString(value))
3011      this.description = null;
3012    else {
3013      if (this.description == null)
3014        this.description = new StringType();
3015      this.description.setValue(value);
3016    }
3017    return this;
3018  }
3019
3020  /**
3021   * @return {@link #addresses} (Identifies the
3022   *         conditions/problems/concerns/diagnoses/etc. whose management and/or
3023   *         mitigation are handled by this plan.)
3024   */
3025  public List<Reference> getAddresses() {
3026    if (this.addresses == null)
3027      this.addresses = new ArrayList<Reference>();
3028    return this.addresses;
3029  }
3030
3031  public boolean hasAddresses() {
3032    if (this.addresses == null)
3033      return false;
3034    for (Reference item : this.addresses)
3035      if (!item.isEmpty())
3036        return true;
3037    return false;
3038  }
3039
3040  /**
3041   * @return {@link #addresses} (Identifies the
3042   *         conditions/problems/concerns/diagnoses/etc. whose management and/or
3043   *         mitigation are handled by this plan.)
3044   */
3045  // syntactic sugar
3046  public Reference addAddresses() { // 3
3047    Reference t = new Reference();
3048    if (this.addresses == null)
3049      this.addresses = new ArrayList<Reference>();
3050    this.addresses.add(t);
3051    return t;
3052  }
3053
3054  // syntactic sugar
3055  public CarePlan addAddresses(Reference t) { // 3
3056    if (t == null)
3057      return this;
3058    if (this.addresses == null)
3059      this.addresses = new ArrayList<Reference>();
3060    this.addresses.add(t);
3061    return this;
3062  }
3063
3064  /**
3065   * @return {@link #addresses} (The actual objects that are the target of the
3066   *         reference. The reference library doesn't populate this, but you can
3067   *         use this to hold the resources if you resolvethemt. Identifies the
3068   *         conditions/problems/concerns/diagnoses/etc. whose management and/or
3069   *         mitigation are handled by this plan.)
3070   */
3071  public List<Condition> getAddressesTarget() {
3072    if (this.addressesTarget == null)
3073      this.addressesTarget = new ArrayList<Condition>();
3074    return this.addressesTarget;
3075  }
3076
3077  // syntactic sugar
3078  /**
3079   * @return {@link #addresses} (Add an actual object that is the target of the
3080   *         reference. The reference library doesn't use these, but you can use
3081   *         this to hold the resources if you resolvethemt. Identifies the
3082   *         conditions/problems/concerns/diagnoses/etc. whose management and/or
3083   *         mitigation are handled by this plan.)
3084   */
3085  public Condition addAddressesTarget() {
3086    Condition r = new Condition();
3087    if (this.addressesTarget == null)
3088      this.addressesTarget = new ArrayList<Condition>();
3089    this.addressesTarget.add(r);
3090    return r;
3091  }
3092
3093  /**
3094   * @return {@link #support} (Identifies portions of the patient's record that
3095   *         specifically influenced the formation of the plan. These might
3096   *         include co-morbidities, recent procedures, limitations, recent
3097   *         assessments, etc.)
3098   */
3099  public List<Reference> getSupport() {
3100    if (this.support == null)
3101      this.support = new ArrayList<Reference>();
3102    return this.support;
3103  }
3104
3105  public boolean hasSupport() {
3106    if (this.support == null)
3107      return false;
3108    for (Reference item : this.support)
3109      if (!item.isEmpty())
3110        return true;
3111    return false;
3112  }
3113
3114  /**
3115   * @return {@link #support} (Identifies portions of the patient's record that
3116   *         specifically influenced the formation of the plan. These might
3117   *         include co-morbidities, recent procedures, limitations, recent
3118   *         assessments, etc.)
3119   */
3120  // syntactic sugar
3121  public Reference addSupport() { // 3
3122    Reference t = new Reference();
3123    if (this.support == null)
3124      this.support = new ArrayList<Reference>();
3125    this.support.add(t);
3126    return t;
3127  }
3128
3129  // syntactic sugar
3130  public CarePlan addSupport(Reference t) { // 3
3131    if (t == null)
3132      return this;
3133    if (this.support == null)
3134      this.support = new ArrayList<Reference>();
3135    this.support.add(t);
3136    return this;
3137  }
3138
3139  /**
3140   * @return {@link #support} (The actual objects that are the target of the
3141   *         reference. The reference library doesn't populate this, but you can
3142   *         use this to hold the resources if you resolvethemt. Identifies
3143   *         portions of the patient's record that specifically influenced the
3144   *         formation of the plan. These might include co-morbidities, recent
3145   *         procedures, limitations, recent assessments, etc.)
3146   */
3147  public List<Resource> getSupportTarget() {
3148    if (this.supportTarget == null)
3149      this.supportTarget = new ArrayList<Resource>();
3150    return this.supportTarget;
3151  }
3152
3153  /**
3154   * @return {@link #relatedPlan} (Identifies CarePlans with some sort of formal
3155   *         relationship to the current plan.)
3156   */
3157  public List<CarePlanRelatedPlanComponent> getRelatedPlan() {
3158    if (this.relatedPlan == null)
3159      this.relatedPlan = new ArrayList<CarePlanRelatedPlanComponent>();
3160    return this.relatedPlan;
3161  }
3162
3163  public boolean hasRelatedPlan() {
3164    if (this.relatedPlan == null)
3165      return false;
3166    for (CarePlanRelatedPlanComponent item : this.relatedPlan)
3167      if (!item.isEmpty())
3168        return true;
3169    return false;
3170  }
3171
3172  /**
3173   * @return {@link #relatedPlan} (Identifies CarePlans with some sort of formal
3174   *         relationship to the current plan.)
3175   */
3176  // syntactic sugar
3177  public CarePlanRelatedPlanComponent addRelatedPlan() { // 3
3178    CarePlanRelatedPlanComponent t = new CarePlanRelatedPlanComponent();
3179    if (this.relatedPlan == null)
3180      this.relatedPlan = new ArrayList<CarePlanRelatedPlanComponent>();
3181    this.relatedPlan.add(t);
3182    return t;
3183  }
3184
3185  // syntactic sugar
3186  public CarePlan addRelatedPlan(CarePlanRelatedPlanComponent t) { // 3
3187    if (t == null)
3188      return this;
3189    if (this.relatedPlan == null)
3190      this.relatedPlan = new ArrayList<CarePlanRelatedPlanComponent>();
3191    this.relatedPlan.add(t);
3192    return this;
3193  }
3194
3195  /**
3196   * @return {@link #participant} (Identifies all people and organizations who are
3197   *         expected to be involved in the care envisioned by this plan.)
3198   */
3199  public List<CarePlanParticipantComponent> getParticipant() {
3200    if (this.participant == null)
3201      this.participant = new ArrayList<CarePlanParticipantComponent>();
3202    return this.participant;
3203  }
3204
3205  public boolean hasParticipant() {
3206    if (this.participant == null)
3207      return false;
3208    for (CarePlanParticipantComponent item : this.participant)
3209      if (!item.isEmpty())
3210        return true;
3211    return false;
3212  }
3213
3214  /**
3215   * @return {@link #participant} (Identifies all people and organizations who are
3216   *         expected to be involved in the care envisioned by this plan.)
3217   */
3218  // syntactic sugar
3219  public CarePlanParticipantComponent addParticipant() { // 3
3220    CarePlanParticipantComponent t = new CarePlanParticipantComponent();
3221    if (this.participant == null)
3222      this.participant = new ArrayList<CarePlanParticipantComponent>();
3223    this.participant.add(t);
3224    return t;
3225  }
3226
3227  // syntactic sugar
3228  public CarePlan addParticipant(CarePlanParticipantComponent t) { // 3
3229    if (t == null)
3230      return this;
3231    if (this.participant == null)
3232      this.participant = new ArrayList<CarePlanParticipantComponent>();
3233    this.participant.add(t);
3234    return this;
3235  }
3236
3237  /**
3238   * @return {@link #goal} (Describes the intended objective(s) of carrying out
3239   *         the care plan.)
3240   */
3241  public List<Reference> getGoal() {
3242    if (this.goal == null)
3243      this.goal = new ArrayList<Reference>();
3244    return this.goal;
3245  }
3246
3247  public boolean hasGoal() {
3248    if (this.goal == null)
3249      return false;
3250    for (Reference item : this.goal)
3251      if (!item.isEmpty())
3252        return true;
3253    return false;
3254  }
3255
3256  /**
3257   * @return {@link #goal} (Describes the intended objective(s) of carrying out
3258   *         the care plan.)
3259   */
3260  // syntactic sugar
3261  public Reference addGoal() { // 3
3262    Reference t = new Reference();
3263    if (this.goal == null)
3264      this.goal = new ArrayList<Reference>();
3265    this.goal.add(t);
3266    return t;
3267  }
3268
3269  // syntactic sugar
3270  public CarePlan addGoal(Reference t) { // 3
3271    if (t == null)
3272      return this;
3273    if (this.goal == null)
3274      this.goal = new ArrayList<Reference>();
3275    this.goal.add(t);
3276    return this;
3277  }
3278
3279  /**
3280   * @return {@link #goal} (The actual objects that are the target of the
3281   *         reference. The reference library doesn't populate this, but you can
3282   *         use this to hold the resources if you resolvethemt. Describes the
3283   *         intended objective(s) of carrying out the care plan.)
3284   */
3285  public List<Goal> getGoalTarget() {
3286    if (this.goalTarget == null)
3287      this.goalTarget = new ArrayList<Goal>();
3288    return this.goalTarget;
3289  }
3290
3291  // syntactic sugar
3292  /**
3293   * @return {@link #goal} (Add an actual object that is the target of the
3294   *         reference. The reference library doesn't use these, but you can use
3295   *         this to hold the resources if you resolvethemt. Describes the
3296   *         intended objective(s) of carrying out the care plan.)
3297   */
3298  public Goal addGoalTarget() {
3299    Goal r = new Goal();
3300    if (this.goalTarget == null)
3301      this.goalTarget = new ArrayList<Goal>();
3302    this.goalTarget.add(r);
3303    return r;
3304  }
3305
3306  /**
3307   * @return {@link #activity} (Identifies a planned action to occur as part of
3308   *         the plan. For example, a medication to be used, lab tests to perform,
3309   *         self-monitoring, education, etc.)
3310   */
3311  public List<CarePlanActivityComponent> getActivity() {
3312    if (this.activity == null)
3313      this.activity = new ArrayList<CarePlanActivityComponent>();
3314    return this.activity;
3315  }
3316
3317  public boolean hasActivity() {
3318    if (this.activity == null)
3319      return false;
3320    for (CarePlanActivityComponent item : this.activity)
3321      if (!item.isEmpty())
3322        return true;
3323    return false;
3324  }
3325
3326  /**
3327   * @return {@link #activity} (Identifies a planned action to occur as part of
3328   *         the plan. For example, a medication to be used, lab tests to perform,
3329   *         self-monitoring, education, etc.)
3330   */
3331  // syntactic sugar
3332  public CarePlanActivityComponent addActivity() { // 3
3333    CarePlanActivityComponent t = new CarePlanActivityComponent();
3334    if (this.activity == null)
3335      this.activity = new ArrayList<CarePlanActivityComponent>();
3336    this.activity.add(t);
3337    return t;
3338  }
3339
3340  // syntactic sugar
3341  public CarePlan addActivity(CarePlanActivityComponent t) { // 3
3342    if (t == null)
3343      return this;
3344    if (this.activity == null)
3345      this.activity = new ArrayList<CarePlanActivityComponent>();
3346    this.activity.add(t);
3347    return this;
3348  }
3349
3350  /**
3351   * @return {@link #note} (General notes about the care plan not covered
3352   *         elsewhere.)
3353   */
3354  public Annotation getNote() {
3355    if (this.note == null)
3356      if (Configuration.errorOnAutoCreate())
3357        throw new Error("Attempt to auto-create CarePlan.note");
3358      else if (Configuration.doAutoCreate())
3359        this.note = new Annotation(); // cc
3360    return this.note;
3361  }
3362
3363  public boolean hasNote() {
3364    return this.note != null && !this.note.isEmpty();
3365  }
3366
3367  /**
3368   * @param value {@link #note} (General notes about the care plan not covered
3369   *              elsewhere.)
3370   */
3371  public CarePlan setNote(Annotation value) {
3372    this.note = value;
3373    return this;
3374  }
3375
3376  protected void listChildren(List<Property> childrenList) {
3377    super.listChildren(childrenList);
3378    childrenList.add(new Property("identifier", "Identifier",
3379        "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).",
3380        0, java.lang.Integer.MAX_VALUE, identifier));
3381    childrenList.add(new Property("subject", "Reference(Patient|Group)",
3382        "Identifies the patient or group whose intended care is described by the plan.", 0, java.lang.Integer.MAX_VALUE,
3383        subject));
3384    childrenList.add(new Property("status", "code",
3385        "Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.",
3386        0, java.lang.Integer.MAX_VALUE, status));
3387    childrenList.add(new Property("context", "Reference(Encounter|EpisodeOfCare)",
3388        "Identifies the context in which this particular CarePlan is defined.", 0, java.lang.Integer.MAX_VALUE,
3389        context));
3390    childrenList.add(
3391        new Property("period", "Period", "Indicates when the plan did (or is intended to) come into effect and end.", 0,
3392            java.lang.Integer.MAX_VALUE, period));
3393    childrenList.add(new Property("author", "Reference(Patient|Practitioner|RelatedPerson|Organization)",
3394        "Identifies the individual(s) or ogranization who is responsible for the content of the care plan.", 0,
3395        java.lang.Integer.MAX_VALUE, author));
3396    childrenList
3397        .add(new Property("modified", "dateTime", "Identifies the most recent date on which the plan has been revised.",
3398            0, java.lang.Integer.MAX_VALUE, modified));
3399    childrenList.add(new Property("category", "CodeableConcept",
3400        "Identifies what \"kind\" of plan this is to support differentiation between multiple co-existing plans; e.g. \"Home health\", \"psychiatric\", \"asthma\", \"disease management\", \"wellness plan\", etc.",
3401        0, java.lang.Integer.MAX_VALUE, category));
3402    childrenList.add(new Property("description", "string", "A description of the scope and nature of the plan.", 0,
3403        java.lang.Integer.MAX_VALUE, description));
3404    childrenList.add(new Property("addresses", "Reference(Condition)",
3405        "Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.",
3406        0, java.lang.Integer.MAX_VALUE, addresses));
3407    childrenList.add(new Property("support", "Reference(Any)",
3408        "Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include co-morbidities, recent procedures, limitations, recent assessments, etc.",
3409        0, java.lang.Integer.MAX_VALUE, support));
3410    childrenList.add(new Property("relatedPlan", "",
3411        "Identifies CarePlans with some sort of formal relationship to the current plan.", 0,
3412        java.lang.Integer.MAX_VALUE, relatedPlan));
3413    childrenList.add(new Property("participant", "",
3414        "Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.",
3415        0, java.lang.Integer.MAX_VALUE, participant));
3416    childrenList.add(new Property("goal", "Reference(Goal)",
3417        "Describes the intended objective(s) of carrying out the care plan.", 0, java.lang.Integer.MAX_VALUE, goal));
3418    childrenList.add(new Property("activity", "",
3419        "Identifies a planned action to occur as part of the plan.  For example, a medication to be used, lab tests to perform, self-monitoring, education, etc.",
3420        0, java.lang.Integer.MAX_VALUE, activity));
3421    childrenList.add(new Property("note", "Annotation", "General notes about the care plan not covered elsewhere.", 0,
3422        java.lang.Integer.MAX_VALUE, note));
3423  }
3424
3425  @Override
3426  public void setProperty(String name, Base value) throws FHIRException {
3427    if (name.equals("identifier"))
3428      this.getIdentifier().add(castToIdentifier(value));
3429    else if (name.equals("subject"))
3430      this.subject = castToReference(value); // Reference
3431    else if (name.equals("status"))
3432      this.status = new CarePlanStatusEnumFactory().fromType(value); // Enumeration<CarePlanStatus>
3433    else if (name.equals("context"))
3434      this.context = castToReference(value); // Reference
3435    else if (name.equals("period"))
3436      this.period = castToPeriod(value); // Period
3437    else if (name.equals("author"))
3438      this.getAuthor().add(castToReference(value));
3439    else if (name.equals("modified"))
3440      this.modified = castToDateTime(value); // DateTimeType
3441    else if (name.equals("category"))
3442      this.getCategory().add(castToCodeableConcept(value));
3443    else if (name.equals("description"))
3444      this.description = castToString(value); // StringType
3445    else if (name.equals("addresses"))
3446      this.getAddresses().add(castToReference(value));
3447    else if (name.equals("support"))
3448      this.getSupport().add(castToReference(value));
3449    else if (name.equals("relatedPlan"))
3450      this.getRelatedPlan().add((CarePlanRelatedPlanComponent) value);
3451    else if (name.equals("participant"))
3452      this.getParticipant().add((CarePlanParticipantComponent) value);
3453    else if (name.equals("goal"))
3454      this.getGoal().add(castToReference(value));
3455    else if (name.equals("activity"))
3456      this.getActivity().add((CarePlanActivityComponent) value);
3457    else if (name.equals("note"))
3458      this.note = castToAnnotation(value); // Annotation
3459    else
3460      super.setProperty(name, value);
3461  }
3462
3463  @Override
3464  public Base addChild(String name) throws FHIRException {
3465    if (name.equals("identifier")) {
3466      return addIdentifier();
3467    } else if (name.equals("subject")) {
3468      this.subject = new Reference();
3469      return this.subject;
3470    } else if (name.equals("status")) {
3471      throw new FHIRException("Cannot call addChild on a singleton property CarePlan.status");
3472    } else if (name.equals("context")) {
3473      this.context = new Reference();
3474      return this.context;
3475    } else if (name.equals("period")) {
3476      this.period = new Period();
3477      return this.period;
3478    } else if (name.equals("author")) {
3479      return addAuthor();
3480    } else if (name.equals("modified")) {
3481      throw new FHIRException("Cannot call addChild on a singleton property CarePlan.modified");
3482    } else if (name.equals("category")) {
3483      return addCategory();
3484    } else if (name.equals("description")) {
3485      throw new FHIRException("Cannot call addChild on a singleton property CarePlan.description");
3486    } else if (name.equals("addresses")) {
3487      return addAddresses();
3488    } else if (name.equals("support")) {
3489      return addSupport();
3490    } else if (name.equals("relatedPlan")) {
3491      return addRelatedPlan();
3492    } else if (name.equals("participant")) {
3493      return addParticipant();
3494    } else if (name.equals("goal")) {
3495      return addGoal();
3496    } else if (name.equals("activity")) {
3497      return addActivity();
3498    } else if (name.equals("note")) {
3499      this.note = new Annotation();
3500      return this.note;
3501    } else
3502      return super.addChild(name);
3503  }
3504
3505  public String fhirType() {
3506    return "CarePlan";
3507
3508  }
3509
3510  public CarePlan copy() {
3511    CarePlan dst = new CarePlan();
3512    copyValues(dst);
3513    if (identifier != null) {
3514      dst.identifier = new ArrayList<Identifier>();
3515      for (Identifier i : identifier)
3516        dst.identifier.add(i.copy());
3517    }
3518    ;
3519    dst.subject = subject == null ? null : subject.copy();
3520    dst.status = status == null ? null : status.copy();
3521    dst.context = context == null ? null : context.copy();
3522    dst.period = period == null ? null : period.copy();
3523    if (author != null) {
3524      dst.author = new ArrayList<Reference>();
3525      for (Reference i : author)
3526        dst.author.add(i.copy());
3527    }
3528    ;
3529    dst.modified = modified == null ? null : modified.copy();
3530    if (category != null) {
3531      dst.category = new ArrayList<CodeableConcept>();
3532      for (CodeableConcept i : category)
3533        dst.category.add(i.copy());
3534    }
3535    ;
3536    dst.description = description == null ? null : description.copy();
3537    if (addresses != null) {
3538      dst.addresses = new ArrayList<Reference>();
3539      for (Reference i : addresses)
3540        dst.addresses.add(i.copy());
3541    }
3542    ;
3543    if (support != null) {
3544      dst.support = new ArrayList<Reference>();
3545      for (Reference i : support)
3546        dst.support.add(i.copy());
3547    }
3548    ;
3549    if (relatedPlan != null) {
3550      dst.relatedPlan = new ArrayList<CarePlanRelatedPlanComponent>();
3551      for (CarePlanRelatedPlanComponent i : relatedPlan)
3552        dst.relatedPlan.add(i.copy());
3553    }
3554    ;
3555    if (participant != null) {
3556      dst.participant = new ArrayList<CarePlanParticipantComponent>();
3557      for (CarePlanParticipantComponent i : participant)
3558        dst.participant.add(i.copy());
3559    }
3560    ;
3561    if (goal != null) {
3562      dst.goal = new ArrayList<Reference>();
3563      for (Reference i : goal)
3564        dst.goal.add(i.copy());
3565    }
3566    ;
3567    if (activity != null) {
3568      dst.activity = new ArrayList<CarePlanActivityComponent>();
3569      for (CarePlanActivityComponent i : activity)
3570        dst.activity.add(i.copy());
3571    }
3572    ;
3573    dst.note = note == null ? null : note.copy();
3574    return dst;
3575  }
3576
3577  protected CarePlan typedCopy() {
3578    return copy();
3579  }
3580
3581  @Override
3582  public boolean equalsDeep(Base other) {
3583    if (!super.equalsDeep(other))
3584      return false;
3585    if (!(other instanceof CarePlan))
3586      return false;
3587    CarePlan o = (CarePlan) other;
3588    return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true)
3589        && compareDeep(status, o.status, true) && compareDeep(context, o.context, true)
3590        && compareDeep(period, o.period, true) && compareDeep(author, o.author, true)
3591        && compareDeep(modified, o.modified, true) && compareDeep(category, o.category, true)
3592        && compareDeep(description, o.description, true) && compareDeep(addresses, o.addresses, true)
3593        && compareDeep(support, o.support, true) && compareDeep(relatedPlan, o.relatedPlan, true)
3594        && compareDeep(participant, o.participant, true) && compareDeep(goal, o.goal, true)
3595        && compareDeep(activity, o.activity, true) && compareDeep(note, o.note, true);
3596  }
3597
3598  @Override
3599  public boolean equalsShallow(Base other) {
3600    if (!super.equalsShallow(other))
3601      return false;
3602    if (!(other instanceof CarePlan))
3603      return false;
3604    CarePlan o = (CarePlan) other;
3605    return compareValues(status, o.status, true) && compareValues(modified, o.modified, true)
3606        && compareValues(description, o.description, true);
3607  }
3608
3609  public boolean isEmpty() {
3610    return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
3611        && (status == null || status.isEmpty()) && (context == null || context.isEmpty())
3612        && (period == null || period.isEmpty()) && (author == null || author.isEmpty())
3613        && (modified == null || modified.isEmpty()) && (category == null || category.isEmpty())
3614        && (description == null || description.isEmpty()) && (addresses == null || addresses.isEmpty())
3615        && (support == null || support.isEmpty()) && (relatedPlan == null || relatedPlan.isEmpty())
3616        && (participant == null || participant.isEmpty()) && (goal == null || goal.isEmpty())
3617        && (activity == null || activity.isEmpty()) && (note == null || note.isEmpty());
3618  }
3619
3620  @Override
3621  public ResourceType getResourceType() {
3622    return ResourceType.CarePlan;
3623  }
3624
3625  @SearchParamDefinition(name = "date", path = "CarePlan.period", description = "Time period plan covers", type = "date")
3626  public static final String SP_DATE = "date";
3627  @SearchParamDefinition(name = "activitycode", path = "CarePlan.activity.detail.code", description = "Detail type of activity", type = "token")
3628  public static final String SP_ACTIVITYCODE = "activitycode";
3629  @SearchParamDefinition(name = "activitydate", path = "CarePlan.activity.detail.scheduled[x]", description = "Specified date occurs within period specified by CarePlan.activity.timingSchedule", type = "date")
3630  public static final String SP_ACTIVITYDATE = "activitydate";
3631  @SearchParamDefinition(name = "activityreference", path = "CarePlan.activity.reference", description = "Activity details defined in specific resource", type = "reference")
3632  public static final String SP_ACTIVITYREFERENCE = "activityreference";
3633  @SearchParamDefinition(name = "performer", path = "CarePlan.activity.detail.performer", description = "Matches if the practitioner is listed as a performer in any of the \"simple\" activities.  (For performers of the detailed activities, chain through the activitydetail search parameter.)", type = "reference")
3634  public static final String SP_PERFORMER = "performer";
3635  @SearchParamDefinition(name = "goal", path = "CarePlan.goal", description = "Desired outcome of plan", type = "reference")
3636  public static final String SP_GOAL = "goal";
3637  @SearchParamDefinition(name = "subject", path = "CarePlan.subject", description = "Who care plan is for", type = "reference")
3638  public static final String SP_SUBJECT = "subject";
3639  @SearchParamDefinition(name = "relatedcode", path = "CarePlan.relatedPlan.code", description = "includes | replaces | fulfills", type = "token")
3640  public static final String SP_RELATEDCODE = "relatedcode";
3641  @SearchParamDefinition(name = "participant", path = "CarePlan.participant.member", description = "Who is involved", type = "reference")
3642  public static final String SP_PARTICIPANT = "participant";
3643  @SearchParamDefinition(name = "relatedplan", path = "CarePlan.relatedPlan.plan", description = "Plan relationship exists with", type = "reference")
3644  public static final String SP_RELATEDPLAN = "relatedplan";
3645  @SearchParamDefinition(name = "condition", path = "CarePlan.addresses", description = "Health issues this plan addresses", type = "reference")
3646  public static final String SP_CONDITION = "condition";
3647  @SearchParamDefinition(name = "related", path = "null", description = "A combination of the type of relationship and the related plan", type = "composite")
3648  public static final String SP_RELATED = "related";
3649  @SearchParamDefinition(name = "patient", path = "CarePlan.subject", description = "Who care plan is for", type = "reference")
3650  public static final String SP_PATIENT = "patient";
3651
3652}