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