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