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