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