001package org.hl7.fhir.r5.model;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
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  Copyright (c) 2011+, HL7, Inc.
025  All rights reserved.
026  
027  Redistribution and use in source and binary forms, with or without modification, 
028  are permitted provided that the following conditions are met:
029  
030   * Redistributions of source code must retain the above copyright notice, this 
031     list of conditions and the following disclaimer.
032   * Redistributions in binary form must reproduce the above copyright notice, 
033     this list of conditions and the following disclaimer in the documentation 
034     and/or other materials provided with the distribution.
035   * Neither the name of HL7 nor the names of its contributors may be used to 
036     endorse or promote products derived from this software without specific 
037     prior written permission.
038  
039  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
040  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
041  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
042  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
043  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
044  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
045  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
046  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
047  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
048  POSSIBILITY OF SUCH DAMAGE.
049  
050*/
051
052// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
053import java.util.ArrayList;
054import java.util.Date;
055import java.util.List;
056import org.hl7.fhir.exceptions.FHIRException;
057import org.hl7.fhir.instance.model.api.ICompositeType;
058
059import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
060import org.hl7.fhir.utilities.Utilities;
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 ca.uhn.fhir.model.api.annotation.Child;
065import ca.uhn.fhir.model.api.annotation.ChildOrder;
066import ca.uhn.fhir.model.api.annotation.Description;
067import ca.uhn.fhir.model.api.annotation.Block;
068/**
069 * 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.
070 */
071@ResourceDef(name="CarePlan", profile="http://hl7.org/fhir/StructureDefinition/CarePlan")
072public class CarePlan extends DomainResource {
073
074    public enum CarePlanStatus {
075        /**
076         * The request has been created but is not yet complete or ready for action.
077         */
078        DRAFT, 
079        /**
080         * The request is in force and ready to be acted upon.
081         */
082        ACTIVE, 
083        /**
084         * The request (and any implicit authorization to act) has been temporarily withdrawn but is expected to resume in the future.
085         */
086        ONHOLD, 
087        /**
088         * The request (and any implicit authorization to act) has been terminated prior to the known full completion of the intended actions.  No further activity should occur.
089         */
090        REVOKED, 
091        /**
092         * The activity described by the request has been fully performed.  No further activity will occur.
093         */
094        COMPLETED, 
095        /**
096         * This request should never have existed and should be considered 'void'.  (It is possible that real-world decisions were based on it.  If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).
097         */
098        ENTEREDINERROR, 
099        /**
100         * The authoring/source system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.
101         */
102        UNKNOWN, 
103        /**
104         * added to help the parsers with the generic types
105         */
106        NULL;
107        public static CarePlanStatus fromCode(String codeString) throws FHIRException {
108            if (codeString == null || "".equals(codeString))
109                return null;
110        if ("draft".equals(codeString))
111          return DRAFT;
112        if ("active".equals(codeString))
113          return ACTIVE;
114        if ("on-hold".equals(codeString))
115          return ONHOLD;
116        if ("revoked".equals(codeString))
117          return REVOKED;
118        if ("completed".equals(codeString))
119          return COMPLETED;
120        if ("entered-in-error".equals(codeString))
121          return ENTEREDINERROR;
122        if ("unknown".equals(codeString))
123          return UNKNOWN;
124        if (Configuration.isAcceptInvalidEnums())
125          return null;
126        else
127          throw new FHIRException("Unknown CarePlanStatus code '"+codeString+"'");
128        }
129        public String toCode() {
130          switch (this) {
131            case DRAFT: return "draft";
132            case ACTIVE: return "active";
133            case ONHOLD: return "on-hold";
134            case REVOKED: return "revoked";
135            case COMPLETED: return "completed";
136            case ENTEREDINERROR: return "entered-in-error";
137            case UNKNOWN: return "unknown";
138            default: return "?";
139          }
140        }
141        public String getSystem() {
142          switch (this) {
143            case DRAFT: return "http://hl7.org/fhir/request-status";
144            case ACTIVE: return "http://hl7.org/fhir/request-status";
145            case ONHOLD: return "http://hl7.org/fhir/request-status";
146            case REVOKED: return "http://hl7.org/fhir/request-status";
147            case COMPLETED: return "http://hl7.org/fhir/request-status";
148            case ENTEREDINERROR: return "http://hl7.org/fhir/request-status";
149            case UNKNOWN: return "http://hl7.org/fhir/request-status";
150            default: return "?";
151          }
152        }
153        public String getDefinition() {
154          switch (this) {
155            case DRAFT: return "The request has been created but is not yet complete or ready for action.";
156            case ACTIVE: return "The request is in force and ready to be acted upon.";
157            case ONHOLD: return "The request (and any implicit authorization to act) has been temporarily withdrawn but is expected to resume in the future.";
158            case REVOKED: return "The request (and any implicit authorization to act) has been terminated prior to the known full completion of the intended actions.  No further activity should occur.";
159            case COMPLETED: return "The activity described by the request has been fully performed.  No further activity will occur.";
160            case ENTEREDINERROR: return "This request should never have existed and should be considered 'void'.  (It is possible that real-world decisions were based on it.  If real-world activity has occurred, the status should be \"cancelled\" rather than \"entered-in-error\".).";
161            case UNKNOWN: return "The authoring/source system does not know which of the status values currently applies for this request.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply,  but the authoring/source system does not know which.";
162            default: return "?";
163          }
164        }
165        public String getDisplay() {
166          switch (this) {
167            case DRAFT: return "Draft";
168            case ACTIVE: return "Active";
169            case ONHOLD: return "On Hold";
170            case REVOKED: return "Revoked";
171            case COMPLETED: return "Completed";
172            case ENTEREDINERROR: return "Entered in Error";
173            case UNKNOWN: return "Unknown";
174            default: return "?";
175          }
176        }
177    }
178
179  public static class CarePlanStatusEnumFactory implements EnumFactory<CarePlanStatus> {
180    public CarePlanStatus fromCode(String codeString) throws IllegalArgumentException {
181      if (codeString == null || "".equals(codeString))
182            if (codeString == null || "".equals(codeString))
183                return null;
184        if ("draft".equals(codeString))
185          return CarePlanStatus.DRAFT;
186        if ("active".equals(codeString))
187          return CarePlanStatus.ACTIVE;
188        if ("on-hold".equals(codeString))
189          return CarePlanStatus.ONHOLD;
190        if ("revoked".equals(codeString))
191          return CarePlanStatus.REVOKED;
192        if ("completed".equals(codeString))
193          return CarePlanStatus.COMPLETED;
194        if ("entered-in-error".equals(codeString))
195          return CarePlanStatus.ENTEREDINERROR;
196        if ("unknown".equals(codeString))
197          return CarePlanStatus.UNKNOWN;
198        throw new IllegalArgumentException("Unknown CarePlanStatus code '"+codeString+"'");
199        }
200        public Enumeration<CarePlanStatus> fromType(Base code) throws FHIRException {
201          if (code == null)
202            return null;
203          if (code.isEmpty())
204            return new Enumeration<CarePlanStatus>(this);
205          String codeString = ((PrimitiveType) code).asStringValue();
206          if (codeString == null || "".equals(codeString))
207            return null;
208        if ("draft".equals(codeString))
209          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.DRAFT);
210        if ("active".equals(codeString))
211          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.ACTIVE);
212        if ("on-hold".equals(codeString))
213          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.ONHOLD);
214        if ("revoked".equals(codeString))
215          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.REVOKED);
216        if ("completed".equals(codeString))
217          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.COMPLETED);
218        if ("entered-in-error".equals(codeString))
219          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.ENTEREDINERROR);
220        if ("unknown".equals(codeString))
221          return new Enumeration<CarePlanStatus>(this, CarePlanStatus.UNKNOWN);
222        throw new FHIRException("Unknown CarePlanStatus code '"+codeString+"'");
223        }
224    public String toCode(CarePlanStatus code) {
225      if (code == CarePlanStatus.DRAFT)
226        return "draft";
227      if (code == CarePlanStatus.ACTIVE)
228        return "active";
229      if (code == CarePlanStatus.ONHOLD)
230        return "on-hold";
231      if (code == CarePlanStatus.REVOKED)
232        return "revoked";
233      if (code == CarePlanStatus.COMPLETED)
234        return "completed";
235      if (code == CarePlanStatus.ENTEREDINERROR)
236        return "entered-in-error";
237      if (code == CarePlanStatus.UNKNOWN)
238        return "unknown";
239      return "?";
240      }
241    public String toSystem(CarePlanStatus code) {
242      return code.getSystem();
243      }
244    }
245
246    public enum CarePlanIntent {
247        /**
248         * null
249         */
250        PROPOSAL, 
251        /**
252         * null
253         */
254        PLAN, 
255        /**
256         * null
257         */
258        ORDER, 
259        /**
260         * null
261         */
262        OPTION, 
263        /**
264         * null
265         */
266        DIRECTIVE, 
267        /**
268         * added to help the parsers with the generic types
269         */
270        NULL;
271        public static CarePlanIntent fromCode(String codeString) throws FHIRException {
272            if (codeString == null || "".equals(codeString))
273                return null;
274        if ("proposal".equals(codeString))
275          return PROPOSAL;
276        if ("plan".equals(codeString))
277          return PLAN;
278        if ("order".equals(codeString))
279          return ORDER;
280        if ("option".equals(codeString))
281          return OPTION;
282        if ("directive".equals(codeString))
283          return DIRECTIVE;
284        if (Configuration.isAcceptInvalidEnums())
285          return null;
286        else
287          throw new FHIRException("Unknown CarePlanIntent code '"+codeString+"'");
288        }
289        public String toCode() {
290          switch (this) {
291            case PROPOSAL: return "proposal";
292            case PLAN: return "plan";
293            case ORDER: return "order";
294            case OPTION: return "option";
295            case DIRECTIVE: return "directive";
296            default: return "?";
297          }
298        }
299        public String getSystem() {
300          switch (this) {
301            case PROPOSAL: return "http://hl7.org/fhir/request-intent";
302            case PLAN: return "http://hl7.org/fhir/request-intent";
303            case ORDER: return "http://hl7.org/fhir/request-intent";
304            case OPTION: return "http://hl7.org/fhir/request-intent";
305            case DIRECTIVE: return "http://hl7.org/fhir/request-intent";
306            default: return "?";
307          }
308        }
309        public String getDefinition() {
310          switch (this) {
311            case PROPOSAL: return "";
312            case PLAN: return "";
313            case ORDER: return "";
314            case OPTION: return "";
315            case DIRECTIVE: return "";
316            default: return "?";
317          }
318        }
319        public String getDisplay() {
320          switch (this) {
321            case PROPOSAL: return "proposal";
322            case PLAN: return "plan";
323            case ORDER: return "order";
324            case OPTION: return "option";
325            case DIRECTIVE: return "directive";
326            default: return "?";
327          }
328        }
329    }
330
331  public static class CarePlanIntentEnumFactory implements EnumFactory<CarePlanIntent> {
332    public CarePlanIntent fromCode(String codeString) throws IllegalArgumentException {
333      if (codeString == null || "".equals(codeString))
334            if (codeString == null || "".equals(codeString))
335                return null;
336        if ("proposal".equals(codeString))
337          return CarePlanIntent.PROPOSAL;
338        if ("plan".equals(codeString))
339          return CarePlanIntent.PLAN;
340        if ("order".equals(codeString))
341          return CarePlanIntent.ORDER;
342        if ("option".equals(codeString))
343          return CarePlanIntent.OPTION;
344        if ("directive".equals(codeString))
345          return CarePlanIntent.DIRECTIVE;
346        throw new IllegalArgumentException("Unknown CarePlanIntent code '"+codeString+"'");
347        }
348        public Enumeration<CarePlanIntent> fromType(Base code) throws FHIRException {
349          if (code == null)
350            return null;
351          if (code.isEmpty())
352            return new Enumeration<CarePlanIntent>(this);
353          String codeString = ((PrimitiveType) code).asStringValue();
354          if (codeString == null || "".equals(codeString))
355            return null;
356        if ("proposal".equals(codeString))
357          return new Enumeration<CarePlanIntent>(this, CarePlanIntent.PROPOSAL);
358        if ("plan".equals(codeString))
359          return new Enumeration<CarePlanIntent>(this, CarePlanIntent.PLAN);
360        if ("order".equals(codeString))
361          return new Enumeration<CarePlanIntent>(this, CarePlanIntent.ORDER);
362        if ("option".equals(codeString))
363          return new Enumeration<CarePlanIntent>(this, CarePlanIntent.OPTION);
364        if ("directive".equals(codeString))
365          return new Enumeration<CarePlanIntent>(this, CarePlanIntent.DIRECTIVE);
366        throw new FHIRException("Unknown CarePlanIntent code '"+codeString+"'");
367        }
368    public String toCode(CarePlanIntent code) {
369      if (code == CarePlanIntent.PROPOSAL)
370        return "proposal";
371      if (code == CarePlanIntent.PLAN)
372        return "plan";
373      if (code == CarePlanIntent.ORDER)
374        return "order";
375      if (code == CarePlanIntent.OPTION)
376        return "option";
377      if (code == CarePlanIntent.DIRECTIVE)
378        return "directive";
379      return "?";
380      }
381    public String toSystem(CarePlanIntent code) {
382      return code.getSystem();
383      }
384    }
385
386    public enum CarePlanActivityKind {
387        /**
388         * null
389         */
390        APPOINTMENT, 
391        /**
392         * null
393         */
394        COMMUNICATIONREQUEST, 
395        /**
396         * null
397         */
398        DEVICEREQUEST, 
399        /**
400         * null
401         */
402        MEDICATIONREQUEST, 
403        /**
404         * null
405         */
406        NUTRITIONORDER, 
407        /**
408         * null
409         */
410        TASK, 
411        /**
412         * null
413         */
414        SERVICEREQUEST, 
415        /**
416         * null
417         */
418        VISIONPRESCRIPTION, 
419        /**
420         * added to help the parsers with the generic types
421         */
422        NULL;
423        public static CarePlanActivityKind fromCode(String codeString) throws FHIRException {
424            if (codeString == null || "".equals(codeString))
425                return null;
426        if ("Appointment".equals(codeString))
427          return APPOINTMENT;
428        if ("CommunicationRequest".equals(codeString))
429          return COMMUNICATIONREQUEST;
430        if ("DeviceRequest".equals(codeString))
431          return DEVICEREQUEST;
432        if ("MedicationRequest".equals(codeString))
433          return MEDICATIONREQUEST;
434        if ("NutritionOrder".equals(codeString))
435          return NUTRITIONORDER;
436        if ("Task".equals(codeString))
437          return TASK;
438        if ("ServiceRequest".equals(codeString))
439          return SERVICEREQUEST;
440        if ("VisionPrescription".equals(codeString))
441          return VISIONPRESCRIPTION;
442        if (Configuration.isAcceptInvalidEnums())
443          return null;
444        else
445          throw new FHIRException("Unknown CarePlanActivityKind code '"+codeString+"'");
446        }
447        public String toCode() {
448          switch (this) {
449            case APPOINTMENT: return "Appointment";
450            case COMMUNICATIONREQUEST: return "CommunicationRequest";
451            case DEVICEREQUEST: return "DeviceRequest";
452            case MEDICATIONREQUEST: return "MedicationRequest";
453            case NUTRITIONORDER: return "NutritionOrder";
454            case TASK: return "Task";
455            case SERVICEREQUEST: return "ServiceRequest";
456            case VISIONPRESCRIPTION: return "VisionPrescription";
457            default: return "?";
458          }
459        }
460        public String getSystem() {
461          switch (this) {
462            case APPOINTMENT: return "http://hl7.org/fhir/resource-types";
463            case COMMUNICATIONREQUEST: return "http://hl7.org/fhir/resource-types";
464            case DEVICEREQUEST: return "http://hl7.org/fhir/resource-types";
465            case MEDICATIONREQUEST: return "http://hl7.org/fhir/resource-types";
466            case NUTRITIONORDER: return "http://hl7.org/fhir/resource-types";
467            case TASK: return "http://hl7.org/fhir/resource-types";
468            case SERVICEREQUEST: return "http://hl7.org/fhir/resource-types";
469            case VISIONPRESCRIPTION: return "http://hl7.org/fhir/resource-types";
470            default: return "?";
471          }
472        }
473        public String getDefinition() {
474          switch (this) {
475            case APPOINTMENT: return "";
476            case COMMUNICATIONREQUEST: return "";
477            case DEVICEREQUEST: return "";
478            case MEDICATIONREQUEST: return "";
479            case NUTRITIONORDER: return "";
480            case TASK: return "";
481            case SERVICEREQUEST: return "";
482            case VISIONPRESCRIPTION: return "";
483            default: return "?";
484          }
485        }
486        public String getDisplay() {
487          switch (this) {
488            case APPOINTMENT: return "Appointment";
489            case COMMUNICATIONREQUEST: return "CommunicationRequest";
490            case DEVICEREQUEST: return "DeviceRequest";
491            case MEDICATIONREQUEST: return "MedicationRequest";
492            case NUTRITIONORDER: return "NutritionOrder";
493            case TASK: return "Task";
494            case SERVICEREQUEST: return "ServiceRequest";
495            case VISIONPRESCRIPTION: return "VisionPrescription";
496            default: return "?";
497          }
498        }
499    }
500
501  public static class CarePlanActivityKindEnumFactory implements EnumFactory<CarePlanActivityKind> {
502    public CarePlanActivityKind fromCode(String codeString) throws IllegalArgumentException {
503      if (codeString == null || "".equals(codeString))
504            if (codeString == null || "".equals(codeString))
505                return null;
506        if ("Appointment".equals(codeString))
507          return CarePlanActivityKind.APPOINTMENT;
508        if ("CommunicationRequest".equals(codeString))
509          return CarePlanActivityKind.COMMUNICATIONREQUEST;
510        if ("DeviceRequest".equals(codeString))
511          return CarePlanActivityKind.DEVICEREQUEST;
512        if ("MedicationRequest".equals(codeString))
513          return CarePlanActivityKind.MEDICATIONREQUEST;
514        if ("NutritionOrder".equals(codeString))
515          return CarePlanActivityKind.NUTRITIONORDER;
516        if ("Task".equals(codeString))
517          return CarePlanActivityKind.TASK;
518        if ("ServiceRequest".equals(codeString))
519          return CarePlanActivityKind.SERVICEREQUEST;
520        if ("VisionPrescription".equals(codeString))
521          return CarePlanActivityKind.VISIONPRESCRIPTION;
522        throw new IllegalArgumentException("Unknown CarePlanActivityKind code '"+codeString+"'");
523        }
524        public Enumeration<CarePlanActivityKind> fromType(Base code) throws FHIRException {
525          if (code == null)
526            return null;
527          if (code.isEmpty())
528            return new Enumeration<CarePlanActivityKind>(this);
529          String codeString = ((PrimitiveType) code).asStringValue();
530          if (codeString == null || "".equals(codeString))
531            return null;
532        if ("Appointment".equals(codeString))
533          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.APPOINTMENT);
534        if ("CommunicationRequest".equals(codeString))
535          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.COMMUNICATIONREQUEST);
536        if ("DeviceRequest".equals(codeString))
537          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.DEVICEREQUEST);
538        if ("MedicationRequest".equals(codeString))
539          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.MEDICATIONREQUEST);
540        if ("NutritionOrder".equals(codeString))
541          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.NUTRITIONORDER);
542        if ("Task".equals(codeString))
543          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.TASK);
544        if ("ServiceRequest".equals(codeString))
545          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.SERVICEREQUEST);
546        if ("VisionPrescription".equals(codeString))
547          return new Enumeration<CarePlanActivityKind>(this, CarePlanActivityKind.VISIONPRESCRIPTION);
548        throw new FHIRException("Unknown CarePlanActivityKind code '"+codeString+"'");
549        }
550    public String toCode(CarePlanActivityKind code) {
551      if (code == CarePlanActivityKind.APPOINTMENT)
552        return "Appointment";
553      if (code == CarePlanActivityKind.COMMUNICATIONREQUEST)
554        return "CommunicationRequest";
555      if (code == CarePlanActivityKind.DEVICEREQUEST)
556        return "DeviceRequest";
557      if (code == CarePlanActivityKind.MEDICATIONREQUEST)
558        return "MedicationRequest";
559      if (code == CarePlanActivityKind.NUTRITIONORDER)
560        return "NutritionOrder";
561      if (code == CarePlanActivityKind.TASK)
562        return "Task";
563      if (code == CarePlanActivityKind.SERVICEREQUEST)
564        return "ServiceRequest";
565      if (code == CarePlanActivityKind.VISIONPRESCRIPTION)
566        return "VisionPrescription";
567      return "?";
568      }
569    public String toSystem(CarePlanActivityKind code) {
570      return code.getSystem();
571      }
572    }
573
574    public enum CarePlanActivityStatus {
575        /**
576         * Care plan activity is planned but no action has yet been taken.
577         */
578        NOTSTARTED, 
579        /**
580         * Appointment or other booking has occurred but activity has not yet begun.
581         */
582        SCHEDULED, 
583        /**
584         * Care plan activity has been started but is not yet complete.
585         */
586        INPROGRESS, 
587        /**
588         * Care plan activity was started but has temporarily ceased with an expectation of resumption at a future time.
589         */
590        ONHOLD, 
591        /**
592         * Care plan activity has been completed (more or less) as planned.
593         */
594        COMPLETED, 
595        /**
596         * The planned care plan activity has been withdrawn.
597         */
598        CANCELLED, 
599        /**
600         * The planned care plan activity has been ended prior to completion after the activity was started.
601         */
602        STOPPED, 
603        /**
604         * The current state of the care plan activity is not known.  Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which one.
605         */
606        UNKNOWN, 
607        /**
608         * Care plan activity was entered in error and voided.
609         */
610        ENTEREDINERROR, 
611        /**
612         * added to help the parsers with the generic types
613         */
614        NULL;
615        public static CarePlanActivityStatus fromCode(String codeString) throws FHIRException {
616            if (codeString == null || "".equals(codeString))
617                return null;
618        if ("not-started".equals(codeString))
619          return NOTSTARTED;
620        if ("scheduled".equals(codeString))
621          return SCHEDULED;
622        if ("in-progress".equals(codeString))
623          return INPROGRESS;
624        if ("on-hold".equals(codeString))
625          return ONHOLD;
626        if ("completed".equals(codeString))
627          return COMPLETED;
628        if ("cancelled".equals(codeString))
629          return CANCELLED;
630        if ("stopped".equals(codeString))
631          return STOPPED;
632        if ("unknown".equals(codeString))
633          return UNKNOWN;
634        if ("entered-in-error".equals(codeString))
635          return ENTEREDINERROR;
636        if (Configuration.isAcceptInvalidEnums())
637          return null;
638        else
639          throw new FHIRException("Unknown CarePlanActivityStatus code '"+codeString+"'");
640        }
641        public String toCode() {
642          switch (this) {
643            case NOTSTARTED: return "not-started";
644            case SCHEDULED: return "scheduled";
645            case INPROGRESS: return "in-progress";
646            case ONHOLD: return "on-hold";
647            case COMPLETED: return "completed";
648            case CANCELLED: return "cancelled";
649            case STOPPED: return "stopped";
650            case UNKNOWN: return "unknown";
651            case ENTEREDINERROR: return "entered-in-error";
652            default: return "?";
653          }
654        }
655        public String getSystem() {
656          switch (this) {
657            case NOTSTARTED: return "http://hl7.org/fhir/care-plan-activity-status";
658            case SCHEDULED: return "http://hl7.org/fhir/care-plan-activity-status";
659            case INPROGRESS: return "http://hl7.org/fhir/care-plan-activity-status";
660            case ONHOLD: return "http://hl7.org/fhir/care-plan-activity-status";
661            case COMPLETED: return "http://hl7.org/fhir/care-plan-activity-status";
662            case CANCELLED: return "http://hl7.org/fhir/care-plan-activity-status";
663            case STOPPED: return "http://hl7.org/fhir/care-plan-activity-status";
664            case UNKNOWN: return "http://hl7.org/fhir/care-plan-activity-status";
665            case ENTEREDINERROR: return "http://hl7.org/fhir/care-plan-activity-status";
666            default: return "?";
667          }
668        }
669        public String getDefinition() {
670          switch (this) {
671            case NOTSTARTED: return "Care plan activity is planned but no action has yet been taken.";
672            case SCHEDULED: return "Appointment or other booking has occurred but activity has not yet begun.";
673            case INPROGRESS: return "Care plan activity has been started but is not yet complete.";
674            case ONHOLD: return "Care plan activity was started but has temporarily ceased with an expectation of resumption at a future time.";
675            case COMPLETED: return "Care plan activity has been completed (more or less) as planned.";
676            case CANCELLED: return "The planned care plan activity has been withdrawn.";
677            case STOPPED: return "The planned care plan activity has been ended prior to completion after the activity was started.";
678            case UNKNOWN: return "The current state of the care plan activity is not known.  Note: This concept is not to be used for \"other\" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which one.";
679            case ENTEREDINERROR: return "Care plan activity was entered in error and voided.";
680            default: return "?";
681          }
682        }
683        public String getDisplay() {
684          switch (this) {
685            case NOTSTARTED: return "Not Started";
686            case SCHEDULED: return "Scheduled";
687            case INPROGRESS: return "In Progress";
688            case ONHOLD: return "On Hold";
689            case COMPLETED: return "Completed";
690            case CANCELLED: return "Cancelled";
691            case STOPPED: return "Stopped";
692            case UNKNOWN: return "Unknown";
693            case ENTEREDINERROR: return "Entered in Error";
694            default: return "?";
695          }
696        }
697    }
698
699  public static class CarePlanActivityStatusEnumFactory implements EnumFactory<CarePlanActivityStatus> {
700    public CarePlanActivityStatus fromCode(String codeString) throws IllegalArgumentException {
701      if (codeString == null || "".equals(codeString))
702            if (codeString == null || "".equals(codeString))
703                return null;
704        if ("not-started".equals(codeString))
705          return CarePlanActivityStatus.NOTSTARTED;
706        if ("scheduled".equals(codeString))
707          return CarePlanActivityStatus.SCHEDULED;
708        if ("in-progress".equals(codeString))
709          return CarePlanActivityStatus.INPROGRESS;
710        if ("on-hold".equals(codeString))
711          return CarePlanActivityStatus.ONHOLD;
712        if ("completed".equals(codeString))
713          return CarePlanActivityStatus.COMPLETED;
714        if ("cancelled".equals(codeString))
715          return CarePlanActivityStatus.CANCELLED;
716        if ("stopped".equals(codeString))
717          return CarePlanActivityStatus.STOPPED;
718        if ("unknown".equals(codeString))
719          return CarePlanActivityStatus.UNKNOWN;
720        if ("entered-in-error".equals(codeString))
721          return CarePlanActivityStatus.ENTEREDINERROR;
722        throw new IllegalArgumentException("Unknown CarePlanActivityStatus code '"+codeString+"'");
723        }
724        public Enumeration<CarePlanActivityStatus> fromType(Base code) throws FHIRException {
725          if (code == null)
726            return null;
727          if (code.isEmpty())
728            return new Enumeration<CarePlanActivityStatus>(this);
729          String codeString = ((PrimitiveType) code).asStringValue();
730          if (codeString == null || "".equals(codeString))
731            return null;
732        if ("not-started".equals(codeString))
733          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.NOTSTARTED);
734        if ("scheduled".equals(codeString))
735          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.SCHEDULED);
736        if ("in-progress".equals(codeString))
737          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.INPROGRESS);
738        if ("on-hold".equals(codeString))
739          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.ONHOLD);
740        if ("completed".equals(codeString))
741          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.COMPLETED);
742        if ("cancelled".equals(codeString))
743          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.CANCELLED);
744        if ("stopped".equals(codeString))
745          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.STOPPED);
746        if ("unknown".equals(codeString))
747          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.UNKNOWN);
748        if ("entered-in-error".equals(codeString))
749          return new Enumeration<CarePlanActivityStatus>(this, CarePlanActivityStatus.ENTEREDINERROR);
750        throw new FHIRException("Unknown CarePlanActivityStatus code '"+codeString+"'");
751        }
752    public String toCode(CarePlanActivityStatus code) {
753      if (code == CarePlanActivityStatus.NOTSTARTED)
754        return "not-started";
755      if (code == CarePlanActivityStatus.SCHEDULED)
756        return "scheduled";
757      if (code == CarePlanActivityStatus.INPROGRESS)
758        return "in-progress";
759      if (code == CarePlanActivityStatus.ONHOLD)
760        return "on-hold";
761      if (code == CarePlanActivityStatus.COMPLETED)
762        return "completed";
763      if (code == CarePlanActivityStatus.CANCELLED)
764        return "cancelled";
765      if (code == CarePlanActivityStatus.STOPPED)
766        return "stopped";
767      if (code == CarePlanActivityStatus.UNKNOWN)
768        return "unknown";
769      if (code == CarePlanActivityStatus.ENTEREDINERROR)
770        return "entered-in-error";
771      return "?";
772      }
773    public String toSystem(CarePlanActivityStatus code) {
774      return code.getSystem();
775      }
776    }
777
778    @Block()
779    public static class CarePlanActivityComponent extends BackboneElement implements IBaseBackboneElement {
780        /**
781         * Identifies the outcome at the point when the status of the activity is assessed.  For example, the outcome of an education activity could be patient understands (or not).
782         */
783        @Child(name = "outcomeCodeableConcept", type = {CodeableConcept.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
784        @Description(shortDefinition="Results of the activity", formalDefinition="Identifies the outcome at the point when the status of the activity is assessed.  For example, the outcome of an education activity could be patient understands (or not)." )
785        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-activity-outcome")
786        protected List<CodeableConcept> outcomeCodeableConcept;
787
788        /**
789         * Details of the outcome or action resulting from the activity.  The reference to an "event" resource, such as Procedure or Encounter or Observation, is the result/outcome of the activity itself.  The activity can be conveyed using CarePlan.activity.detail OR using the CarePlan.activity.reference (a reference to a “request” resource).
790         */
791        @Child(name = "outcomeReference", type = {Reference.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
792        @Description(shortDefinition="Appointment, Encounter, Procedure, etc.", formalDefinition="Details of the outcome or action resulting from the activity.  The reference to an \"event\" resource, such as Procedure or Encounter or Observation, is the result/outcome of the activity itself.  The activity can be conveyed using CarePlan.activity.detail OR using the CarePlan.activity.reference (a reference to a “request” resource)." )
793        protected List<Reference> outcomeReference;
794
795        /**
796         * Notes about the adherence/status/progress of the activity.
797         */
798        @Child(name = "progress", type = {Annotation.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
799        @Description(shortDefinition="Comments about the activity status/progress", formalDefinition="Notes about the adherence/status/progress of the activity." )
800        protected List<Annotation> progress;
801
802        /**
803         * The details of the proposed activity represented in a specific resource.
804         */
805        @Child(name = "reference", type = {Appointment.class, CommunicationRequest.class, DeviceRequest.class, MedicationRequest.class, NutritionOrder.class, Task.class, ServiceRequest.class, VisionPrescription.class, RequestGroup.class, ImmunizationRecommendation.class}, order=4, min=0, max=1, modifier=false, summary=false)
806        @Description(shortDefinition="Activity details defined in specific resource", formalDefinition="The details of the proposed activity represented in a specific resource." )
807        protected Reference reference;
808
809        /**
810         * 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.
811         */
812        @Child(name = "detail", type = {}, order=5, min=0, max=1, modifier=false, summary=false)
813        @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." )
814        protected CarePlanActivityDetailComponent detail;
815
816        private static final long serialVersionUID = -1499292662L;
817
818    /**
819     * Constructor
820     */
821      public CarePlanActivityComponent() {
822        super();
823      }
824
825        /**
826         * @return {@link #outcomeCodeableConcept} (Identifies the outcome at the point when the status of the activity is assessed.  For example, the outcome of an education activity could be patient understands (or not).)
827         */
828        public List<CodeableConcept> getOutcomeCodeableConcept() { 
829          if (this.outcomeCodeableConcept == null)
830            this.outcomeCodeableConcept = new ArrayList<CodeableConcept>();
831          return this.outcomeCodeableConcept;
832        }
833
834        /**
835         * @return Returns a reference to <code>this</code> for easy method chaining
836         */
837        public CarePlanActivityComponent setOutcomeCodeableConcept(List<CodeableConcept> theOutcomeCodeableConcept) { 
838          this.outcomeCodeableConcept = theOutcomeCodeableConcept;
839          return this;
840        }
841
842        public boolean hasOutcomeCodeableConcept() { 
843          if (this.outcomeCodeableConcept == null)
844            return false;
845          for (CodeableConcept item : this.outcomeCodeableConcept)
846            if (!item.isEmpty())
847              return true;
848          return false;
849        }
850
851        public CodeableConcept addOutcomeCodeableConcept() { //3
852          CodeableConcept t = new CodeableConcept();
853          if (this.outcomeCodeableConcept == null)
854            this.outcomeCodeableConcept = new ArrayList<CodeableConcept>();
855          this.outcomeCodeableConcept.add(t);
856          return t;
857        }
858
859        public CarePlanActivityComponent addOutcomeCodeableConcept(CodeableConcept t) { //3
860          if (t == null)
861            return this;
862          if (this.outcomeCodeableConcept == null)
863            this.outcomeCodeableConcept = new ArrayList<CodeableConcept>();
864          this.outcomeCodeableConcept.add(t);
865          return this;
866        }
867
868        /**
869         * @return The first repetition of repeating field {@link #outcomeCodeableConcept}, creating it if it does not already exist
870         */
871        public CodeableConcept getOutcomeCodeableConceptFirstRep() { 
872          if (getOutcomeCodeableConcept().isEmpty()) {
873            addOutcomeCodeableConcept();
874          }
875          return getOutcomeCodeableConcept().get(0);
876        }
877
878        /**
879         * @return {@link #outcomeReference} (Details of the outcome or action resulting from the activity.  The reference to an "event" resource, such as Procedure or Encounter or Observation, is the result/outcome of the activity itself.  The activity can be conveyed using CarePlan.activity.detail OR using the CarePlan.activity.reference (a reference to a “request” resource).)
880         */
881        public List<Reference> getOutcomeReference() { 
882          if (this.outcomeReference == null)
883            this.outcomeReference = new ArrayList<Reference>();
884          return this.outcomeReference;
885        }
886
887        /**
888         * @return Returns a reference to <code>this</code> for easy method chaining
889         */
890        public CarePlanActivityComponent setOutcomeReference(List<Reference> theOutcomeReference) { 
891          this.outcomeReference = theOutcomeReference;
892          return this;
893        }
894
895        public boolean hasOutcomeReference() { 
896          if (this.outcomeReference == null)
897            return false;
898          for (Reference item : this.outcomeReference)
899            if (!item.isEmpty())
900              return true;
901          return false;
902        }
903
904        public Reference addOutcomeReference() { //3
905          Reference t = new Reference();
906          if (this.outcomeReference == null)
907            this.outcomeReference = new ArrayList<Reference>();
908          this.outcomeReference.add(t);
909          return t;
910        }
911
912        public CarePlanActivityComponent addOutcomeReference(Reference t) { //3
913          if (t == null)
914            return this;
915          if (this.outcomeReference == null)
916            this.outcomeReference = new ArrayList<Reference>();
917          this.outcomeReference.add(t);
918          return this;
919        }
920
921        /**
922         * @return The first repetition of repeating field {@link #outcomeReference}, creating it if it does not already exist
923         */
924        public Reference getOutcomeReferenceFirstRep() { 
925          if (getOutcomeReference().isEmpty()) {
926            addOutcomeReference();
927          }
928          return getOutcomeReference().get(0);
929        }
930
931        /**
932         * @return {@link #progress} (Notes about the adherence/status/progress of the activity.)
933         */
934        public List<Annotation> getProgress() { 
935          if (this.progress == null)
936            this.progress = new ArrayList<Annotation>();
937          return this.progress;
938        }
939
940        /**
941         * @return Returns a reference to <code>this</code> for easy method chaining
942         */
943        public CarePlanActivityComponent setProgress(List<Annotation> theProgress) { 
944          this.progress = theProgress;
945          return this;
946        }
947
948        public boolean hasProgress() { 
949          if (this.progress == null)
950            return false;
951          for (Annotation item : this.progress)
952            if (!item.isEmpty())
953              return true;
954          return false;
955        }
956
957        public Annotation addProgress() { //3
958          Annotation t = new Annotation();
959          if (this.progress == null)
960            this.progress = new ArrayList<Annotation>();
961          this.progress.add(t);
962          return t;
963        }
964
965        public CarePlanActivityComponent addProgress(Annotation t) { //3
966          if (t == null)
967            return this;
968          if (this.progress == null)
969            this.progress = new ArrayList<Annotation>();
970          this.progress.add(t);
971          return this;
972        }
973
974        /**
975         * @return The first repetition of repeating field {@link #progress}, creating it if it does not already exist
976         */
977        public Annotation getProgressFirstRep() { 
978          if (getProgress().isEmpty()) {
979            addProgress();
980          }
981          return getProgress().get(0);
982        }
983
984        /**
985         * @return {@link #reference} (The details of the proposed activity represented in a specific resource.)
986         */
987        public Reference getReference() { 
988          if (this.reference == null)
989            if (Configuration.errorOnAutoCreate())
990              throw new Error("Attempt to auto-create CarePlanActivityComponent.reference");
991            else if (Configuration.doAutoCreate())
992              this.reference = new Reference(); // cc
993          return this.reference;
994        }
995
996        public boolean hasReference() { 
997          return this.reference != null && !this.reference.isEmpty();
998        }
999
1000        /**
1001         * @param value {@link #reference} (The details of the proposed activity represented in a specific resource.)
1002         */
1003        public CarePlanActivityComponent setReference(Reference value) { 
1004          this.reference = value;
1005          return this;
1006        }
1007
1008        /**
1009         * @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.)
1010         */
1011        public CarePlanActivityDetailComponent getDetail() { 
1012          if (this.detail == null)
1013            if (Configuration.errorOnAutoCreate())
1014              throw new Error("Attempt to auto-create CarePlanActivityComponent.detail");
1015            else if (Configuration.doAutoCreate())
1016              this.detail = new CarePlanActivityDetailComponent(); // cc
1017          return this.detail;
1018        }
1019
1020        public boolean hasDetail() { 
1021          return this.detail != null && !this.detail.isEmpty();
1022        }
1023
1024        /**
1025         * @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.)
1026         */
1027        public CarePlanActivityComponent setDetail(CarePlanActivityDetailComponent value) { 
1028          this.detail = value;
1029          return this;
1030        }
1031
1032        protected void listChildren(List<Property> children) {
1033          super.listChildren(children);
1034          children.add(new Property("outcomeCodeableConcept", "CodeableConcept", "Identifies the outcome at the point when the status of the activity is assessed.  For example, the outcome of an education activity could be patient understands (or not).", 0, java.lang.Integer.MAX_VALUE, outcomeCodeableConcept));
1035          children.add(new Property("outcomeReference", "Reference(Any)", "Details of the outcome or action resulting from the activity.  The reference to an \"event\" resource, such as Procedure or Encounter or Observation, is the result/outcome of the activity itself.  The activity can be conveyed using CarePlan.activity.detail OR using the CarePlan.activity.reference (a reference to a “request” resource).", 0, java.lang.Integer.MAX_VALUE, outcomeReference));
1036          children.add(new Property("progress", "Annotation", "Notes about the adherence/status/progress of the activity.", 0, java.lang.Integer.MAX_VALUE, progress));
1037          children.add(new Property("reference", "Reference(Appointment|CommunicationRequest|DeviceRequest|MedicationRequest|NutritionOrder|Task|ServiceRequest|VisionPrescription|RequestGroup|ImmunizationRecommendation)", "The details of the proposed activity represented in a specific resource.", 0, 1, reference));
1038          children.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, 1, detail));
1039        }
1040
1041        @Override
1042        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
1043          switch (_hash) {
1044          case -511913489: /*outcomeCodeableConcept*/  return new Property("outcomeCodeableConcept", "CodeableConcept", "Identifies the outcome at the point when the status of the activity is assessed.  For example, the outcome of an education activity could be patient understands (or not).", 0, java.lang.Integer.MAX_VALUE, outcomeCodeableConcept);
1045          case -782273511: /*outcomeReference*/  return new Property("outcomeReference", "Reference(Any)", "Details of the outcome or action resulting from the activity.  The reference to an \"event\" resource, such as Procedure or Encounter or Observation, is the result/outcome of the activity itself.  The activity can be conveyed using CarePlan.activity.detail OR using the CarePlan.activity.reference (a reference to a “request” resource).", 0, java.lang.Integer.MAX_VALUE, outcomeReference);
1046          case -1001078227: /*progress*/  return new Property("progress", "Annotation", "Notes about the adherence/status/progress of the activity.", 0, java.lang.Integer.MAX_VALUE, progress);
1047          case -925155509: /*reference*/  return new Property("reference", "Reference(Appointment|CommunicationRequest|DeviceRequest|MedicationRequest|NutritionOrder|Task|ServiceRequest|VisionPrescription|RequestGroup|ImmunizationRecommendation)", "The details of the proposed activity represented in a specific resource.", 0, 1, reference);
1048          case -1335224239: /*detail*/  return 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, 1, detail);
1049          default: return super.getNamedProperty(_hash, _name, _checkValid);
1050          }
1051
1052        }
1053
1054      @Override
1055      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
1056        switch (hash) {
1057        case -511913489: /*outcomeCodeableConcept*/ return this.outcomeCodeableConcept == null ? new Base[0] : this.outcomeCodeableConcept.toArray(new Base[this.outcomeCodeableConcept.size()]); // CodeableConcept
1058        case -782273511: /*outcomeReference*/ return this.outcomeReference == null ? new Base[0] : this.outcomeReference.toArray(new Base[this.outcomeReference.size()]); // Reference
1059        case -1001078227: /*progress*/ return this.progress == null ? new Base[0] : this.progress.toArray(new Base[this.progress.size()]); // Annotation
1060        case -925155509: /*reference*/ return this.reference == null ? new Base[0] : new Base[] {this.reference}; // Reference
1061        case -1335224239: /*detail*/ return this.detail == null ? new Base[0] : new Base[] {this.detail}; // CarePlanActivityDetailComponent
1062        default: return super.getProperty(hash, name, checkValid);
1063        }
1064
1065      }
1066
1067      @Override
1068      public Base setProperty(int hash, String name, Base value) throws FHIRException {
1069        switch (hash) {
1070        case -511913489: // outcomeCodeableConcept
1071          this.getOutcomeCodeableConcept().add(castToCodeableConcept(value)); // CodeableConcept
1072          return value;
1073        case -782273511: // outcomeReference
1074          this.getOutcomeReference().add(castToReference(value)); // Reference
1075          return value;
1076        case -1001078227: // progress
1077          this.getProgress().add(castToAnnotation(value)); // Annotation
1078          return value;
1079        case -925155509: // reference
1080          this.reference = castToReference(value); // Reference
1081          return value;
1082        case -1335224239: // detail
1083          this.detail = (CarePlanActivityDetailComponent) value; // CarePlanActivityDetailComponent
1084          return value;
1085        default: return super.setProperty(hash, name, value);
1086        }
1087
1088      }
1089
1090      @Override
1091      public Base setProperty(String name, Base value) throws FHIRException {
1092        if (name.equals("outcomeCodeableConcept")) {
1093          this.getOutcomeCodeableConcept().add(castToCodeableConcept(value));
1094        } else if (name.equals("outcomeReference")) {
1095          this.getOutcomeReference().add(castToReference(value));
1096        } else if (name.equals("progress")) {
1097          this.getProgress().add(castToAnnotation(value));
1098        } else if (name.equals("reference")) {
1099          this.reference = castToReference(value); // Reference
1100        } else if (name.equals("detail")) {
1101          this.detail = (CarePlanActivityDetailComponent) value; // CarePlanActivityDetailComponent
1102        } else
1103          return super.setProperty(name, value);
1104        return value;
1105      }
1106
1107      @Override
1108      public Base makeProperty(int hash, String name) throws FHIRException {
1109        switch (hash) {
1110        case -511913489:  return addOutcomeCodeableConcept(); 
1111        case -782273511:  return addOutcomeReference(); 
1112        case -1001078227:  return addProgress(); 
1113        case -925155509:  return getReference();
1114        case -1335224239:  return getDetail();
1115        default: return super.makeProperty(hash, name);
1116        }
1117
1118      }
1119
1120      @Override
1121      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
1122        switch (hash) {
1123        case -511913489: /*outcomeCodeableConcept*/ return new String[] {"CodeableConcept"};
1124        case -782273511: /*outcomeReference*/ return new String[] {"Reference"};
1125        case -1001078227: /*progress*/ return new String[] {"Annotation"};
1126        case -925155509: /*reference*/ return new String[] {"Reference"};
1127        case -1335224239: /*detail*/ return new String[] {};
1128        default: return super.getTypesForProperty(hash, name);
1129        }
1130
1131      }
1132
1133      @Override
1134      public Base addChild(String name) throws FHIRException {
1135        if (name.equals("outcomeCodeableConcept")) {
1136          return addOutcomeCodeableConcept();
1137        }
1138        else if (name.equals("outcomeReference")) {
1139          return addOutcomeReference();
1140        }
1141        else if (name.equals("progress")) {
1142          return addProgress();
1143        }
1144        else if (name.equals("reference")) {
1145          this.reference = new Reference();
1146          return this.reference;
1147        }
1148        else if (name.equals("detail")) {
1149          this.detail = new CarePlanActivityDetailComponent();
1150          return this.detail;
1151        }
1152        else
1153          return super.addChild(name);
1154      }
1155
1156      public CarePlanActivityComponent copy() {
1157        CarePlanActivityComponent dst = new CarePlanActivityComponent();
1158        copyValues(dst);
1159        return dst;
1160      }
1161
1162      public void copyValues(CarePlanActivityComponent dst) {
1163        super.copyValues(dst);
1164        if (outcomeCodeableConcept != null) {
1165          dst.outcomeCodeableConcept = new ArrayList<CodeableConcept>();
1166          for (CodeableConcept i : outcomeCodeableConcept)
1167            dst.outcomeCodeableConcept.add(i.copy());
1168        };
1169        if (outcomeReference != null) {
1170          dst.outcomeReference = new ArrayList<Reference>();
1171          for (Reference i : outcomeReference)
1172            dst.outcomeReference.add(i.copy());
1173        };
1174        if (progress != null) {
1175          dst.progress = new ArrayList<Annotation>();
1176          for (Annotation i : progress)
1177            dst.progress.add(i.copy());
1178        };
1179        dst.reference = reference == null ? null : reference.copy();
1180        dst.detail = detail == null ? null : detail.copy();
1181      }
1182
1183      @Override
1184      public boolean equalsDeep(Base other_) {
1185        if (!super.equalsDeep(other_))
1186          return false;
1187        if (!(other_ instanceof CarePlanActivityComponent))
1188          return false;
1189        CarePlanActivityComponent o = (CarePlanActivityComponent) other_;
1190        return compareDeep(outcomeCodeableConcept, o.outcomeCodeableConcept, true) && compareDeep(outcomeReference, o.outcomeReference, true)
1191           && compareDeep(progress, o.progress, true) && compareDeep(reference, o.reference, true) && compareDeep(detail, o.detail, true)
1192          ;
1193      }
1194
1195      @Override
1196      public boolean equalsShallow(Base other_) {
1197        if (!super.equalsShallow(other_))
1198          return false;
1199        if (!(other_ instanceof CarePlanActivityComponent))
1200          return false;
1201        CarePlanActivityComponent o = (CarePlanActivityComponent) other_;
1202        return true;
1203      }
1204
1205      public boolean isEmpty() {
1206        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(outcomeCodeableConcept, outcomeReference
1207          , progress, reference, detail);
1208      }
1209
1210  public String fhirType() {
1211    return "CarePlan.activity";
1212
1213  }
1214
1215  }
1216
1217    @Block()
1218    public static class CarePlanActivityDetailComponent extends BackboneElement implements IBaseBackboneElement {
1219        /**
1220         * A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.
1221         */
1222        @Child(name = "kind", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=false)
1223        @Description(shortDefinition="Appointment | CommunicationRequest | DeviceRequest | MedicationRequest | NutritionOrder | Task | ServiceRequest | VisionPrescription", formalDefinition="A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest." )
1224        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-activity-kind")
1225        protected Enumeration<CarePlanActivityKind> kind;
1226
1227        /**
1228         * The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.
1229         */
1230        @Child(name = "instantiatesCanonical", type = {CanonicalType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1231        @Description(shortDefinition="Instantiates FHIR protocol or definition", formalDefinition="The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity." )
1232        protected List<CanonicalType> instantiatesCanonical;
1233
1234        /**
1235         * The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.
1236         */
1237        @Child(name = "instantiatesUri", type = {UriType.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1238        @Description(shortDefinition="Instantiates external protocol or definition", formalDefinition="The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity." )
1239        protected List<UriType> instantiatesUri;
1240
1241        /**
1242         * Detailed description of the type of planned activity; e.g. what lab test, what procedure, what kind of encounter.
1243         */
1244        @Child(name = "code", type = {CodeableConcept.class}, order=4, min=0, max=1, modifier=false, summary=false)
1245        @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." )
1246        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/procedure-code")
1247        protected CodeableConcept code;
1248
1249        /**
1250         * Provides the rationale that drove the inclusion of this particular activity as part of the plan or the reason why the activity was prohibited.
1251         */
1252        @Child(name = "reasonCode", type = {CodeableConcept.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1253        @Description(shortDefinition="Why activity should be done or why activity was prohibited", formalDefinition="Provides the rationale that drove the inclusion of this particular activity as part of the plan or the reason why the activity was prohibited." )
1254        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
1255        protected List<CodeableConcept> reasonCode;
1256
1257        /**
1258         * Indicates another resource, such as the health condition(s), whose existence justifies this request and drove the inclusion of this particular activity as part of the plan.
1259         */
1260        @Child(name = "reasonReference", type = {Condition.class, Observation.class, DiagnosticReport.class, DocumentReference.class}, order=6, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1261        @Description(shortDefinition="Why activity is needed", formalDefinition="Indicates another resource, such as the health condition(s), whose existence justifies this request and drove the inclusion of this particular activity as part of the plan." )
1262        protected List<Reference> reasonReference;
1263
1264        /**
1265         * Internal reference that identifies the goals that this activity is intended to contribute towards meeting.
1266         */
1267        @Child(name = "goal", type = {Goal.class}, order=7, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1268        @Description(shortDefinition="Goals this activity relates to", formalDefinition="Internal reference that identifies the goals that this activity is intended to contribute towards meeting." )
1269        protected List<Reference> goal;
1270
1271        /**
1272         * Identifies what progress is being made for the specific activity.
1273         */
1274        @Child(name = "status", type = {CodeType.class}, order=8, min=1, max=1, modifier=true, summary=false)
1275        @Description(shortDefinition="not-started | scheduled | in-progress | on-hold | completed | cancelled | stopped | unknown | entered-in-error", formalDefinition="Identifies what progress is being made for the specific activity." )
1276        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-activity-status")
1277        protected Enumeration<CarePlanActivityStatus> status;
1278
1279        /**
1280         * Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.
1281         */
1282        @Child(name = "statusReason", type = {CodeableConcept.class}, order=9, min=0, max=1, modifier=false, summary=false)
1283        @Description(shortDefinition="Reason for current status", formalDefinition="Provides reason why the activity isn't yet started, is on hold, was cancelled, etc." )
1284        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-activity-status-reason")
1285        protected CodeableConcept statusReason;
1286
1287        /**
1288         * If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.
1289         */
1290        @Child(name = "doNotPerform", type = {BooleanType.class}, order=10, min=0, max=1, modifier=true, summary=false)
1291        @Description(shortDefinition="If true, activity is prohibiting action", formalDefinition="If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan." )
1292        protected BooleanType doNotPerform;
1293
1294        /**
1295         * The period, timing or frequency upon which the described activity is to occur.
1296         */
1297        @Child(name = "scheduled", type = {Timing.class, Period.class, StringType.class}, order=11, min=0, max=1, modifier=false, summary=false)
1298        @Description(shortDefinition="When activity is to occur", formalDefinition="The period, timing or frequency upon which the described activity is to occur." )
1299        protected Type scheduled;
1300
1301        /**
1302         * Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.
1303         */
1304        @Child(name = "location", type = {Location.class}, order=12, min=0, max=1, modifier=false, summary=false)
1305        @Description(shortDefinition="Where it should happen", formalDefinition="Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc." )
1306        protected Reference location;
1307
1308        /**
1309         * Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.
1310         */
1311        @Child(name = "reported", type = {BooleanType.class, Patient.class, RelatedPerson.class, Practitioner.class, PractitionerRole.class, Organization.class}, order=13, min=0, max=1, modifier=false, summary=false)
1312        @Description(shortDefinition="Reported rather than primary record", formalDefinition="Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report." )
1313        protected Type reported;
1314
1315        /**
1316         * Identifies who's expected to be involved in the activity.
1317         */
1318        @Child(name = "performer", type = {Practitioner.class, PractitionerRole.class, Organization.class, RelatedPerson.class, Patient.class, CareTeam.class, HealthcareService.class, Device.class}, order=14, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
1319        @Description(shortDefinition="Who will be responsible?", formalDefinition="Identifies who's expected to be involved in the activity." )
1320        protected List<Reference> performer;
1321
1322        /**
1323         * Identifies the food, drug or other product to be consumed or supplied in the activity.
1324         */
1325        @Child(name = "product", type = {CodeableConcept.class, Medication.class, Substance.class}, order=15, min=0, max=1, modifier=false, summary=false)
1326        @Description(shortDefinition="What is to be administered/supplied", formalDefinition="Identifies the food, drug or other product to be consumed or supplied in the activity." )
1327        @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/medication-codes")
1328        protected Type product;
1329
1330        /**
1331         * Identifies the quantity expected to be consumed in a given day.
1332         */
1333        @Child(name = "dailyAmount", type = {Quantity.class}, order=16, min=0, max=1, modifier=false, summary=false)
1334        @Description(shortDefinition="How to consume/day?", formalDefinition="Identifies the quantity expected to be consumed in a given day." )
1335        protected Quantity dailyAmount;
1336
1337        /**
1338         * Identifies the quantity expected to be supplied, administered or consumed by the subject.
1339         */
1340        @Child(name = "quantity", type = {Quantity.class}, order=17, min=0, max=1, modifier=false, summary=false)
1341        @Description(shortDefinition="How much to administer/supply/consume", formalDefinition="Identifies the quantity expected to be supplied, administered or consumed by the subject." )
1342        protected Quantity quantity;
1343
1344        /**
1345         * 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.
1346         */
1347        @Child(name = "description", type = {StringType.class}, order=18, min=0, max=1, modifier=false, summary=false)
1348        @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." )
1349        protected StringType description;
1350
1351        private static final long serialVersionUID = -177703989L;
1352
1353    /**
1354     * Constructor
1355     */
1356      public CarePlanActivityDetailComponent() {
1357        super();
1358      }
1359
1360    /**
1361     * Constructor
1362     */
1363      public CarePlanActivityDetailComponent(Enumeration<CarePlanActivityStatus> status) {
1364        super();
1365        this.status = status;
1366      }
1367
1368        /**
1369         * @return {@link #kind} (A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
1370         */
1371        public Enumeration<CarePlanActivityKind> getKindElement() { 
1372          if (this.kind == null)
1373            if (Configuration.errorOnAutoCreate())
1374              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.kind");
1375            else if (Configuration.doAutoCreate())
1376              this.kind = new Enumeration<CarePlanActivityKind>(new CarePlanActivityKindEnumFactory()); // bb
1377          return this.kind;
1378        }
1379
1380        public boolean hasKindElement() { 
1381          return this.kind != null && !this.kind.isEmpty();
1382        }
1383
1384        public boolean hasKind() { 
1385          return this.kind != null && !this.kind.isEmpty();
1386        }
1387
1388        /**
1389         * @param value {@link #kind} (A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.). This is the underlying object with id, value and extensions. The accessor "getKind" gives direct access to the value
1390         */
1391        public CarePlanActivityDetailComponent setKindElement(Enumeration<CarePlanActivityKind> value) { 
1392          this.kind = value;
1393          return this;
1394        }
1395
1396        /**
1397         * @return A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.
1398         */
1399        public CarePlanActivityKind getKind() { 
1400          return this.kind == null ? null : this.kind.getValue();
1401        }
1402
1403        /**
1404         * @param value A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.
1405         */
1406        public CarePlanActivityDetailComponent setKind(CarePlanActivityKind value) { 
1407          if (value == null)
1408            this.kind = null;
1409          else {
1410            if (this.kind == null)
1411              this.kind = new Enumeration<CarePlanActivityKind>(new CarePlanActivityKindEnumFactory());
1412            this.kind.setValue(value);
1413          }
1414          return this;
1415        }
1416
1417        /**
1418         * @return {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1419         */
1420        public List<CanonicalType> getInstantiatesCanonical() { 
1421          if (this.instantiatesCanonical == null)
1422            this.instantiatesCanonical = new ArrayList<CanonicalType>();
1423          return this.instantiatesCanonical;
1424        }
1425
1426        /**
1427         * @return Returns a reference to <code>this</code> for easy method chaining
1428         */
1429        public CarePlanActivityDetailComponent setInstantiatesCanonical(List<CanonicalType> theInstantiatesCanonical) { 
1430          this.instantiatesCanonical = theInstantiatesCanonical;
1431          return this;
1432        }
1433
1434        public boolean hasInstantiatesCanonical() { 
1435          if (this.instantiatesCanonical == null)
1436            return false;
1437          for (CanonicalType item : this.instantiatesCanonical)
1438            if (!item.isEmpty())
1439              return true;
1440          return false;
1441        }
1442
1443        /**
1444         * @return {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1445         */
1446        public CanonicalType addInstantiatesCanonicalElement() {//2 
1447          CanonicalType t = new CanonicalType();
1448          if (this.instantiatesCanonical == null)
1449            this.instantiatesCanonical = new ArrayList<CanonicalType>();
1450          this.instantiatesCanonical.add(t);
1451          return t;
1452        }
1453
1454        /**
1455         * @param value {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1456         */
1457        public CarePlanActivityDetailComponent addInstantiatesCanonical(String value) { //1
1458          CanonicalType t = new CanonicalType();
1459          t.setValue(value);
1460          if (this.instantiatesCanonical == null)
1461            this.instantiatesCanonical = new ArrayList<CanonicalType>();
1462          this.instantiatesCanonical.add(t);
1463          return this;
1464        }
1465
1466        /**
1467         * @param value {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1468         */
1469        public boolean hasInstantiatesCanonical(String value) { 
1470          if (this.instantiatesCanonical == null)
1471            return false;
1472          for (CanonicalType v : this.instantiatesCanonical)
1473            if (v.getValue().equals(value)) // canonical(PlanDefinition|ActivityDefinition|Questionnaire|Measure|OperationDefinition)
1474              return true;
1475          return false;
1476        }
1477
1478        /**
1479         * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1480         */
1481        public List<UriType> getInstantiatesUri() { 
1482          if (this.instantiatesUri == null)
1483            this.instantiatesUri = new ArrayList<UriType>();
1484          return this.instantiatesUri;
1485        }
1486
1487        /**
1488         * @return Returns a reference to <code>this</code> for easy method chaining
1489         */
1490        public CarePlanActivityDetailComponent setInstantiatesUri(List<UriType> theInstantiatesUri) { 
1491          this.instantiatesUri = theInstantiatesUri;
1492          return this;
1493        }
1494
1495        public boolean hasInstantiatesUri() { 
1496          if (this.instantiatesUri == null)
1497            return false;
1498          for (UriType item : this.instantiatesUri)
1499            if (!item.isEmpty())
1500              return true;
1501          return false;
1502        }
1503
1504        /**
1505         * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1506         */
1507        public UriType addInstantiatesUriElement() {//2 
1508          UriType t = new UriType();
1509          if (this.instantiatesUri == null)
1510            this.instantiatesUri = new ArrayList<UriType>();
1511          this.instantiatesUri.add(t);
1512          return t;
1513        }
1514
1515        /**
1516         * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1517         */
1518        public CarePlanActivityDetailComponent addInstantiatesUri(String value) { //1
1519          UriType t = new UriType();
1520          t.setValue(value);
1521          if (this.instantiatesUri == null)
1522            this.instantiatesUri = new ArrayList<UriType>();
1523          this.instantiatesUri.add(t);
1524          return this;
1525        }
1526
1527        /**
1528         * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.)
1529         */
1530        public boolean hasInstantiatesUri(String value) { 
1531          if (this.instantiatesUri == null)
1532            return false;
1533          for (UriType v : this.instantiatesUri)
1534            if (v.getValue().equals(value)) // uri
1535              return true;
1536          return false;
1537        }
1538
1539        /**
1540         * @return {@link #code} (Detailed description of the type of planned activity; e.g. what lab test, what procedure, what kind of encounter.)
1541         */
1542        public CodeableConcept getCode() { 
1543          if (this.code == null)
1544            if (Configuration.errorOnAutoCreate())
1545              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.code");
1546            else if (Configuration.doAutoCreate())
1547              this.code = new CodeableConcept(); // cc
1548          return this.code;
1549        }
1550
1551        public boolean hasCode() { 
1552          return this.code != null && !this.code.isEmpty();
1553        }
1554
1555        /**
1556         * @param value {@link #code} (Detailed description of the type of planned activity; e.g. what lab test, what procedure, what kind of encounter.)
1557         */
1558        public CarePlanActivityDetailComponent setCode(CodeableConcept value) { 
1559          this.code = value;
1560          return this;
1561        }
1562
1563        /**
1564         * @return {@link #reasonCode} (Provides the rationale that drove the inclusion of this particular activity as part of the plan or the reason why the activity was prohibited.)
1565         */
1566        public List<CodeableConcept> getReasonCode() { 
1567          if (this.reasonCode == null)
1568            this.reasonCode = new ArrayList<CodeableConcept>();
1569          return this.reasonCode;
1570        }
1571
1572        /**
1573         * @return Returns a reference to <code>this</code> for easy method chaining
1574         */
1575        public CarePlanActivityDetailComponent setReasonCode(List<CodeableConcept> theReasonCode) { 
1576          this.reasonCode = theReasonCode;
1577          return this;
1578        }
1579
1580        public boolean hasReasonCode() { 
1581          if (this.reasonCode == null)
1582            return false;
1583          for (CodeableConcept item : this.reasonCode)
1584            if (!item.isEmpty())
1585              return true;
1586          return false;
1587        }
1588
1589        public CodeableConcept addReasonCode() { //3
1590          CodeableConcept t = new CodeableConcept();
1591          if (this.reasonCode == null)
1592            this.reasonCode = new ArrayList<CodeableConcept>();
1593          this.reasonCode.add(t);
1594          return t;
1595        }
1596
1597        public CarePlanActivityDetailComponent addReasonCode(CodeableConcept t) { //3
1598          if (t == null)
1599            return this;
1600          if (this.reasonCode == null)
1601            this.reasonCode = new ArrayList<CodeableConcept>();
1602          this.reasonCode.add(t);
1603          return this;
1604        }
1605
1606        /**
1607         * @return The first repetition of repeating field {@link #reasonCode}, creating it if it does not already exist
1608         */
1609        public CodeableConcept getReasonCodeFirstRep() { 
1610          if (getReasonCode().isEmpty()) {
1611            addReasonCode();
1612          }
1613          return getReasonCode().get(0);
1614        }
1615
1616        /**
1617         * @return {@link #reasonReference} (Indicates another resource, such as the health condition(s), whose existence justifies this request and drove the inclusion of this particular activity as part of the plan.)
1618         */
1619        public List<Reference> getReasonReference() { 
1620          if (this.reasonReference == null)
1621            this.reasonReference = new ArrayList<Reference>();
1622          return this.reasonReference;
1623        }
1624
1625        /**
1626         * @return Returns a reference to <code>this</code> for easy method chaining
1627         */
1628        public CarePlanActivityDetailComponent setReasonReference(List<Reference> theReasonReference) { 
1629          this.reasonReference = theReasonReference;
1630          return this;
1631        }
1632
1633        public boolean hasReasonReference() { 
1634          if (this.reasonReference == null)
1635            return false;
1636          for (Reference item : this.reasonReference)
1637            if (!item.isEmpty())
1638              return true;
1639          return false;
1640        }
1641
1642        public Reference addReasonReference() { //3
1643          Reference t = new Reference();
1644          if (this.reasonReference == null)
1645            this.reasonReference = new ArrayList<Reference>();
1646          this.reasonReference.add(t);
1647          return t;
1648        }
1649
1650        public CarePlanActivityDetailComponent addReasonReference(Reference t) { //3
1651          if (t == null)
1652            return this;
1653          if (this.reasonReference == null)
1654            this.reasonReference = new ArrayList<Reference>();
1655          this.reasonReference.add(t);
1656          return this;
1657        }
1658
1659        /**
1660         * @return The first repetition of repeating field {@link #reasonReference}, creating it if it does not already exist
1661         */
1662        public Reference getReasonReferenceFirstRep() { 
1663          if (getReasonReference().isEmpty()) {
1664            addReasonReference();
1665          }
1666          return getReasonReference().get(0);
1667        }
1668
1669        /**
1670         * @return {@link #goal} (Internal reference that identifies the goals that this activity is intended to contribute towards meeting.)
1671         */
1672        public List<Reference> getGoal() { 
1673          if (this.goal == null)
1674            this.goal = new ArrayList<Reference>();
1675          return this.goal;
1676        }
1677
1678        /**
1679         * @return Returns a reference to <code>this</code> for easy method chaining
1680         */
1681        public CarePlanActivityDetailComponent setGoal(List<Reference> theGoal) { 
1682          this.goal = theGoal;
1683          return this;
1684        }
1685
1686        public boolean hasGoal() { 
1687          if (this.goal == null)
1688            return false;
1689          for (Reference item : this.goal)
1690            if (!item.isEmpty())
1691              return true;
1692          return false;
1693        }
1694
1695        public Reference addGoal() { //3
1696          Reference t = new Reference();
1697          if (this.goal == null)
1698            this.goal = new ArrayList<Reference>();
1699          this.goal.add(t);
1700          return t;
1701        }
1702
1703        public CarePlanActivityDetailComponent addGoal(Reference t) { //3
1704          if (t == null)
1705            return this;
1706          if (this.goal == null)
1707            this.goal = new ArrayList<Reference>();
1708          this.goal.add(t);
1709          return this;
1710        }
1711
1712        /**
1713         * @return The first repetition of repeating field {@link #goal}, creating it if it does not already exist
1714         */
1715        public Reference getGoalFirstRep() { 
1716          if (getGoal().isEmpty()) {
1717            addGoal();
1718          }
1719          return getGoal().get(0);
1720        }
1721
1722        /**
1723         * @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
1724         */
1725        public Enumeration<CarePlanActivityStatus> getStatusElement() { 
1726          if (this.status == null)
1727            if (Configuration.errorOnAutoCreate())
1728              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.status");
1729            else if (Configuration.doAutoCreate())
1730              this.status = new Enumeration<CarePlanActivityStatus>(new CarePlanActivityStatusEnumFactory()); // bb
1731          return this.status;
1732        }
1733
1734        public boolean hasStatusElement() { 
1735          return this.status != null && !this.status.isEmpty();
1736        }
1737
1738        public boolean hasStatus() { 
1739          return this.status != null && !this.status.isEmpty();
1740        }
1741
1742        /**
1743         * @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
1744         */
1745        public CarePlanActivityDetailComponent setStatusElement(Enumeration<CarePlanActivityStatus> value) { 
1746          this.status = value;
1747          return this;
1748        }
1749
1750        /**
1751         * @return Identifies what progress is being made for the specific activity.
1752         */
1753        public CarePlanActivityStatus getStatus() { 
1754          return this.status == null ? null : this.status.getValue();
1755        }
1756
1757        /**
1758         * @param value Identifies what progress is being made for the specific activity.
1759         */
1760        public CarePlanActivityDetailComponent setStatus(CarePlanActivityStatus value) { 
1761            if (this.status == null)
1762              this.status = new Enumeration<CarePlanActivityStatus>(new CarePlanActivityStatusEnumFactory());
1763            this.status.setValue(value);
1764          return this;
1765        }
1766
1767        /**
1768         * @return {@link #statusReason} (Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.)
1769         */
1770        public CodeableConcept getStatusReason() { 
1771          if (this.statusReason == null)
1772            if (Configuration.errorOnAutoCreate())
1773              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.statusReason");
1774            else if (Configuration.doAutoCreate())
1775              this.statusReason = new CodeableConcept(); // cc
1776          return this.statusReason;
1777        }
1778
1779        public boolean hasStatusReason() { 
1780          return this.statusReason != null && !this.statusReason.isEmpty();
1781        }
1782
1783        /**
1784         * @param value {@link #statusReason} (Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.)
1785         */
1786        public CarePlanActivityDetailComponent setStatusReason(CodeableConcept value) { 
1787          this.statusReason = value;
1788          return this;
1789        }
1790
1791        /**
1792         * @return {@link #doNotPerform} (If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1793         */
1794        public BooleanType getDoNotPerformElement() { 
1795          if (this.doNotPerform == null)
1796            if (Configuration.errorOnAutoCreate())
1797              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.doNotPerform");
1798            else if (Configuration.doAutoCreate())
1799              this.doNotPerform = new BooleanType(); // bb
1800          return this.doNotPerform;
1801        }
1802
1803        public boolean hasDoNotPerformElement() { 
1804          return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1805        }
1806
1807        public boolean hasDoNotPerform() { 
1808          return this.doNotPerform != null && !this.doNotPerform.isEmpty();
1809        }
1810
1811        /**
1812         * @param value {@link #doNotPerform} (If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.). This is the underlying object with id, value and extensions. The accessor "getDoNotPerform" gives direct access to the value
1813         */
1814        public CarePlanActivityDetailComponent setDoNotPerformElement(BooleanType value) { 
1815          this.doNotPerform = value;
1816          return this;
1817        }
1818
1819        /**
1820         * @return If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.
1821         */
1822        public boolean getDoNotPerform() { 
1823          return this.doNotPerform == null || this.doNotPerform.isEmpty() ? false : this.doNotPerform.getValue();
1824        }
1825
1826        /**
1827         * @param value If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.
1828         */
1829        public CarePlanActivityDetailComponent setDoNotPerform(boolean value) { 
1830            if (this.doNotPerform == null)
1831              this.doNotPerform = new BooleanType();
1832            this.doNotPerform.setValue(value);
1833          return this;
1834        }
1835
1836        /**
1837         * @return {@link #scheduled} (The period, timing or frequency upon which the described activity is to occur.)
1838         */
1839        public Type getScheduled() { 
1840          return this.scheduled;
1841        }
1842
1843        /**
1844         * @return {@link #scheduled} (The period, timing or frequency upon which the described activity is to occur.)
1845         */
1846        public Timing getScheduledTiming() throws FHIRException { 
1847          if (this.scheduled == null)
1848            this.scheduled = new Timing();
1849          if (!(this.scheduled instanceof Timing))
1850            throw new FHIRException("Type mismatch: the type Timing was expected, but "+this.scheduled.getClass().getName()+" was encountered");
1851          return (Timing) this.scheduled;
1852        }
1853
1854        public boolean hasScheduledTiming() { 
1855          return this != null && this.scheduled instanceof Timing;
1856        }
1857
1858        /**
1859         * @return {@link #scheduled} (The period, timing or frequency upon which the described activity is to occur.)
1860         */
1861        public Period getScheduledPeriod() throws FHIRException { 
1862          if (this.scheduled == null)
1863            this.scheduled = new Period();
1864          if (!(this.scheduled instanceof Period))
1865            throw new FHIRException("Type mismatch: the type Period was expected, but "+this.scheduled.getClass().getName()+" was encountered");
1866          return (Period) this.scheduled;
1867        }
1868
1869        public boolean hasScheduledPeriod() { 
1870          return this != null && this.scheduled instanceof Period;
1871        }
1872
1873        /**
1874         * @return {@link #scheduled} (The period, timing or frequency upon which the described activity is to occur.)
1875         */
1876        public StringType getScheduledStringType() throws FHIRException { 
1877          if (this.scheduled == null)
1878            this.scheduled = new StringType();
1879          if (!(this.scheduled instanceof StringType))
1880            throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.scheduled.getClass().getName()+" was encountered");
1881          return (StringType) this.scheduled;
1882        }
1883
1884        public boolean hasScheduledStringType() { 
1885          return this != null && this.scheduled instanceof StringType;
1886        }
1887
1888        public boolean hasScheduled() { 
1889          return this.scheduled != null && !this.scheduled.isEmpty();
1890        }
1891
1892        /**
1893         * @param value {@link #scheduled} (The period, timing or frequency upon which the described activity is to occur.)
1894         */
1895        public CarePlanActivityDetailComponent setScheduled(Type value) { 
1896          if (value != null && !(value instanceof Timing || value instanceof Period || value instanceof StringType))
1897            throw new Error("Not the right type for CarePlan.activity.detail.scheduled[x]: "+value.fhirType());
1898          this.scheduled = value;
1899          return this;
1900        }
1901
1902        /**
1903         * @return {@link #location} (Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.)
1904         */
1905        public Reference getLocation() { 
1906          if (this.location == null)
1907            if (Configuration.errorOnAutoCreate())
1908              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.location");
1909            else if (Configuration.doAutoCreate())
1910              this.location = new Reference(); // cc
1911          return this.location;
1912        }
1913
1914        public boolean hasLocation() { 
1915          return this.location != null && !this.location.isEmpty();
1916        }
1917
1918        /**
1919         * @param value {@link #location} (Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.)
1920         */
1921        public CarePlanActivityDetailComponent setLocation(Reference value) { 
1922          this.location = value;
1923          return this;
1924        }
1925
1926        /**
1927         * @return {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.)
1928         */
1929        public Type getReported() { 
1930          return this.reported;
1931        }
1932
1933        /**
1934         * @return {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.)
1935         */
1936        public BooleanType getReportedBooleanType() throws FHIRException { 
1937          if (this.reported == null)
1938            this.reported = new BooleanType();
1939          if (!(this.reported instanceof BooleanType))
1940            throw new FHIRException("Type mismatch: the type BooleanType was expected, but "+this.reported.getClass().getName()+" was encountered");
1941          return (BooleanType) this.reported;
1942        }
1943
1944        public boolean hasReportedBooleanType() { 
1945          return this != null && this.reported instanceof BooleanType;
1946        }
1947
1948        /**
1949         * @return {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.)
1950         */
1951        public Reference getReportedReference() throws FHIRException { 
1952          if (this.reported == null)
1953            this.reported = new Reference();
1954          if (!(this.reported instanceof Reference))
1955            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.reported.getClass().getName()+" was encountered");
1956          return (Reference) this.reported;
1957        }
1958
1959        public boolean hasReportedReference() { 
1960          return this != null && this.reported instanceof Reference;
1961        }
1962
1963        public boolean hasReported() { 
1964          return this.reported != null && !this.reported.isEmpty();
1965        }
1966
1967        /**
1968         * @param value {@link #reported} (Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.)
1969         */
1970        public CarePlanActivityDetailComponent setReported(Type value) { 
1971          if (value != null && !(value instanceof BooleanType || value instanceof Reference))
1972            throw new Error("Not the right type for CarePlan.activity.detail.reported[x]: "+value.fhirType());
1973          this.reported = value;
1974          return this;
1975        }
1976
1977        /**
1978         * @return {@link #performer} (Identifies who's expected to be involved in the activity.)
1979         */
1980        public List<Reference> getPerformer() { 
1981          if (this.performer == null)
1982            this.performer = new ArrayList<Reference>();
1983          return this.performer;
1984        }
1985
1986        /**
1987         * @return Returns a reference to <code>this</code> for easy method chaining
1988         */
1989        public CarePlanActivityDetailComponent setPerformer(List<Reference> thePerformer) { 
1990          this.performer = thePerformer;
1991          return this;
1992        }
1993
1994        public boolean hasPerformer() { 
1995          if (this.performer == null)
1996            return false;
1997          for (Reference item : this.performer)
1998            if (!item.isEmpty())
1999              return true;
2000          return false;
2001        }
2002
2003        public Reference addPerformer() { //3
2004          Reference t = new Reference();
2005          if (this.performer == null)
2006            this.performer = new ArrayList<Reference>();
2007          this.performer.add(t);
2008          return t;
2009        }
2010
2011        public CarePlanActivityDetailComponent addPerformer(Reference t) { //3
2012          if (t == null)
2013            return this;
2014          if (this.performer == null)
2015            this.performer = new ArrayList<Reference>();
2016          this.performer.add(t);
2017          return this;
2018        }
2019
2020        /**
2021         * @return The first repetition of repeating field {@link #performer}, creating it if it does not already exist
2022         */
2023        public Reference getPerformerFirstRep() { 
2024          if (getPerformer().isEmpty()) {
2025            addPerformer();
2026          }
2027          return getPerformer().get(0);
2028        }
2029
2030        /**
2031         * @return {@link #product} (Identifies the food, drug or other product to be consumed or supplied in the activity.)
2032         */
2033        public Type getProduct() { 
2034          return this.product;
2035        }
2036
2037        /**
2038         * @return {@link #product} (Identifies the food, drug or other product to be consumed or supplied in the activity.)
2039         */
2040        public CodeableConcept getProductCodeableConcept() throws FHIRException { 
2041          if (this.product == null)
2042            this.product = new CodeableConcept();
2043          if (!(this.product instanceof CodeableConcept))
2044            throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "+this.product.getClass().getName()+" was encountered");
2045          return (CodeableConcept) this.product;
2046        }
2047
2048        public boolean hasProductCodeableConcept() { 
2049          return this != null && this.product instanceof CodeableConcept;
2050        }
2051
2052        /**
2053         * @return {@link #product} (Identifies the food, drug or other product to be consumed or supplied in the activity.)
2054         */
2055        public Reference getProductReference() throws FHIRException { 
2056          if (this.product == null)
2057            this.product = new Reference();
2058          if (!(this.product instanceof Reference))
2059            throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.product.getClass().getName()+" was encountered");
2060          return (Reference) this.product;
2061        }
2062
2063        public boolean hasProductReference() { 
2064          return this != null && this.product instanceof Reference;
2065        }
2066
2067        public boolean hasProduct() { 
2068          return this.product != null && !this.product.isEmpty();
2069        }
2070
2071        /**
2072         * @param value {@link #product} (Identifies the food, drug or other product to be consumed or supplied in the activity.)
2073         */
2074        public CarePlanActivityDetailComponent setProduct(Type value) { 
2075          if (value != null && !(value instanceof CodeableConcept || value instanceof Reference))
2076            throw new Error("Not the right type for CarePlan.activity.detail.product[x]: "+value.fhirType());
2077          this.product = value;
2078          return this;
2079        }
2080
2081        /**
2082         * @return {@link #dailyAmount} (Identifies the quantity expected to be consumed in a given day.)
2083         */
2084        public Quantity getDailyAmount() { 
2085          if (this.dailyAmount == null)
2086            if (Configuration.errorOnAutoCreate())
2087              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.dailyAmount");
2088            else if (Configuration.doAutoCreate())
2089              this.dailyAmount = new Quantity(); // cc
2090          return this.dailyAmount;
2091        }
2092
2093        public boolean hasDailyAmount() { 
2094          return this.dailyAmount != null && !this.dailyAmount.isEmpty();
2095        }
2096
2097        /**
2098         * @param value {@link #dailyAmount} (Identifies the quantity expected to be consumed in a given day.)
2099         */
2100        public CarePlanActivityDetailComponent setDailyAmount(Quantity value) { 
2101          this.dailyAmount = value;
2102          return this;
2103        }
2104
2105        /**
2106         * @return {@link #quantity} (Identifies the quantity expected to be supplied, administered or consumed by the subject.)
2107         */
2108        public Quantity getQuantity() { 
2109          if (this.quantity == null)
2110            if (Configuration.errorOnAutoCreate())
2111              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.quantity");
2112            else if (Configuration.doAutoCreate())
2113              this.quantity = new Quantity(); // cc
2114          return this.quantity;
2115        }
2116
2117        public boolean hasQuantity() { 
2118          return this.quantity != null && !this.quantity.isEmpty();
2119        }
2120
2121        /**
2122         * @param value {@link #quantity} (Identifies the quantity expected to be supplied, administered or consumed by the subject.)
2123         */
2124        public CarePlanActivityDetailComponent setQuantity(Quantity value) { 
2125          this.quantity = value;
2126          return this;
2127        }
2128
2129        /**
2130         * @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
2131         */
2132        public StringType getDescriptionElement() { 
2133          if (this.description == null)
2134            if (Configuration.errorOnAutoCreate())
2135              throw new Error("Attempt to auto-create CarePlanActivityDetailComponent.description");
2136            else if (Configuration.doAutoCreate())
2137              this.description = new StringType(); // bb
2138          return this.description;
2139        }
2140
2141        public boolean hasDescriptionElement() { 
2142          return this.description != null && !this.description.isEmpty();
2143        }
2144
2145        public boolean hasDescription() { 
2146          return this.description != null && !this.description.isEmpty();
2147        }
2148
2149        /**
2150         * @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
2151         */
2152        public CarePlanActivityDetailComponent setDescriptionElement(StringType value) { 
2153          this.description = value;
2154          return this;
2155        }
2156
2157        /**
2158         * @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.
2159         */
2160        public String getDescription() { 
2161          return this.description == null ? null : this.description.getValue();
2162        }
2163
2164        /**
2165         * @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.
2166         */
2167        public CarePlanActivityDetailComponent setDescription(String value) { 
2168          if (Utilities.noString(value))
2169            this.description = null;
2170          else {
2171            if (this.description == null)
2172              this.description = new StringType();
2173            this.description.setValue(value);
2174          }
2175          return this;
2176        }
2177
2178        protected void listChildren(List<Property> children) {
2179          super.listChildren(children);
2180          children.add(new Property("kind", "code", "A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.", 0, 1, kind));
2181          children.add(new Property("instantiatesCanonical", "canonical(PlanDefinition|ActivityDefinition|Questionnaire|Measure|OperationDefinition)", "The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical));
2182          children.add(new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri));
2183          children.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, 1, code));
2184          children.add(new Property("reasonCode", "CodeableConcept", "Provides the rationale that drove the inclusion of this particular activity as part of the plan or the reason why the activity was prohibited.", 0, java.lang.Integer.MAX_VALUE, reasonCode));
2185          children.add(new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "Indicates another resource, such as the health condition(s), whose existence justifies this request and drove the inclusion of this particular activity as part of the plan.", 0, java.lang.Integer.MAX_VALUE, reasonReference));
2186          children.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));
2187          children.add(new Property("status", "code", "Identifies what progress is being made for the specific activity.", 0, 1, status));
2188          children.add(new Property("statusReason", "CodeableConcept", "Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.", 0, 1, statusReason));
2189          children.add(new Property("doNotPerform", "boolean", "If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.", 0, 1, doNotPerform));
2190          children.add(new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled));
2191          children.add(new Property("location", "Reference(Location)", "Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.", 0, 1, location));
2192          children.add(new Property("reported[x]", "boolean|Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported));
2193          children.add(new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|RelatedPerson|Patient|CareTeam|HealthcareService|Device)", "Identifies who's expected to be involved in the activity.", 0, java.lang.Integer.MAX_VALUE, performer));
2194          children.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, 1, product));
2195          children.add(new Property("dailyAmount", "SimpleQuantity", "Identifies the quantity expected to be consumed in a given day.", 0, 1, dailyAmount));
2196          children.add(new Property("quantity", "SimpleQuantity", "Identifies the quantity expected to be supplied, administered or consumed by the subject.", 0, 1, quantity));
2197          children.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, 1, description));
2198        }
2199
2200        @Override
2201        public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
2202          switch (_hash) {
2203          case 3292052: /*kind*/  return new Property("kind", "code", "A description of the kind of resource the in-line definition of a care plan activity is representing.  The CarePlan.activity.detail is an in-line definition when a resource is not referenced using CarePlan.activity.reference.  For example, a MedicationRequest, a ServiceRequest, or a CommunicationRequest.", 0, 1, kind);
2204          case 8911915: /*instantiatesCanonical*/  return new Property("instantiatesCanonical", "canonical(PlanDefinition|ActivityDefinition|Questionnaire|Measure|OperationDefinition)", "The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical);
2205          case -1926393373: /*instantiatesUri*/  return new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan activity.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri);
2206          case 3059181: /*code*/  return new Property("code", "CodeableConcept", "Detailed description of the type of planned activity; e.g. what lab test, what procedure, what kind of encounter.", 0, 1, code);
2207          case 722137681: /*reasonCode*/  return new Property("reasonCode", "CodeableConcept", "Provides the rationale that drove the inclusion of this particular activity as part of the plan or the reason why the activity was prohibited.", 0, java.lang.Integer.MAX_VALUE, reasonCode);
2208          case -1146218137: /*reasonReference*/  return new Property("reasonReference", "Reference(Condition|Observation|DiagnosticReport|DocumentReference)", "Indicates another resource, such as the health condition(s), whose existence justifies this request and drove the inclusion of this particular activity as part of the plan.", 0, java.lang.Integer.MAX_VALUE, reasonReference);
2209          case 3178259: /*goal*/  return 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);
2210          case -892481550: /*status*/  return new Property("status", "code", "Identifies what progress is being made for the specific activity.", 0, 1, status);
2211          case 2051346646: /*statusReason*/  return new Property("statusReason", "CodeableConcept", "Provides reason why the activity isn't yet started, is on hold, was cancelled, etc.", 0, 1, statusReason);
2212          case -1788508167: /*doNotPerform*/  return new Property("doNotPerform", "boolean", "If true, indicates that the described activity is one that must NOT be engaged in when following the plan.  If false, or missing, indicates that the described activity is one that should be engaged in when following the plan.", 0, 1, doNotPerform);
2213          case 1162627251: /*scheduled[x]*/  return new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled);
2214          case -160710483: /*scheduled*/  return new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled);
2215          case 998483799: /*scheduledTiming*/  return new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled);
2216          case 880422094: /*scheduledPeriod*/  return new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled);
2217          case 980162334: /*scheduledString*/  return new Property("scheduled[x]", "Timing|Period|string", "The period, timing or frequency upon which the described activity is to occur.", 0, 1, scheduled);
2218          case 1901043637: /*location*/  return new Property("location", "Reference(Location)", "Identifies the facility where the activity will occur; e.g. home, hospital, specific clinic, etc.", 0, 1, location);
2219          case -241505587: /*reported[x]*/  return new Property("reported[x]", "boolean|Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported);
2220          case -427039533: /*reported*/  return new Property("reported[x]", "boolean|Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported);
2221          case 1219992533: /*reportedBoolean*/  return new Property("reported[x]", "boolean|Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported);
2222          case 1198143416: /*reportedReference*/  return new Property("reported[x]", "boolean|Reference(Patient|RelatedPerson|Practitioner|PractitionerRole|Organization)", "Indicates if this record was captured as a secondary 'reported' record rather than as an original primary source-of-truth record.  It may also indicate the source of the report.", 0, 1, reported);
2223          case 481140686: /*performer*/  return new Property("performer", "Reference(Practitioner|PractitionerRole|Organization|RelatedPerson|Patient|CareTeam|HealthcareService|Device)", "Identifies who's expected to be involved in the activity.", 0, java.lang.Integer.MAX_VALUE, performer);
2224          case 1753005361: /*product[x]*/  return new Property("product[x]", "CodeableConcept|Reference(Medication|Substance)", "Identifies the food, drug or other product to be consumed or supplied in the activity.", 0, 1, product);
2225          case -309474065: /*product*/  return new Property("product[x]", "CodeableConcept|Reference(Medication|Substance)", "Identifies the food, drug or other product to be consumed or supplied in the activity.", 0, 1, product);
2226          case 906854066: /*productCodeableConcept*/  return new Property("product[x]", "CodeableConcept|Reference(Medication|Substance)", "Identifies the food, drug or other product to be consumed or supplied in the activity.", 0, 1, product);
2227          case -669667556: /*productReference*/  return new Property("product[x]", "CodeableConcept|Reference(Medication|Substance)", "Identifies the food, drug or other product to be consumed or supplied in the activity.", 0, 1, product);
2228          case -768908335: /*dailyAmount*/  return new Property("dailyAmount", "SimpleQuantity", "Identifies the quantity expected to be consumed in a given day.", 0, 1, dailyAmount);
2229          case -1285004149: /*quantity*/  return new Property("quantity", "SimpleQuantity", "Identifies the quantity expected to be supplied, administered or consumed by the subject.", 0, 1, quantity);
2230          case -1724546052: /*description*/  return 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, 1, description);
2231          default: return super.getNamedProperty(_hash, _name, _checkValid);
2232          }
2233
2234        }
2235
2236      @Override
2237      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
2238        switch (hash) {
2239        case 3292052: /*kind*/ return this.kind == null ? new Base[0] : new Base[] {this.kind}; // Enumeration<CarePlanActivityKind>
2240        case 8911915: /*instantiatesCanonical*/ return this.instantiatesCanonical == null ? new Base[0] : this.instantiatesCanonical.toArray(new Base[this.instantiatesCanonical.size()]); // CanonicalType
2241        case -1926393373: /*instantiatesUri*/ return this.instantiatesUri == null ? new Base[0] : this.instantiatesUri.toArray(new Base[this.instantiatesUri.size()]); // UriType
2242        case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
2243        case 722137681: /*reasonCode*/ return this.reasonCode == null ? new Base[0] : this.reasonCode.toArray(new Base[this.reasonCode.size()]); // CodeableConcept
2244        case -1146218137: /*reasonReference*/ return this.reasonReference == null ? new Base[0] : this.reasonReference.toArray(new Base[this.reasonReference.size()]); // Reference
2245        case 3178259: /*goal*/ return this.goal == null ? new Base[0] : this.goal.toArray(new Base[this.goal.size()]); // Reference
2246        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CarePlanActivityStatus>
2247        case 2051346646: /*statusReason*/ return this.statusReason == null ? new Base[0] : new Base[] {this.statusReason}; // CodeableConcept
2248        case -1788508167: /*doNotPerform*/ return this.doNotPerform == null ? new Base[0] : new Base[] {this.doNotPerform}; // BooleanType
2249        case -160710483: /*scheduled*/ return this.scheduled == null ? new Base[0] : new Base[] {this.scheduled}; // Type
2250        case 1901043637: /*location*/ return this.location == null ? new Base[0] : new Base[] {this.location}; // Reference
2251        case -427039533: /*reported*/ return this.reported == null ? new Base[0] : new Base[] {this.reported}; // Type
2252        case 481140686: /*performer*/ return this.performer == null ? new Base[0] : this.performer.toArray(new Base[this.performer.size()]); // Reference
2253        case -309474065: /*product*/ return this.product == null ? new Base[0] : new Base[] {this.product}; // Type
2254        case -768908335: /*dailyAmount*/ return this.dailyAmount == null ? new Base[0] : new Base[] {this.dailyAmount}; // Quantity
2255        case -1285004149: /*quantity*/ return this.quantity == null ? new Base[0] : new Base[] {this.quantity}; // Quantity
2256        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
2257        default: return super.getProperty(hash, name, checkValid);
2258        }
2259
2260      }
2261
2262      @Override
2263      public Base setProperty(int hash, String name, Base value) throws FHIRException {
2264        switch (hash) {
2265        case 3292052: // kind
2266          value = new CarePlanActivityKindEnumFactory().fromType(castToCode(value));
2267          this.kind = (Enumeration) value; // Enumeration<CarePlanActivityKind>
2268          return value;
2269        case 8911915: // instantiatesCanonical
2270          this.getInstantiatesCanonical().add(castToCanonical(value)); // CanonicalType
2271          return value;
2272        case -1926393373: // instantiatesUri
2273          this.getInstantiatesUri().add(castToUri(value)); // UriType
2274          return value;
2275        case 3059181: // code
2276          this.code = castToCodeableConcept(value); // CodeableConcept
2277          return value;
2278        case 722137681: // reasonCode
2279          this.getReasonCode().add(castToCodeableConcept(value)); // CodeableConcept
2280          return value;
2281        case -1146218137: // reasonReference
2282          this.getReasonReference().add(castToReference(value)); // Reference
2283          return value;
2284        case 3178259: // goal
2285          this.getGoal().add(castToReference(value)); // Reference
2286          return value;
2287        case -892481550: // status
2288          value = new CarePlanActivityStatusEnumFactory().fromType(castToCode(value));
2289          this.status = (Enumeration) value; // Enumeration<CarePlanActivityStatus>
2290          return value;
2291        case 2051346646: // statusReason
2292          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2293          return value;
2294        case -1788508167: // doNotPerform
2295          this.doNotPerform = castToBoolean(value); // BooleanType
2296          return value;
2297        case -160710483: // scheduled
2298          this.scheduled = castToType(value); // Type
2299          return value;
2300        case 1901043637: // location
2301          this.location = castToReference(value); // Reference
2302          return value;
2303        case -427039533: // reported
2304          this.reported = castToType(value); // Type
2305          return value;
2306        case 481140686: // performer
2307          this.getPerformer().add(castToReference(value)); // Reference
2308          return value;
2309        case -309474065: // product
2310          this.product = castToType(value); // Type
2311          return value;
2312        case -768908335: // dailyAmount
2313          this.dailyAmount = castToQuantity(value); // Quantity
2314          return value;
2315        case -1285004149: // quantity
2316          this.quantity = castToQuantity(value); // Quantity
2317          return value;
2318        case -1724546052: // description
2319          this.description = castToString(value); // StringType
2320          return value;
2321        default: return super.setProperty(hash, name, value);
2322        }
2323
2324      }
2325
2326      @Override
2327      public Base setProperty(String name, Base value) throws FHIRException {
2328        if (name.equals("kind")) {
2329          value = new CarePlanActivityKindEnumFactory().fromType(castToCode(value));
2330          this.kind = (Enumeration) value; // Enumeration<CarePlanActivityKind>
2331        } else if (name.equals("instantiatesCanonical")) {
2332          this.getInstantiatesCanonical().add(castToCanonical(value));
2333        } else if (name.equals("instantiatesUri")) {
2334          this.getInstantiatesUri().add(castToUri(value));
2335        } else if (name.equals("code")) {
2336          this.code = castToCodeableConcept(value); // CodeableConcept
2337        } else if (name.equals("reasonCode")) {
2338          this.getReasonCode().add(castToCodeableConcept(value));
2339        } else if (name.equals("reasonReference")) {
2340          this.getReasonReference().add(castToReference(value));
2341        } else if (name.equals("goal")) {
2342          this.getGoal().add(castToReference(value));
2343        } else if (name.equals("status")) {
2344          value = new CarePlanActivityStatusEnumFactory().fromType(castToCode(value));
2345          this.status = (Enumeration) value; // Enumeration<CarePlanActivityStatus>
2346        } else if (name.equals("statusReason")) {
2347          this.statusReason = castToCodeableConcept(value); // CodeableConcept
2348        } else if (name.equals("doNotPerform")) {
2349          this.doNotPerform = castToBoolean(value); // BooleanType
2350        } else if (name.equals("scheduled[x]")) {
2351          this.scheduled = castToType(value); // Type
2352        } else if (name.equals("location")) {
2353          this.location = castToReference(value); // Reference
2354        } else if (name.equals("reported[x]")) {
2355          this.reported = castToType(value); // Type
2356        } else if (name.equals("performer")) {
2357          this.getPerformer().add(castToReference(value));
2358        } else if (name.equals("product[x]")) {
2359          this.product = castToType(value); // Type
2360        } else if (name.equals("dailyAmount")) {
2361          this.dailyAmount = castToQuantity(value); // Quantity
2362        } else if (name.equals("quantity")) {
2363          this.quantity = castToQuantity(value); // Quantity
2364        } else if (name.equals("description")) {
2365          this.description = castToString(value); // StringType
2366        } else
2367          return super.setProperty(name, value);
2368        return value;
2369      }
2370
2371      @Override
2372      public Base makeProperty(int hash, String name) throws FHIRException {
2373        switch (hash) {
2374        case 3292052:  return getKindElement();
2375        case 8911915:  return addInstantiatesCanonicalElement();
2376        case -1926393373:  return addInstantiatesUriElement();
2377        case 3059181:  return getCode();
2378        case 722137681:  return addReasonCode(); 
2379        case -1146218137:  return addReasonReference(); 
2380        case 3178259:  return addGoal(); 
2381        case -892481550:  return getStatusElement();
2382        case 2051346646:  return getStatusReason();
2383        case -1788508167:  return getDoNotPerformElement();
2384        case 1162627251:  return getScheduled();
2385        case -160710483:  return getScheduled();
2386        case 1901043637:  return getLocation();
2387        case -241505587:  return getReported();
2388        case -427039533:  return getReported();
2389        case 481140686:  return addPerformer(); 
2390        case 1753005361:  return getProduct();
2391        case -309474065:  return getProduct();
2392        case -768908335:  return getDailyAmount();
2393        case -1285004149:  return getQuantity();
2394        case -1724546052:  return getDescriptionElement();
2395        default: return super.makeProperty(hash, name);
2396        }
2397
2398      }
2399
2400      @Override
2401      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
2402        switch (hash) {
2403        case 3292052: /*kind*/ return new String[] {"code"};
2404        case 8911915: /*instantiatesCanonical*/ return new String[] {"canonical"};
2405        case -1926393373: /*instantiatesUri*/ return new String[] {"uri"};
2406        case 3059181: /*code*/ return new String[] {"CodeableConcept"};
2407        case 722137681: /*reasonCode*/ return new String[] {"CodeableConcept"};
2408        case -1146218137: /*reasonReference*/ return new String[] {"Reference"};
2409        case 3178259: /*goal*/ return new String[] {"Reference"};
2410        case -892481550: /*status*/ return new String[] {"code"};
2411        case 2051346646: /*statusReason*/ return new String[] {"CodeableConcept"};
2412        case -1788508167: /*doNotPerform*/ return new String[] {"boolean"};
2413        case -160710483: /*scheduled*/ return new String[] {"Timing", "Period", "string"};
2414        case 1901043637: /*location*/ return new String[] {"Reference"};
2415        case -427039533: /*reported*/ return new String[] {"boolean", "Reference"};
2416        case 481140686: /*performer*/ return new String[] {"Reference"};
2417        case -309474065: /*product*/ return new String[] {"CodeableConcept", "Reference"};
2418        case -768908335: /*dailyAmount*/ return new String[] {"SimpleQuantity"};
2419        case -1285004149: /*quantity*/ return new String[] {"SimpleQuantity"};
2420        case -1724546052: /*description*/ return new String[] {"string"};
2421        default: return super.getTypesForProperty(hash, name);
2422        }
2423
2424      }
2425
2426      @Override
2427      public Base addChild(String name) throws FHIRException {
2428        if (name.equals("kind")) {
2429          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.kind");
2430        }
2431        else if (name.equals("instantiatesCanonical")) {
2432          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.instantiatesCanonical");
2433        }
2434        else if (name.equals("instantiatesUri")) {
2435          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.instantiatesUri");
2436        }
2437        else if (name.equals("code")) {
2438          this.code = new CodeableConcept();
2439          return this.code;
2440        }
2441        else if (name.equals("reasonCode")) {
2442          return addReasonCode();
2443        }
2444        else if (name.equals("reasonReference")) {
2445          return addReasonReference();
2446        }
2447        else if (name.equals("goal")) {
2448          return addGoal();
2449        }
2450        else if (name.equals("status")) {
2451          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.status");
2452        }
2453        else if (name.equals("statusReason")) {
2454          this.statusReason = new CodeableConcept();
2455          return this.statusReason;
2456        }
2457        else if (name.equals("doNotPerform")) {
2458          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.doNotPerform");
2459        }
2460        else if (name.equals("scheduledTiming")) {
2461          this.scheduled = new Timing();
2462          return this.scheduled;
2463        }
2464        else if (name.equals("scheduledPeriod")) {
2465          this.scheduled = new Period();
2466          return this.scheduled;
2467        }
2468        else if (name.equals("scheduledString")) {
2469          this.scheduled = new StringType();
2470          return this.scheduled;
2471        }
2472        else if (name.equals("location")) {
2473          this.location = new Reference();
2474          return this.location;
2475        }
2476        else if (name.equals("reportedBoolean")) {
2477          this.reported = new BooleanType();
2478          return this.reported;
2479        }
2480        else if (name.equals("reportedReference")) {
2481          this.reported = new Reference();
2482          return this.reported;
2483        }
2484        else if (name.equals("performer")) {
2485          return addPerformer();
2486        }
2487        else if (name.equals("productCodeableConcept")) {
2488          this.product = new CodeableConcept();
2489          return this.product;
2490        }
2491        else if (name.equals("productReference")) {
2492          this.product = new Reference();
2493          return this.product;
2494        }
2495        else if (name.equals("dailyAmount")) {
2496          this.dailyAmount = new Quantity();
2497          return this.dailyAmount;
2498        }
2499        else if (name.equals("quantity")) {
2500          this.quantity = new Quantity();
2501          return this.quantity;
2502        }
2503        else if (name.equals("description")) {
2504          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.description");
2505        }
2506        else
2507          return super.addChild(name);
2508      }
2509
2510      public CarePlanActivityDetailComponent copy() {
2511        CarePlanActivityDetailComponent dst = new CarePlanActivityDetailComponent();
2512        copyValues(dst);
2513        return dst;
2514      }
2515
2516      public void copyValues(CarePlanActivityDetailComponent dst) {
2517        super.copyValues(dst);
2518        dst.kind = kind == null ? null : kind.copy();
2519        if (instantiatesCanonical != null) {
2520          dst.instantiatesCanonical = new ArrayList<CanonicalType>();
2521          for (CanonicalType i : instantiatesCanonical)
2522            dst.instantiatesCanonical.add(i.copy());
2523        };
2524        if (instantiatesUri != null) {
2525          dst.instantiatesUri = new ArrayList<UriType>();
2526          for (UriType i : instantiatesUri)
2527            dst.instantiatesUri.add(i.copy());
2528        };
2529        dst.code = code == null ? null : code.copy();
2530        if (reasonCode != null) {
2531          dst.reasonCode = new ArrayList<CodeableConcept>();
2532          for (CodeableConcept i : reasonCode)
2533            dst.reasonCode.add(i.copy());
2534        };
2535        if (reasonReference != null) {
2536          dst.reasonReference = new ArrayList<Reference>();
2537          for (Reference i : reasonReference)
2538            dst.reasonReference.add(i.copy());
2539        };
2540        if (goal != null) {
2541          dst.goal = new ArrayList<Reference>();
2542          for (Reference i : goal)
2543            dst.goal.add(i.copy());
2544        };
2545        dst.status = status == null ? null : status.copy();
2546        dst.statusReason = statusReason == null ? null : statusReason.copy();
2547        dst.doNotPerform = doNotPerform == null ? null : doNotPerform.copy();
2548        dst.scheduled = scheduled == null ? null : scheduled.copy();
2549        dst.location = location == null ? null : location.copy();
2550        dst.reported = reported == null ? null : reported.copy();
2551        if (performer != null) {
2552          dst.performer = new ArrayList<Reference>();
2553          for (Reference i : performer)
2554            dst.performer.add(i.copy());
2555        };
2556        dst.product = product == null ? null : product.copy();
2557        dst.dailyAmount = dailyAmount == null ? null : dailyAmount.copy();
2558        dst.quantity = quantity == null ? null : quantity.copy();
2559        dst.description = description == null ? null : description.copy();
2560      }
2561
2562      @Override
2563      public boolean equalsDeep(Base other_) {
2564        if (!super.equalsDeep(other_))
2565          return false;
2566        if (!(other_ instanceof CarePlanActivityDetailComponent))
2567          return false;
2568        CarePlanActivityDetailComponent o = (CarePlanActivityDetailComponent) other_;
2569        return compareDeep(kind, o.kind, true) && compareDeep(instantiatesCanonical, o.instantiatesCanonical, true)
2570           && compareDeep(instantiatesUri, o.instantiatesUri, true) && compareDeep(code, o.code, true) && compareDeep(reasonCode, o.reasonCode, true)
2571           && compareDeep(reasonReference, o.reasonReference, true) && compareDeep(goal, o.goal, true) && compareDeep(status, o.status, true)
2572           && compareDeep(statusReason, o.statusReason, true) && compareDeep(doNotPerform, o.doNotPerform, true)
2573           && compareDeep(scheduled, o.scheduled, true) && compareDeep(location, o.location, true) && compareDeep(reported, o.reported, true)
2574           && compareDeep(performer, o.performer, true) && compareDeep(product, o.product, true) && compareDeep(dailyAmount, o.dailyAmount, true)
2575           && compareDeep(quantity, o.quantity, true) && compareDeep(description, o.description, true);
2576      }
2577
2578      @Override
2579      public boolean equalsShallow(Base other_) {
2580        if (!super.equalsShallow(other_))
2581          return false;
2582        if (!(other_ instanceof CarePlanActivityDetailComponent))
2583          return false;
2584        CarePlanActivityDetailComponent o = (CarePlanActivityDetailComponent) other_;
2585        return compareValues(kind, o.kind, true) && compareValues(instantiatesUri, o.instantiatesUri, true)
2586           && compareValues(status, o.status, true) && compareValues(doNotPerform, o.doNotPerform, true) && compareValues(description, o.description, true)
2587          ;
2588      }
2589
2590      public boolean isEmpty() {
2591        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(kind, instantiatesCanonical
2592          , instantiatesUri, code, reasonCode, reasonReference, goal, status, statusReason
2593          , doNotPerform, scheduled, location, reported, performer, product, dailyAmount
2594          , quantity, description);
2595      }
2596
2597  public String fhirType() {
2598    return "CarePlan.activity.detail";
2599
2600  }
2601
2602  }
2603
2604    /**
2605     * Business identifiers assigned to this care plan by the performer or other systems which remain constant as the resource is updated and propagates from server to server.
2606     */
2607    @Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2608    @Description(shortDefinition="External Ids for this plan", formalDefinition="Business identifiers assigned to this care plan by the performer or other systems which remain constant as the resource is updated and propagates from server to server." )
2609    protected List<Identifier> identifier;
2610
2611    /**
2612     * The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.
2613     */
2614    @Child(name = "instantiatesCanonical", type = {CanonicalType.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2615    @Description(shortDefinition="Instantiates FHIR protocol or definition", formalDefinition="The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan." )
2616    protected List<CanonicalType> instantiatesCanonical;
2617
2618    /**
2619     * The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.
2620     */
2621    @Child(name = "instantiatesUri", type = {UriType.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2622    @Description(shortDefinition="Instantiates external protocol or definition", formalDefinition="The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan." )
2623    protected List<UriType> instantiatesUri;
2624
2625    /**
2626     * A care plan that is fulfilled in whole or in part by this care plan.
2627     */
2628    @Child(name = "basedOn", type = {CarePlan.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2629    @Description(shortDefinition="Fulfills CarePlan", formalDefinition="A care plan that is fulfilled in whole or in part by this care plan." )
2630    protected List<Reference> basedOn;
2631
2632    /**
2633     * Completed or terminated care plan whose function is taken by this new care plan.
2634     */
2635    @Child(name = "replaces", type = {CarePlan.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2636    @Description(shortDefinition="CarePlan replaced by this CarePlan", formalDefinition="Completed or terminated care plan whose function is taken by this new care plan." )
2637    protected List<Reference> replaces;
2638
2639    /**
2640     * A larger care plan of which this particular care plan is a component or step.
2641     */
2642    @Child(name = "partOf", type = {CarePlan.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2643    @Description(shortDefinition="Part of referenced CarePlan", formalDefinition="A larger care plan of which this particular care plan is a component or step." )
2644    protected List<Reference> partOf;
2645
2646    /**
2647     * Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.
2648     */
2649    @Child(name = "status", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
2650    @Description(shortDefinition="draft | active | on-hold | revoked | completed | entered-in-error | unknown", formalDefinition="Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record." )
2651    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/request-status")
2652    protected Enumeration<CarePlanStatus> status;
2653
2654    /**
2655     * Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.
2656     */
2657    @Child(name = "intent", type = {CodeType.class}, order=7, min=1, max=1, modifier=true, summary=true)
2658    @Description(shortDefinition="proposal | plan | order | option | directive", formalDefinition="Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain." )
2659    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-intent")
2660    protected Enumeration<CarePlanIntent> intent;
2661
2662    /**
2663     * 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.
2664     */
2665    @Child(name = "category", type = {CodeableConcept.class}, order=8, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2666    @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." )
2667    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/care-plan-category")
2668    protected List<CodeableConcept> category;
2669
2670    /**
2671     * Human-friendly name for the care plan.
2672     */
2673    @Child(name = "title", type = {StringType.class}, order=9, min=0, max=1, modifier=false, summary=true)
2674    @Description(shortDefinition="Human-friendly name for the care plan", formalDefinition="Human-friendly name for the care plan." )
2675    protected StringType title;
2676
2677    /**
2678     * A description of the scope and nature of the plan.
2679     */
2680    @Child(name = "description", type = {StringType.class}, order=10, min=0, max=1, modifier=false, summary=true)
2681    @Description(shortDefinition="Summary of nature of plan", formalDefinition="A description of the scope and nature of the plan." )
2682    protected StringType description;
2683
2684    /**
2685     * Identifies the patient or group whose intended care is described by the plan.
2686     */
2687    @Child(name = "subject", type = {Patient.class, Group.class}, order=11, min=1, max=1, modifier=false, summary=true)
2688    @Description(shortDefinition="Who the care plan is for", formalDefinition="Identifies the patient or group whose intended care is described by the plan." )
2689    protected Reference subject;
2690
2691    /**
2692     * The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated.
2693     */
2694    @Child(name = "encounter", type = {Encounter.class}, order=12, min=0, max=1, modifier=false, summary=true)
2695    @Description(shortDefinition="The Encounter during which this CarePlan was created", formalDefinition="The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated." )
2696    protected Reference encounter;
2697
2698    /**
2699     * Indicates when the plan did (or is intended to) come into effect and end.
2700     */
2701    @Child(name = "period", type = {Period.class}, order=13, min=0, max=1, modifier=false, summary=true)
2702    @Description(shortDefinition="Time period plan covers", formalDefinition="Indicates when the plan did (or is intended to) come into effect and end." )
2703    protected Period period;
2704
2705    /**
2706     * Represents when this particular CarePlan record was created in the system, which is often a system-generated date.
2707     */
2708    @Child(name = "created", type = {DateTimeType.class}, order=14, min=0, max=1, modifier=false, summary=true)
2709    @Description(shortDefinition="Date record was first recorded", formalDefinition="Represents when this particular CarePlan record was created in the system, which is often a system-generated date." )
2710    protected DateTimeType created;
2711
2712    /**
2713     * When populated, the author is responsible for the care plan.  The care plan is attributed to the author.
2714     */
2715    @Child(name = "author", type = {Patient.class, Practitioner.class, PractitionerRole.class, Device.class, RelatedPerson.class, Organization.class, CareTeam.class}, order=15, min=0, max=1, modifier=false, summary=true)
2716    @Description(shortDefinition="Who is the designated responsible party", formalDefinition="When populated, the author is responsible for the care plan.  The care plan is attributed to the author." )
2717    protected Reference author;
2718
2719    /**
2720     * Identifies the individual(s) or organization who provided the contents of the care plan.
2721     */
2722    @Child(name = "contributor", type = {Patient.class, Practitioner.class, PractitionerRole.class, Device.class, RelatedPerson.class, Organization.class, CareTeam.class}, order=16, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2723    @Description(shortDefinition="Who provided the content of the care plan", formalDefinition="Identifies the individual(s) or organization who provided the contents of the care plan." )
2724    protected List<Reference> contributor;
2725
2726    /**
2727     * Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.
2728     */
2729    @Child(name = "careTeam", type = {CareTeam.class}, order=17, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2730    @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." )
2731    protected List<Reference> careTeam;
2732
2733    /**
2734     * Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.
2735     */
2736    @Child(name = "addressesCode", type = {CodeableConcept.class}, order=18, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2737    @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." )
2738    @ca.uhn.fhir.model.api.annotation.Binding(valueSet="http://hl7.org/fhir/ValueSet/clinical-findings")
2739    protected List<CodeableConcept> addressesCode;
2740
2741    /**
2742     * Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.
2743     */
2744    @Child(name = "addressesReference", type = {Condition.class}, order=19, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
2745    @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." )
2746    protected List<Reference> addressesReference;
2747
2748    /**
2749     * Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include comorbidities, recent procedures, limitations, recent assessments, etc.
2750     */
2751    @Child(name = "supportingInfo", type = {Reference.class}, order=20, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2752    @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 comorbidities, recent procedures, limitations, recent assessments, etc." )
2753    protected List<Reference> supportingInfo;
2754
2755    /**
2756     * Describes the intended objective(s) of carrying out the care plan.
2757     */
2758    @Child(name = "goal", type = {Goal.class}, order=21, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2759    @Description(shortDefinition="Desired outcome of plan", formalDefinition="Describes the intended objective(s) of carrying out the care plan." )
2760    protected List<Reference> goal;
2761
2762    /**
2763     * Identifies an action that has occurred or is a planned action to occur as part of the plan. For example, a medication to be used, lab tests to perform, self-monitoring that has occurred, education etc.
2764     */
2765    @Child(name = "activity", type = {}, order=22, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2766    @Description(shortDefinition="Action to occur or has occurred as part of plan", formalDefinition="Identifies an action that has occurred or is a planned action to occur as part of the plan. For example, a medication to be used, lab tests to perform, self-monitoring that has occurred, education etc." )
2767    protected List<CarePlanActivityComponent> activity;
2768
2769    /**
2770     * General notes about the care plan not covered elsewhere.
2771     */
2772    @Child(name = "note", type = {Annotation.class}, order=23, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
2773    @Description(shortDefinition="Comments about the plan", formalDefinition="General notes about the care plan not covered elsewhere." )
2774    protected List<Annotation> note;
2775
2776    private static final long serialVersionUID = 422455124L;
2777
2778  /**
2779   * Constructor
2780   */
2781    public CarePlan() {
2782      super();
2783    }
2784
2785  /**
2786   * Constructor
2787   */
2788    public CarePlan(Enumeration<CarePlanStatus> status, Enumeration<CarePlanIntent> intent, Reference subject) {
2789      super();
2790      this.status = status;
2791      this.intent = intent;
2792      this.subject = subject;
2793    }
2794
2795    /**
2796     * @return {@link #identifier} (Business identifiers assigned to this care plan by the performer or other systems which remain constant as the resource is updated and propagates from server to server.)
2797     */
2798    public List<Identifier> getIdentifier() { 
2799      if (this.identifier == null)
2800        this.identifier = new ArrayList<Identifier>();
2801      return this.identifier;
2802    }
2803
2804    /**
2805     * @return Returns a reference to <code>this</code> for easy method chaining
2806     */
2807    public CarePlan setIdentifier(List<Identifier> theIdentifier) { 
2808      this.identifier = theIdentifier;
2809      return this;
2810    }
2811
2812    public boolean hasIdentifier() { 
2813      if (this.identifier == null)
2814        return false;
2815      for (Identifier item : this.identifier)
2816        if (!item.isEmpty())
2817          return true;
2818      return false;
2819    }
2820
2821    public Identifier addIdentifier() { //3
2822      Identifier t = new Identifier();
2823      if (this.identifier == null)
2824        this.identifier = new ArrayList<Identifier>();
2825      this.identifier.add(t);
2826      return t;
2827    }
2828
2829    public CarePlan addIdentifier(Identifier t) { //3
2830      if (t == null)
2831        return this;
2832      if (this.identifier == null)
2833        this.identifier = new ArrayList<Identifier>();
2834      this.identifier.add(t);
2835      return this;
2836    }
2837
2838    /**
2839     * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist
2840     */
2841    public Identifier getIdentifierFirstRep() { 
2842      if (getIdentifier().isEmpty()) {
2843        addIdentifier();
2844      }
2845      return getIdentifier().get(0);
2846    }
2847
2848    /**
2849     * @return {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2850     */
2851    public List<CanonicalType> getInstantiatesCanonical() { 
2852      if (this.instantiatesCanonical == null)
2853        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2854      return this.instantiatesCanonical;
2855    }
2856
2857    /**
2858     * @return Returns a reference to <code>this</code> for easy method chaining
2859     */
2860    public CarePlan setInstantiatesCanonical(List<CanonicalType> theInstantiatesCanonical) { 
2861      this.instantiatesCanonical = theInstantiatesCanonical;
2862      return this;
2863    }
2864
2865    public boolean hasInstantiatesCanonical() { 
2866      if (this.instantiatesCanonical == null)
2867        return false;
2868      for (CanonicalType item : this.instantiatesCanonical)
2869        if (!item.isEmpty())
2870          return true;
2871      return false;
2872    }
2873
2874    /**
2875     * @return {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2876     */
2877    public CanonicalType addInstantiatesCanonicalElement() {//2 
2878      CanonicalType t = new CanonicalType();
2879      if (this.instantiatesCanonical == null)
2880        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2881      this.instantiatesCanonical.add(t);
2882      return t;
2883    }
2884
2885    /**
2886     * @param value {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2887     */
2888    public CarePlan addInstantiatesCanonical(String value) { //1
2889      CanonicalType t = new CanonicalType();
2890      t.setValue(value);
2891      if (this.instantiatesCanonical == null)
2892        this.instantiatesCanonical = new ArrayList<CanonicalType>();
2893      this.instantiatesCanonical.add(t);
2894      return this;
2895    }
2896
2897    /**
2898     * @param value {@link #instantiatesCanonical} (The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2899     */
2900    public boolean hasInstantiatesCanonical(String value) { 
2901      if (this.instantiatesCanonical == null)
2902        return false;
2903      for (CanonicalType v : this.instantiatesCanonical)
2904        if (v.getValue().equals(value)) // canonical(PlanDefinition|Questionnaire|Measure|ActivityDefinition|OperationDefinition)
2905          return true;
2906      return false;
2907    }
2908
2909    /**
2910     * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2911     */
2912    public List<UriType> getInstantiatesUri() { 
2913      if (this.instantiatesUri == null)
2914        this.instantiatesUri = new ArrayList<UriType>();
2915      return this.instantiatesUri;
2916    }
2917
2918    /**
2919     * @return Returns a reference to <code>this</code> for easy method chaining
2920     */
2921    public CarePlan setInstantiatesUri(List<UriType> theInstantiatesUri) { 
2922      this.instantiatesUri = theInstantiatesUri;
2923      return this;
2924    }
2925
2926    public boolean hasInstantiatesUri() { 
2927      if (this.instantiatesUri == null)
2928        return false;
2929      for (UriType item : this.instantiatesUri)
2930        if (!item.isEmpty())
2931          return true;
2932      return false;
2933    }
2934
2935    /**
2936     * @return {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2937     */
2938    public UriType addInstantiatesUriElement() {//2 
2939      UriType t = new UriType();
2940      if (this.instantiatesUri == null)
2941        this.instantiatesUri = new ArrayList<UriType>();
2942      this.instantiatesUri.add(t);
2943      return t;
2944    }
2945
2946    /**
2947     * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2948     */
2949    public CarePlan addInstantiatesUri(String value) { //1
2950      UriType t = new UriType();
2951      t.setValue(value);
2952      if (this.instantiatesUri == null)
2953        this.instantiatesUri = new ArrayList<UriType>();
2954      this.instantiatesUri.add(t);
2955      return this;
2956    }
2957
2958    /**
2959     * @param value {@link #instantiatesUri} (The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.)
2960     */
2961    public boolean hasInstantiatesUri(String value) { 
2962      if (this.instantiatesUri == null)
2963        return false;
2964      for (UriType v : this.instantiatesUri)
2965        if (v.getValue().equals(value)) // uri
2966          return true;
2967      return false;
2968    }
2969
2970    /**
2971     * @return {@link #basedOn} (A care plan that is fulfilled in whole or in part by this care plan.)
2972     */
2973    public List<Reference> getBasedOn() { 
2974      if (this.basedOn == null)
2975        this.basedOn = new ArrayList<Reference>();
2976      return this.basedOn;
2977    }
2978
2979    /**
2980     * @return Returns a reference to <code>this</code> for easy method chaining
2981     */
2982    public CarePlan setBasedOn(List<Reference> theBasedOn) { 
2983      this.basedOn = theBasedOn;
2984      return this;
2985    }
2986
2987    public boolean hasBasedOn() { 
2988      if (this.basedOn == null)
2989        return false;
2990      for (Reference item : this.basedOn)
2991        if (!item.isEmpty())
2992          return true;
2993      return false;
2994    }
2995
2996    public Reference addBasedOn() { //3
2997      Reference t = new Reference();
2998      if (this.basedOn == null)
2999        this.basedOn = new ArrayList<Reference>();
3000      this.basedOn.add(t);
3001      return t;
3002    }
3003
3004    public CarePlan addBasedOn(Reference t) { //3
3005      if (t == null)
3006        return this;
3007      if (this.basedOn == null)
3008        this.basedOn = new ArrayList<Reference>();
3009      this.basedOn.add(t);
3010      return this;
3011    }
3012
3013    /**
3014     * @return The first repetition of repeating field {@link #basedOn}, creating it if it does not already exist
3015     */
3016    public Reference getBasedOnFirstRep() { 
3017      if (getBasedOn().isEmpty()) {
3018        addBasedOn();
3019      }
3020      return getBasedOn().get(0);
3021    }
3022
3023    /**
3024     * @return {@link #replaces} (Completed or terminated care plan whose function is taken by this new care plan.)
3025     */
3026    public List<Reference> getReplaces() { 
3027      if (this.replaces == null)
3028        this.replaces = new ArrayList<Reference>();
3029      return this.replaces;
3030    }
3031
3032    /**
3033     * @return Returns a reference to <code>this</code> for easy method chaining
3034     */
3035    public CarePlan setReplaces(List<Reference> theReplaces) { 
3036      this.replaces = theReplaces;
3037      return this;
3038    }
3039
3040    public boolean hasReplaces() { 
3041      if (this.replaces == null)
3042        return false;
3043      for (Reference item : this.replaces)
3044        if (!item.isEmpty())
3045          return true;
3046      return false;
3047    }
3048
3049    public Reference addReplaces() { //3
3050      Reference t = new Reference();
3051      if (this.replaces == null)
3052        this.replaces = new ArrayList<Reference>();
3053      this.replaces.add(t);
3054      return t;
3055    }
3056
3057    public CarePlan addReplaces(Reference t) { //3
3058      if (t == null)
3059        return this;
3060      if (this.replaces == null)
3061        this.replaces = new ArrayList<Reference>();
3062      this.replaces.add(t);
3063      return this;
3064    }
3065
3066    /**
3067     * @return The first repetition of repeating field {@link #replaces}, creating it if it does not already exist
3068     */
3069    public Reference getReplacesFirstRep() { 
3070      if (getReplaces().isEmpty()) {
3071        addReplaces();
3072      }
3073      return getReplaces().get(0);
3074    }
3075
3076    /**
3077     * @return {@link #partOf} (A larger care plan of which this particular care plan is a component or step.)
3078     */
3079    public List<Reference> getPartOf() { 
3080      if (this.partOf == null)
3081        this.partOf = new ArrayList<Reference>();
3082      return this.partOf;
3083    }
3084
3085    /**
3086     * @return Returns a reference to <code>this</code> for easy method chaining
3087     */
3088    public CarePlan setPartOf(List<Reference> thePartOf) { 
3089      this.partOf = thePartOf;
3090      return this;
3091    }
3092
3093    public boolean hasPartOf() { 
3094      if (this.partOf == null)
3095        return false;
3096      for (Reference item : this.partOf)
3097        if (!item.isEmpty())
3098          return true;
3099      return false;
3100    }
3101
3102    public Reference addPartOf() { //3
3103      Reference t = new Reference();
3104      if (this.partOf == null)
3105        this.partOf = new ArrayList<Reference>();
3106      this.partOf.add(t);
3107      return t;
3108    }
3109
3110    public CarePlan addPartOf(Reference t) { //3
3111      if (t == null)
3112        return this;
3113      if (this.partOf == null)
3114        this.partOf = new ArrayList<Reference>();
3115      this.partOf.add(t);
3116      return this;
3117    }
3118
3119    /**
3120     * @return The first repetition of repeating field {@link #partOf}, creating it if it does not already exist
3121     */
3122    public Reference getPartOfFirstRep() { 
3123      if (getPartOf().isEmpty()) {
3124        addPartOf();
3125      }
3126      return getPartOf().get(0);
3127    }
3128
3129    /**
3130     * @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
3131     */
3132    public Enumeration<CarePlanStatus> getStatusElement() { 
3133      if (this.status == null)
3134        if (Configuration.errorOnAutoCreate())
3135          throw new Error("Attempt to auto-create CarePlan.status");
3136        else if (Configuration.doAutoCreate())
3137          this.status = new Enumeration<CarePlanStatus>(new CarePlanStatusEnumFactory()); // bb
3138      return this.status;
3139    }
3140
3141    public boolean hasStatusElement() { 
3142      return this.status != null && !this.status.isEmpty();
3143    }
3144
3145    public boolean hasStatus() { 
3146      return this.status != null && !this.status.isEmpty();
3147    }
3148
3149    /**
3150     * @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
3151     */
3152    public CarePlan setStatusElement(Enumeration<CarePlanStatus> value) { 
3153      this.status = value;
3154      return this;
3155    }
3156
3157    /**
3158     * @return Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.
3159     */
3160    public CarePlanStatus getStatus() { 
3161      return this.status == null ? null : this.status.getValue();
3162    }
3163
3164    /**
3165     * @param value Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.
3166     */
3167    public CarePlan setStatus(CarePlanStatus value) { 
3168        if (this.status == null)
3169          this.status = new Enumeration<CarePlanStatus>(new CarePlanStatusEnumFactory());
3170        this.status.setValue(value);
3171      return this;
3172    }
3173
3174    /**
3175     * @return {@link #intent} (Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
3176     */
3177    public Enumeration<CarePlanIntent> getIntentElement() { 
3178      if (this.intent == null)
3179        if (Configuration.errorOnAutoCreate())
3180          throw new Error("Attempt to auto-create CarePlan.intent");
3181        else if (Configuration.doAutoCreate())
3182          this.intent = new Enumeration<CarePlanIntent>(new CarePlanIntentEnumFactory()); // bb
3183      return this.intent;
3184    }
3185
3186    public boolean hasIntentElement() { 
3187      return this.intent != null && !this.intent.isEmpty();
3188    }
3189
3190    public boolean hasIntent() { 
3191      return this.intent != null && !this.intent.isEmpty();
3192    }
3193
3194    /**
3195     * @param value {@link #intent} (Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.). This is the underlying object with id, value and extensions. The accessor "getIntent" gives direct access to the value
3196     */
3197    public CarePlan setIntentElement(Enumeration<CarePlanIntent> value) { 
3198      this.intent = value;
3199      return this;
3200    }
3201
3202    /**
3203     * @return Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.
3204     */
3205    public CarePlanIntent getIntent() { 
3206      return this.intent == null ? null : this.intent.getValue();
3207    }
3208
3209    /**
3210     * @param value Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.
3211     */
3212    public CarePlan setIntent(CarePlanIntent value) { 
3213        if (this.intent == null)
3214          this.intent = new Enumeration<CarePlanIntent>(new CarePlanIntentEnumFactory());
3215        this.intent.setValue(value);
3216      return this;
3217    }
3218
3219    /**
3220     * @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.)
3221     */
3222    public List<CodeableConcept> getCategory() { 
3223      if (this.category == null)
3224        this.category = new ArrayList<CodeableConcept>();
3225      return this.category;
3226    }
3227
3228    /**
3229     * @return Returns a reference to <code>this</code> for easy method chaining
3230     */
3231    public CarePlan setCategory(List<CodeableConcept> theCategory) { 
3232      this.category = theCategory;
3233      return this;
3234    }
3235
3236    public boolean hasCategory() { 
3237      if (this.category == null)
3238        return false;
3239      for (CodeableConcept item : this.category)
3240        if (!item.isEmpty())
3241          return true;
3242      return false;
3243    }
3244
3245    public CodeableConcept addCategory() { //3
3246      CodeableConcept t = new CodeableConcept();
3247      if (this.category == null)
3248        this.category = new ArrayList<CodeableConcept>();
3249      this.category.add(t);
3250      return t;
3251    }
3252
3253    public CarePlan addCategory(CodeableConcept t) { //3
3254      if (t == null)
3255        return this;
3256      if (this.category == null)
3257        this.category = new ArrayList<CodeableConcept>();
3258      this.category.add(t);
3259      return this;
3260    }
3261
3262    /**
3263     * @return The first repetition of repeating field {@link #category}, creating it if it does not already exist
3264     */
3265    public CodeableConcept getCategoryFirstRep() { 
3266      if (getCategory().isEmpty()) {
3267        addCategory();
3268      }
3269      return getCategory().get(0);
3270    }
3271
3272    /**
3273     * @return {@link #title} (Human-friendly name for the care plan.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
3274     */
3275    public StringType getTitleElement() { 
3276      if (this.title == null)
3277        if (Configuration.errorOnAutoCreate())
3278          throw new Error("Attempt to auto-create CarePlan.title");
3279        else if (Configuration.doAutoCreate())
3280          this.title = new StringType(); // bb
3281      return this.title;
3282    }
3283
3284    public boolean hasTitleElement() { 
3285      return this.title != null && !this.title.isEmpty();
3286    }
3287
3288    public boolean hasTitle() { 
3289      return this.title != null && !this.title.isEmpty();
3290    }
3291
3292    /**
3293     * @param value {@link #title} (Human-friendly name for the care plan.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
3294     */
3295    public CarePlan setTitleElement(StringType value) { 
3296      this.title = value;
3297      return this;
3298    }
3299
3300    /**
3301     * @return Human-friendly name for the care plan.
3302     */
3303    public String getTitle() { 
3304      return this.title == null ? null : this.title.getValue();
3305    }
3306
3307    /**
3308     * @param value Human-friendly name for the care plan.
3309     */
3310    public CarePlan setTitle(String value) { 
3311      if (Utilities.noString(value))
3312        this.title = null;
3313      else {
3314        if (this.title == null)
3315          this.title = new StringType();
3316        this.title.setValue(value);
3317      }
3318      return this;
3319    }
3320
3321    /**
3322     * @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
3323     */
3324    public StringType getDescriptionElement() { 
3325      if (this.description == null)
3326        if (Configuration.errorOnAutoCreate())
3327          throw new Error("Attempt to auto-create CarePlan.description");
3328        else if (Configuration.doAutoCreate())
3329          this.description = new StringType(); // bb
3330      return this.description;
3331    }
3332
3333    public boolean hasDescriptionElement() { 
3334      return this.description != null && !this.description.isEmpty();
3335    }
3336
3337    public boolean hasDescription() { 
3338      return this.description != null && !this.description.isEmpty();
3339    }
3340
3341    /**
3342     * @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
3343     */
3344    public CarePlan setDescriptionElement(StringType value) { 
3345      this.description = value;
3346      return this;
3347    }
3348
3349    /**
3350     * @return A description of the scope and nature of the plan.
3351     */
3352    public String getDescription() { 
3353      return this.description == null ? null : this.description.getValue();
3354    }
3355
3356    /**
3357     * @param value A description of the scope and nature of the plan.
3358     */
3359    public CarePlan setDescription(String value) { 
3360      if (Utilities.noString(value))
3361        this.description = null;
3362      else {
3363        if (this.description == null)
3364          this.description = new StringType();
3365        this.description.setValue(value);
3366      }
3367      return this;
3368    }
3369
3370    /**
3371     * @return {@link #subject} (Identifies the patient or group whose intended care is described by the plan.)
3372     */
3373    public Reference getSubject() { 
3374      if (this.subject == null)
3375        if (Configuration.errorOnAutoCreate())
3376          throw new Error("Attempt to auto-create CarePlan.subject");
3377        else if (Configuration.doAutoCreate())
3378          this.subject = new Reference(); // cc
3379      return this.subject;
3380    }
3381
3382    public boolean hasSubject() { 
3383      return this.subject != null && !this.subject.isEmpty();
3384    }
3385
3386    /**
3387     * @param value {@link #subject} (Identifies the patient or group whose intended care is described by the plan.)
3388     */
3389    public CarePlan setSubject(Reference value) { 
3390      this.subject = value;
3391      return this;
3392    }
3393
3394    /**
3395     * @return {@link #encounter} (The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated.)
3396     */
3397    public Reference getEncounter() { 
3398      if (this.encounter == null)
3399        if (Configuration.errorOnAutoCreate())
3400          throw new Error("Attempt to auto-create CarePlan.encounter");
3401        else if (Configuration.doAutoCreate())
3402          this.encounter = new Reference(); // cc
3403      return this.encounter;
3404    }
3405
3406    public boolean hasEncounter() { 
3407      return this.encounter != null && !this.encounter.isEmpty();
3408    }
3409
3410    /**
3411     * @param value {@link #encounter} (The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated.)
3412     */
3413    public CarePlan setEncounter(Reference value) { 
3414      this.encounter = value;
3415      return this;
3416    }
3417
3418    /**
3419     * @return {@link #period} (Indicates when the plan did (or is intended to) come into effect and end.)
3420     */
3421    public Period getPeriod() { 
3422      if (this.period == null)
3423        if (Configuration.errorOnAutoCreate())
3424          throw new Error("Attempt to auto-create CarePlan.period");
3425        else if (Configuration.doAutoCreate())
3426          this.period = new Period(); // cc
3427      return this.period;
3428    }
3429
3430    public boolean hasPeriod() { 
3431      return this.period != null && !this.period.isEmpty();
3432    }
3433
3434    /**
3435     * @param value {@link #period} (Indicates when the plan did (or is intended to) come into effect and end.)
3436     */
3437    public CarePlan setPeriod(Period value) { 
3438      this.period = value;
3439      return this;
3440    }
3441
3442    /**
3443     * @return {@link #created} (Represents when this particular CarePlan record was created in the system, which is often a system-generated date.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
3444     */
3445    public DateTimeType getCreatedElement() { 
3446      if (this.created == null)
3447        if (Configuration.errorOnAutoCreate())
3448          throw new Error("Attempt to auto-create CarePlan.created");
3449        else if (Configuration.doAutoCreate())
3450          this.created = new DateTimeType(); // bb
3451      return this.created;
3452    }
3453
3454    public boolean hasCreatedElement() { 
3455      return this.created != null && !this.created.isEmpty();
3456    }
3457
3458    public boolean hasCreated() { 
3459      return this.created != null && !this.created.isEmpty();
3460    }
3461
3462    /**
3463     * @param value {@link #created} (Represents when this particular CarePlan record was created in the system, which is often a system-generated date.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
3464     */
3465    public CarePlan setCreatedElement(DateTimeType value) { 
3466      this.created = value;
3467      return this;
3468    }
3469
3470    /**
3471     * @return Represents when this particular CarePlan record was created in the system, which is often a system-generated date.
3472     */
3473    public Date getCreated() { 
3474      return this.created == null ? null : this.created.getValue();
3475    }
3476
3477    /**
3478     * @param value Represents when this particular CarePlan record was created in the system, which is often a system-generated date.
3479     */
3480    public CarePlan setCreated(Date value) { 
3481      if (value == null)
3482        this.created = null;
3483      else {
3484        if (this.created == null)
3485          this.created = new DateTimeType();
3486        this.created.setValue(value);
3487      }
3488      return this;
3489    }
3490
3491    /**
3492     * @return {@link #author} (When populated, the author is responsible for the care plan.  The care plan is attributed to the author.)
3493     */
3494    public Reference getAuthor() { 
3495      if (this.author == null)
3496        if (Configuration.errorOnAutoCreate())
3497          throw new Error("Attempt to auto-create CarePlan.author");
3498        else if (Configuration.doAutoCreate())
3499          this.author = new Reference(); // cc
3500      return this.author;
3501    }
3502
3503    public boolean hasAuthor() { 
3504      return this.author != null && !this.author.isEmpty();
3505    }
3506
3507    /**
3508     * @param value {@link #author} (When populated, the author is responsible for the care plan.  The care plan is attributed to the author.)
3509     */
3510    public CarePlan setAuthor(Reference value) { 
3511      this.author = value;
3512      return this;
3513    }
3514
3515    /**
3516     * @return {@link #contributor} (Identifies the individual(s) or organization who provided the contents of the care plan.)
3517     */
3518    public List<Reference> getContributor() { 
3519      if (this.contributor == null)
3520        this.contributor = new ArrayList<Reference>();
3521      return this.contributor;
3522    }
3523
3524    /**
3525     * @return Returns a reference to <code>this</code> for easy method chaining
3526     */
3527    public CarePlan setContributor(List<Reference> theContributor) { 
3528      this.contributor = theContributor;
3529      return this;
3530    }
3531
3532    public boolean hasContributor() { 
3533      if (this.contributor == null)
3534        return false;
3535      for (Reference item : this.contributor)
3536        if (!item.isEmpty())
3537          return true;
3538      return false;
3539    }
3540
3541    public Reference addContributor() { //3
3542      Reference t = new Reference();
3543      if (this.contributor == null)
3544        this.contributor = new ArrayList<Reference>();
3545      this.contributor.add(t);
3546      return t;
3547    }
3548
3549    public CarePlan addContributor(Reference t) { //3
3550      if (t == null)
3551        return this;
3552      if (this.contributor == null)
3553        this.contributor = new ArrayList<Reference>();
3554      this.contributor.add(t);
3555      return this;
3556    }
3557
3558    /**
3559     * @return The first repetition of repeating field {@link #contributor}, creating it if it does not already exist
3560     */
3561    public Reference getContributorFirstRep() { 
3562      if (getContributor().isEmpty()) {
3563        addContributor();
3564      }
3565      return getContributor().get(0);
3566    }
3567
3568    /**
3569     * @return {@link #careTeam} (Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.)
3570     */
3571    public List<Reference> getCareTeam() { 
3572      if (this.careTeam == null)
3573        this.careTeam = new ArrayList<Reference>();
3574      return this.careTeam;
3575    }
3576
3577    /**
3578     * @return Returns a reference to <code>this</code> for easy method chaining
3579     */
3580    public CarePlan setCareTeam(List<Reference> theCareTeam) { 
3581      this.careTeam = theCareTeam;
3582      return this;
3583    }
3584
3585    public boolean hasCareTeam() { 
3586      if (this.careTeam == null)
3587        return false;
3588      for (Reference item : this.careTeam)
3589        if (!item.isEmpty())
3590          return true;
3591      return false;
3592    }
3593
3594    public Reference addCareTeam() { //3
3595      Reference t = new Reference();
3596      if (this.careTeam == null)
3597        this.careTeam = new ArrayList<Reference>();
3598      this.careTeam.add(t);
3599      return t;
3600    }
3601
3602    public CarePlan addCareTeam(Reference t) { //3
3603      if (t == null)
3604        return this;
3605      if (this.careTeam == null)
3606        this.careTeam = new ArrayList<Reference>();
3607      this.careTeam.add(t);
3608      return this;
3609    }
3610
3611    /**
3612     * @return The first repetition of repeating field {@link #careTeam}, creating it if it does not already exist
3613     */
3614    public Reference getCareTeamFirstRep() { 
3615      if (getCareTeam().isEmpty()) {
3616        addCareTeam();
3617      }
3618      return getCareTeam().get(0);
3619    }
3620
3621    /**
3622     * @return {@link #addressesCode} (Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.)
3623     */
3624    public List<CodeableConcept> getAddressesCode() { 
3625      if (this.addressesCode == null)
3626        this.addressesCode = new ArrayList<CodeableConcept>();
3627      return this.addressesCode;
3628    }
3629
3630    /**
3631     * @return Returns a reference to <code>this</code> for easy method chaining
3632     */
3633    public CarePlan setAddressesCode(List<CodeableConcept> theAddressesCode) { 
3634      this.addressesCode = theAddressesCode;
3635      return this;
3636    }
3637
3638    public boolean hasAddressesCode() { 
3639      if (this.addressesCode == null)
3640        return false;
3641      for (CodeableConcept item : this.addressesCode)
3642        if (!item.isEmpty())
3643          return true;
3644      return false;
3645    }
3646
3647    public CodeableConcept addAddressesCode() { //3
3648      CodeableConcept t = new CodeableConcept();
3649      if (this.addressesCode == null)
3650        this.addressesCode = new ArrayList<CodeableConcept>();
3651      this.addressesCode.add(t);
3652      return t;
3653    }
3654
3655    public CarePlan addAddressesCode(CodeableConcept t) { //3
3656      if (t == null)
3657        return this;
3658      if (this.addressesCode == null)
3659        this.addressesCode = new ArrayList<CodeableConcept>();
3660      this.addressesCode.add(t);
3661      return this;
3662    }
3663
3664    /**
3665     * @return The first repetition of repeating field {@link #addressesCode}, creating it if it does not already exist
3666     */
3667    public CodeableConcept getAddressesCodeFirstRep() { 
3668      if (getAddressesCode().isEmpty()) {
3669        addAddressesCode();
3670      }
3671      return getAddressesCode().get(0);
3672    }
3673
3674    /**
3675     * @return {@link #addressesReference} (Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.)
3676     */
3677    public List<Reference> getAddressesReference() { 
3678      if (this.addressesReference == null)
3679        this.addressesReference = new ArrayList<Reference>();
3680      return this.addressesReference;
3681    }
3682
3683    /**
3684     * @return Returns a reference to <code>this</code> for easy method chaining
3685     */
3686    public CarePlan setAddressesReference(List<Reference> theAddressesReference) { 
3687      this.addressesReference = theAddressesReference;
3688      return this;
3689    }
3690
3691    public boolean hasAddressesReference() { 
3692      if (this.addressesReference == null)
3693        return false;
3694      for (Reference item : this.addressesReference)
3695        if (!item.isEmpty())
3696          return true;
3697      return false;
3698    }
3699
3700    public Reference addAddressesReference() { //3
3701      Reference t = new Reference();
3702      if (this.addressesReference == null)
3703        this.addressesReference = new ArrayList<Reference>();
3704      this.addressesReference.add(t);
3705      return t;
3706    }
3707
3708    public CarePlan addAddressesReference(Reference t) { //3
3709      if (t == null)
3710        return this;
3711      if (this.addressesReference == null)
3712        this.addressesReference = new ArrayList<Reference>();
3713      this.addressesReference.add(t);
3714      return this;
3715    }
3716
3717    /**
3718     * @return The first repetition of repeating field {@link #addressesReference}, creating it if it does not already exist
3719     */
3720    public Reference getAddressesReferenceFirstRep() { 
3721      if (getAddressesReference().isEmpty()) {
3722        addAddressesReference();
3723      }
3724      return getAddressesReference().get(0);
3725    }
3726
3727    /**
3728     * @return {@link #supportingInfo} (Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include comorbidities, recent procedures, limitations, recent assessments, etc.)
3729     */
3730    public List<Reference> getSupportingInfo() { 
3731      if (this.supportingInfo == null)
3732        this.supportingInfo = new ArrayList<Reference>();
3733      return this.supportingInfo;
3734    }
3735
3736    /**
3737     * @return Returns a reference to <code>this</code> for easy method chaining
3738     */
3739    public CarePlan setSupportingInfo(List<Reference> theSupportingInfo) { 
3740      this.supportingInfo = theSupportingInfo;
3741      return this;
3742    }
3743
3744    public boolean hasSupportingInfo() { 
3745      if (this.supportingInfo == null)
3746        return false;
3747      for (Reference item : this.supportingInfo)
3748        if (!item.isEmpty())
3749          return true;
3750      return false;
3751    }
3752
3753    public Reference addSupportingInfo() { //3
3754      Reference t = new Reference();
3755      if (this.supportingInfo == null)
3756        this.supportingInfo = new ArrayList<Reference>();
3757      this.supportingInfo.add(t);
3758      return t;
3759    }
3760
3761    public CarePlan addSupportingInfo(Reference t) { //3
3762      if (t == null)
3763        return this;
3764      if (this.supportingInfo == null)
3765        this.supportingInfo = new ArrayList<Reference>();
3766      this.supportingInfo.add(t);
3767      return this;
3768    }
3769
3770    /**
3771     * @return The first repetition of repeating field {@link #supportingInfo}, creating it if it does not already exist
3772     */
3773    public Reference getSupportingInfoFirstRep() { 
3774      if (getSupportingInfo().isEmpty()) {
3775        addSupportingInfo();
3776      }
3777      return getSupportingInfo().get(0);
3778    }
3779
3780    /**
3781     * @return {@link #goal} (Describes the intended objective(s) of carrying out the care plan.)
3782     */
3783    public List<Reference> getGoal() { 
3784      if (this.goal == null)
3785        this.goal = new ArrayList<Reference>();
3786      return this.goal;
3787    }
3788
3789    /**
3790     * @return Returns a reference to <code>this</code> for easy method chaining
3791     */
3792    public CarePlan setGoal(List<Reference> theGoal) { 
3793      this.goal = theGoal;
3794      return this;
3795    }
3796
3797    public boolean hasGoal() { 
3798      if (this.goal == null)
3799        return false;
3800      for (Reference item : this.goal)
3801        if (!item.isEmpty())
3802          return true;
3803      return false;
3804    }
3805
3806    public Reference addGoal() { //3
3807      Reference t = new Reference();
3808      if (this.goal == null)
3809        this.goal = new ArrayList<Reference>();
3810      this.goal.add(t);
3811      return t;
3812    }
3813
3814    public CarePlan addGoal(Reference t) { //3
3815      if (t == null)
3816        return this;
3817      if (this.goal == null)
3818        this.goal = new ArrayList<Reference>();
3819      this.goal.add(t);
3820      return this;
3821    }
3822
3823    /**
3824     * @return The first repetition of repeating field {@link #goal}, creating it if it does not already exist
3825     */
3826    public Reference getGoalFirstRep() { 
3827      if (getGoal().isEmpty()) {
3828        addGoal();
3829      }
3830      return getGoal().get(0);
3831    }
3832
3833    /**
3834     * @return {@link #activity} (Identifies an action that has occurred or is a planned action to occur as part of the plan. For example, a medication to be used, lab tests to perform, self-monitoring that has occurred, education etc.)
3835     */
3836    public List<CarePlanActivityComponent> getActivity() { 
3837      if (this.activity == null)
3838        this.activity = new ArrayList<CarePlanActivityComponent>();
3839      return this.activity;
3840    }
3841
3842    /**
3843     * @return Returns a reference to <code>this</code> for easy method chaining
3844     */
3845    public CarePlan setActivity(List<CarePlanActivityComponent> theActivity) { 
3846      this.activity = theActivity;
3847      return this;
3848    }
3849
3850    public boolean hasActivity() { 
3851      if (this.activity == null)
3852        return false;
3853      for (CarePlanActivityComponent item : this.activity)
3854        if (!item.isEmpty())
3855          return true;
3856      return false;
3857    }
3858
3859    public CarePlanActivityComponent addActivity() { //3
3860      CarePlanActivityComponent t = new CarePlanActivityComponent();
3861      if (this.activity == null)
3862        this.activity = new ArrayList<CarePlanActivityComponent>();
3863      this.activity.add(t);
3864      return t;
3865    }
3866
3867    public CarePlan addActivity(CarePlanActivityComponent t) { //3
3868      if (t == null)
3869        return this;
3870      if (this.activity == null)
3871        this.activity = new ArrayList<CarePlanActivityComponent>();
3872      this.activity.add(t);
3873      return this;
3874    }
3875
3876    /**
3877     * @return The first repetition of repeating field {@link #activity}, creating it if it does not already exist
3878     */
3879    public CarePlanActivityComponent getActivityFirstRep() { 
3880      if (getActivity().isEmpty()) {
3881        addActivity();
3882      }
3883      return getActivity().get(0);
3884    }
3885
3886    /**
3887     * @return {@link #note} (General notes about the care plan not covered elsewhere.)
3888     */
3889    public List<Annotation> getNote() { 
3890      if (this.note == null)
3891        this.note = new ArrayList<Annotation>();
3892      return this.note;
3893    }
3894
3895    /**
3896     * @return Returns a reference to <code>this</code> for easy method chaining
3897     */
3898    public CarePlan setNote(List<Annotation> theNote) { 
3899      this.note = theNote;
3900      return this;
3901    }
3902
3903    public boolean hasNote() { 
3904      if (this.note == null)
3905        return false;
3906      for (Annotation item : this.note)
3907        if (!item.isEmpty())
3908          return true;
3909      return false;
3910    }
3911
3912    public Annotation addNote() { //3
3913      Annotation t = new Annotation();
3914      if (this.note == null)
3915        this.note = new ArrayList<Annotation>();
3916      this.note.add(t);
3917      return t;
3918    }
3919
3920    public CarePlan addNote(Annotation t) { //3
3921      if (t == null)
3922        return this;
3923      if (this.note == null)
3924        this.note = new ArrayList<Annotation>();
3925      this.note.add(t);
3926      return this;
3927    }
3928
3929    /**
3930     * @return The first repetition of repeating field {@link #note}, creating it if it does not already exist
3931     */
3932    public Annotation getNoteFirstRep() { 
3933      if (getNote().isEmpty()) {
3934        addNote();
3935      }
3936      return getNote().get(0);
3937    }
3938
3939      protected void listChildren(List<Property> children) {
3940        super.listChildren(children);
3941        children.add(new Property("identifier", "Identifier", "Business identifiers assigned to this care plan by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier));
3942        children.add(new Property("instantiatesCanonical", "canonical(PlanDefinition|Questionnaire|Measure|ActivityDefinition|OperationDefinition)", "The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical));
3943        children.add(new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri));
3944        children.add(new Property("basedOn", "Reference(CarePlan)", "A care plan that is fulfilled in whole or in part by this care plan.", 0, java.lang.Integer.MAX_VALUE, basedOn));
3945        children.add(new Property("replaces", "Reference(CarePlan)", "Completed or terminated care plan whose function is taken by this new care plan.", 0, java.lang.Integer.MAX_VALUE, replaces));
3946        children.add(new Property("partOf", "Reference(CarePlan)", "A larger care plan of which this particular care plan is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf));
3947        children.add(new Property("status", "code", "Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.", 0, 1, status));
3948        children.add(new Property("intent", "code", "Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.", 0, 1, intent));
3949        children.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));
3950        children.add(new Property("title", "string", "Human-friendly name for the care plan.", 0, 1, title));
3951        children.add(new Property("description", "string", "A description of the scope and nature of the plan.", 0, 1, description));
3952        children.add(new Property("subject", "Reference(Patient|Group)", "Identifies the patient or group whose intended care is described by the plan.", 0, 1, subject));
3953        children.add(new Property("encounter", "Reference(Encounter)", "The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated.", 0, 1, encounter));
3954        children.add(new Property("period", "Period", "Indicates when the plan did (or is intended to) come into effect and end.", 0, 1, period));
3955        children.add(new Property("created", "dateTime", "Represents when this particular CarePlan record was created in the system, which is often a system-generated date.", 0, 1, created));
3956        children.add(new Property("author", "Reference(Patient|Practitioner|PractitionerRole|Device|RelatedPerson|Organization|CareTeam)", "When populated, the author is responsible for the care plan.  The care plan is attributed to the author.", 0, 1, author));
3957        children.add(new Property("contributor", "Reference(Patient|Practitioner|PractitionerRole|Device|RelatedPerson|Organization|CareTeam)", "Identifies the individual(s) or organization who provided the contents of the care plan.", 0, java.lang.Integer.MAX_VALUE, contributor));
3958        children.add(new Property("careTeam", "Reference(CareTeam)", "Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.", 0, java.lang.Integer.MAX_VALUE, careTeam));
3959        children.add(new Property("addressesCode", "CodeableConcept", "Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.", 0, java.lang.Integer.MAX_VALUE, addressesCode));
3960        children.add(new Property("addressesReference", "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, addressesReference));
3961        children.add(new Property("supportingInfo", "Reference(Any)", "Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include comorbidities, recent procedures, limitations, recent assessments, etc.", 0, java.lang.Integer.MAX_VALUE, supportingInfo));
3962        children.add(new Property("goal", "Reference(Goal)", "Describes the intended objective(s) of carrying out the care plan.", 0, java.lang.Integer.MAX_VALUE, goal));
3963        children.add(new Property("activity", "", "Identifies an action that has occurred or is a planned action to occur as part of the plan. For example, a medication to be used, lab tests to perform, self-monitoring that has occurred, education etc.", 0, java.lang.Integer.MAX_VALUE, activity));
3964        children.add(new Property("note", "Annotation", "General notes about the care plan not covered elsewhere.", 0, java.lang.Integer.MAX_VALUE, note));
3965      }
3966
3967      @Override
3968      public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
3969        switch (_hash) {
3970        case -1618432855: /*identifier*/  return new Property("identifier", "Identifier", "Business identifiers assigned to this care plan by the performer or other systems which remain constant as the resource is updated and propagates from server to server.", 0, java.lang.Integer.MAX_VALUE, identifier);
3971        case 8911915: /*instantiatesCanonical*/  return new Property("instantiatesCanonical", "canonical(PlanDefinition|Questionnaire|Measure|ActivityDefinition|OperationDefinition)", "The URL pointing to a FHIR-defined protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.", 0, java.lang.Integer.MAX_VALUE, instantiatesCanonical);
3972        case -1926393373: /*instantiatesUri*/  return new Property("instantiatesUri", "uri", "The URL pointing to an externally maintained protocol, guideline, questionnaire or other definition that is adhered to in whole or in part by this CarePlan.", 0, java.lang.Integer.MAX_VALUE, instantiatesUri);
3973        case -332612366: /*basedOn*/  return new Property("basedOn", "Reference(CarePlan)", "A care plan that is fulfilled in whole or in part by this care plan.", 0, java.lang.Integer.MAX_VALUE, basedOn);
3974        case -430332865: /*replaces*/  return new Property("replaces", "Reference(CarePlan)", "Completed or terminated care plan whose function is taken by this new care plan.", 0, java.lang.Integer.MAX_VALUE, replaces);
3975        case -995410646: /*partOf*/  return new Property("partOf", "Reference(CarePlan)", "A larger care plan of which this particular care plan is a component or step.", 0, java.lang.Integer.MAX_VALUE, partOf);
3976        case -892481550: /*status*/  return new Property("status", "code", "Indicates whether the plan is currently being acted upon, represents future intentions or is now a historical record.", 0, 1, status);
3977        case -1183762788: /*intent*/  return new Property("intent", "code", "Indicates the level of authority/intentionality associated with the care plan and where the care plan fits into the workflow chain.", 0, 1, intent);
3978        case 50511102: /*category*/  return 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);
3979        case 110371416: /*title*/  return new Property("title", "string", "Human-friendly name for the care plan.", 0, 1, title);
3980        case -1724546052: /*description*/  return new Property("description", "string", "A description of the scope and nature of the plan.", 0, 1, description);
3981        case -1867885268: /*subject*/  return new Property("subject", "Reference(Patient|Group)", "Identifies the patient or group whose intended care is described by the plan.", 0, 1, subject);
3982        case 1524132147: /*encounter*/  return new Property("encounter", "Reference(Encounter)", "The Encounter during which this CarePlan was created or to which the creation of this record is tightly associated.", 0, 1, encounter);
3983        case -991726143: /*period*/  return new Property("period", "Period", "Indicates when the plan did (or is intended to) come into effect and end.", 0, 1, period);
3984        case 1028554472: /*created*/  return new Property("created", "dateTime", "Represents when this particular CarePlan record was created in the system, which is often a system-generated date.", 0, 1, created);
3985        case -1406328437: /*author*/  return new Property("author", "Reference(Patient|Practitioner|PractitionerRole|Device|RelatedPerson|Organization|CareTeam)", "When populated, the author is responsible for the care plan.  The care plan is attributed to the author.", 0, 1, author);
3986        case -1895276325: /*contributor*/  return new Property("contributor", "Reference(Patient|Practitioner|PractitionerRole|Device|RelatedPerson|Organization|CareTeam)", "Identifies the individual(s) or organization who provided the contents of the care plan.", 0, java.lang.Integer.MAX_VALUE, contributor);
3987        case -7323378: /*careTeam*/  return new Property("careTeam", "Reference(CareTeam)", "Identifies all people and organizations who are expected to be involved in the care envisioned by this plan.", 0, java.lang.Integer.MAX_VALUE, careTeam);
3988        case -227148625: /*addressesCode*/  return new Property("addressesCode", "CodeableConcept", "Identifies the conditions/problems/concerns/diagnoses/etc. whose management and/or mitigation are handled by this plan.", 0, java.lang.Integer.MAX_VALUE, addressesCode);
3989        case -1878992439: /*addressesReference*/  return new Property("addressesReference", "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, addressesReference);
3990        case 1922406657: /*supportingInfo*/  return new Property("supportingInfo", "Reference(Any)", "Identifies portions of the patient's record that specifically influenced the formation of the plan.  These might include comorbidities, recent procedures, limitations, recent assessments, etc.", 0, java.lang.Integer.MAX_VALUE, supportingInfo);
3991        case 3178259: /*goal*/  return new Property("goal", "Reference(Goal)", "Describes the intended objective(s) of carrying out the care plan.", 0, java.lang.Integer.MAX_VALUE, goal);
3992        case -1655966961: /*activity*/  return new Property("activity", "", "Identifies an action that has occurred or is a planned action to occur as part of the plan. For example, a medication to be used, lab tests to perform, self-monitoring that has occurred, education etc.", 0, java.lang.Integer.MAX_VALUE, activity);
3993        case 3387378: /*note*/  return new Property("note", "Annotation", "General notes about the care plan not covered elsewhere.", 0, java.lang.Integer.MAX_VALUE, note);
3994        default: return super.getNamedProperty(_hash, _name, _checkValid);
3995        }
3996
3997      }
3998
3999      @Override
4000      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
4001        switch (hash) {
4002        case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
4003        case 8911915: /*instantiatesCanonical*/ return this.instantiatesCanonical == null ? new Base[0] : this.instantiatesCanonical.toArray(new Base[this.instantiatesCanonical.size()]); // CanonicalType
4004        case -1926393373: /*instantiatesUri*/ return this.instantiatesUri == null ? new Base[0] : this.instantiatesUri.toArray(new Base[this.instantiatesUri.size()]); // UriType
4005        case -332612366: /*basedOn*/ return this.basedOn == null ? new Base[0] : this.basedOn.toArray(new Base[this.basedOn.size()]); // Reference
4006        case -430332865: /*replaces*/ return this.replaces == null ? new Base[0] : this.replaces.toArray(new Base[this.replaces.size()]); // Reference
4007        case -995410646: /*partOf*/ return this.partOf == null ? new Base[0] : this.partOf.toArray(new Base[this.partOf.size()]); // Reference
4008        case -892481550: /*status*/ return this.status == null ? new Base[0] : new Base[] {this.status}; // Enumeration<CarePlanStatus>
4009        case -1183762788: /*intent*/ return this.intent == null ? new Base[0] : new Base[] {this.intent}; // Enumeration<CarePlanIntent>
4010        case 50511102: /*category*/ return this.category == null ? new Base[0] : this.category.toArray(new Base[this.category.size()]); // CodeableConcept
4011        case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
4012        case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
4013        case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
4014        case 1524132147: /*encounter*/ return this.encounter == null ? new Base[0] : new Base[] {this.encounter}; // Reference
4015        case -991726143: /*period*/ return this.period == null ? new Base[0] : new Base[] {this.period}; // Period
4016        case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateTimeType
4017        case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
4018        case -1895276325: /*contributor*/ return this.contributor == null ? new Base[0] : this.contributor.toArray(new Base[this.contributor.size()]); // Reference
4019        case -7323378: /*careTeam*/ return this.careTeam == null ? new Base[0] : this.careTeam.toArray(new Base[this.careTeam.size()]); // Reference
4020        case -227148625: /*addressesCode*/ return this.addressesCode == null ? new Base[0] : this.addressesCode.toArray(new Base[this.addressesCode.size()]); // CodeableConcept
4021        case -1878992439: /*addressesReference*/ return this.addressesReference == null ? new Base[0] : this.addressesReference.toArray(new Base[this.addressesReference.size()]); // Reference
4022        case 1922406657: /*supportingInfo*/ return this.supportingInfo == null ? new Base[0] : this.supportingInfo.toArray(new Base[this.supportingInfo.size()]); // Reference
4023        case 3178259: /*goal*/ return this.goal == null ? new Base[0] : this.goal.toArray(new Base[this.goal.size()]); // Reference
4024        case -1655966961: /*activity*/ return this.activity == null ? new Base[0] : this.activity.toArray(new Base[this.activity.size()]); // CarePlanActivityComponent
4025        case 3387378: /*note*/ return this.note == null ? new Base[0] : this.note.toArray(new Base[this.note.size()]); // Annotation
4026        default: return super.getProperty(hash, name, checkValid);
4027        }
4028
4029      }
4030
4031      @Override
4032      public Base setProperty(int hash, String name, Base value) throws FHIRException {
4033        switch (hash) {
4034        case -1618432855: // identifier
4035          this.getIdentifier().add(castToIdentifier(value)); // Identifier
4036          return value;
4037        case 8911915: // instantiatesCanonical
4038          this.getInstantiatesCanonical().add(castToCanonical(value)); // CanonicalType
4039          return value;
4040        case -1926393373: // instantiatesUri
4041          this.getInstantiatesUri().add(castToUri(value)); // UriType
4042          return value;
4043        case -332612366: // basedOn
4044          this.getBasedOn().add(castToReference(value)); // Reference
4045          return value;
4046        case -430332865: // replaces
4047          this.getReplaces().add(castToReference(value)); // Reference
4048          return value;
4049        case -995410646: // partOf
4050          this.getPartOf().add(castToReference(value)); // Reference
4051          return value;
4052        case -892481550: // status
4053          value = new CarePlanStatusEnumFactory().fromType(castToCode(value));
4054          this.status = (Enumeration) value; // Enumeration<CarePlanStatus>
4055          return value;
4056        case -1183762788: // intent
4057          value = new CarePlanIntentEnumFactory().fromType(castToCode(value));
4058          this.intent = (Enumeration) value; // Enumeration<CarePlanIntent>
4059          return value;
4060        case 50511102: // category
4061          this.getCategory().add(castToCodeableConcept(value)); // CodeableConcept
4062          return value;
4063        case 110371416: // title
4064          this.title = castToString(value); // StringType
4065          return value;
4066        case -1724546052: // description
4067          this.description = castToString(value); // StringType
4068          return value;
4069        case -1867885268: // subject
4070          this.subject = castToReference(value); // Reference
4071          return value;
4072        case 1524132147: // encounter
4073          this.encounter = castToReference(value); // Reference
4074          return value;
4075        case -991726143: // period
4076          this.period = castToPeriod(value); // Period
4077          return value;
4078        case 1028554472: // created
4079          this.created = castToDateTime(value); // DateTimeType
4080          return value;
4081        case -1406328437: // author
4082          this.author = castToReference(value); // Reference
4083          return value;
4084        case -1895276325: // contributor
4085          this.getContributor().add(castToReference(value)); // Reference
4086          return value;
4087        case -7323378: // careTeam
4088          this.getCareTeam().add(castToReference(value)); // Reference
4089          return value;
4090        case -227148625: // addressesCode
4091          this.getAddressesCode().add(castToCodeableConcept(value)); // CodeableConcept
4092          return value;
4093        case -1878992439: // addressesReference
4094          this.getAddressesReference().add(castToReference(value)); // Reference
4095          return value;
4096        case 1922406657: // supportingInfo
4097          this.getSupportingInfo().add(castToReference(value)); // Reference
4098          return value;
4099        case 3178259: // goal
4100          this.getGoal().add(castToReference(value)); // Reference
4101          return value;
4102        case -1655966961: // activity
4103          this.getActivity().add((CarePlanActivityComponent) value); // CarePlanActivityComponent
4104          return value;
4105        case 3387378: // note
4106          this.getNote().add(castToAnnotation(value)); // Annotation
4107          return value;
4108        default: return super.setProperty(hash, name, value);
4109        }
4110
4111      }
4112
4113      @Override
4114      public Base setProperty(String name, Base value) throws FHIRException {
4115        if (name.equals("identifier")) {
4116          this.getIdentifier().add(castToIdentifier(value));
4117        } else if (name.equals("instantiatesCanonical")) {
4118          this.getInstantiatesCanonical().add(castToCanonical(value));
4119        } else if (name.equals("instantiatesUri")) {
4120          this.getInstantiatesUri().add(castToUri(value));
4121        } else if (name.equals("basedOn")) {
4122          this.getBasedOn().add(castToReference(value));
4123        } else if (name.equals("replaces")) {
4124          this.getReplaces().add(castToReference(value));
4125        } else if (name.equals("partOf")) {
4126          this.getPartOf().add(castToReference(value));
4127        } else if (name.equals("status")) {
4128          value = new CarePlanStatusEnumFactory().fromType(castToCode(value));
4129          this.status = (Enumeration) value; // Enumeration<CarePlanStatus>
4130        } else if (name.equals("intent")) {
4131          value = new CarePlanIntentEnumFactory().fromType(castToCode(value));
4132          this.intent = (Enumeration) value; // Enumeration<CarePlanIntent>
4133        } else if (name.equals("category")) {
4134          this.getCategory().add(castToCodeableConcept(value));
4135        } else if (name.equals("title")) {
4136          this.title = castToString(value); // StringType
4137        } else if (name.equals("description")) {
4138          this.description = castToString(value); // StringType
4139        } else if (name.equals("subject")) {
4140          this.subject = castToReference(value); // Reference
4141        } else if (name.equals("encounter")) {
4142          this.encounter = castToReference(value); // Reference
4143        } else if (name.equals("period")) {
4144          this.period = castToPeriod(value); // Period
4145        } else if (name.equals("created")) {
4146          this.created = castToDateTime(value); // DateTimeType
4147        } else if (name.equals("author")) {
4148          this.author = castToReference(value); // Reference
4149        } else if (name.equals("contributor")) {
4150          this.getContributor().add(castToReference(value));
4151        } else if (name.equals("careTeam")) {
4152          this.getCareTeam().add(castToReference(value));
4153        } else if (name.equals("addressesCode")) {
4154          this.getAddressesCode().add(castToCodeableConcept(value));
4155        } else if (name.equals("addressesReference")) {
4156          this.getAddressesReference().add(castToReference(value));
4157        } else if (name.equals("supportingInfo")) {
4158          this.getSupportingInfo().add(castToReference(value));
4159        } else if (name.equals("goal")) {
4160          this.getGoal().add(castToReference(value));
4161        } else if (name.equals("activity")) {
4162          this.getActivity().add((CarePlanActivityComponent) value);
4163        } else if (name.equals("note")) {
4164          this.getNote().add(castToAnnotation(value));
4165        } else
4166          return super.setProperty(name, value);
4167        return value;
4168      }
4169
4170      @Override
4171      public Base makeProperty(int hash, String name) throws FHIRException {
4172        switch (hash) {
4173        case -1618432855:  return addIdentifier(); 
4174        case 8911915:  return addInstantiatesCanonicalElement();
4175        case -1926393373:  return addInstantiatesUriElement();
4176        case -332612366:  return addBasedOn(); 
4177        case -430332865:  return addReplaces(); 
4178        case -995410646:  return addPartOf(); 
4179        case -892481550:  return getStatusElement();
4180        case -1183762788:  return getIntentElement();
4181        case 50511102:  return addCategory(); 
4182        case 110371416:  return getTitleElement();
4183        case -1724546052:  return getDescriptionElement();
4184        case -1867885268:  return getSubject();
4185        case 1524132147:  return getEncounter();
4186        case -991726143:  return getPeriod();
4187        case 1028554472:  return getCreatedElement();
4188        case -1406328437:  return getAuthor();
4189        case -1895276325:  return addContributor(); 
4190        case -7323378:  return addCareTeam(); 
4191        case -227148625:  return addAddressesCode(); 
4192        case -1878992439:  return addAddressesReference(); 
4193        case 1922406657:  return addSupportingInfo(); 
4194        case 3178259:  return addGoal(); 
4195        case -1655966961:  return addActivity(); 
4196        case 3387378:  return addNote(); 
4197        default: return super.makeProperty(hash, name);
4198        }
4199
4200      }
4201
4202      @Override
4203      public String[] getTypesForProperty(int hash, String name) throws FHIRException {
4204        switch (hash) {
4205        case -1618432855: /*identifier*/ return new String[] {"Identifier"};
4206        case 8911915: /*instantiatesCanonical*/ return new String[] {"canonical"};
4207        case -1926393373: /*instantiatesUri*/ return new String[] {"uri"};
4208        case -332612366: /*basedOn*/ return new String[] {"Reference"};
4209        case -430332865: /*replaces*/ return new String[] {"Reference"};
4210        case -995410646: /*partOf*/ return new String[] {"Reference"};
4211        case -892481550: /*status*/ return new String[] {"code"};
4212        case -1183762788: /*intent*/ return new String[] {"code"};
4213        case 50511102: /*category*/ return new String[] {"CodeableConcept"};
4214        case 110371416: /*title*/ return new String[] {"string"};
4215        case -1724546052: /*description*/ return new String[] {"string"};
4216        case -1867885268: /*subject*/ return new String[] {"Reference"};
4217        case 1524132147: /*encounter*/ return new String[] {"Reference"};
4218        case -991726143: /*period*/ return new String[] {"Period"};
4219        case 1028554472: /*created*/ return new String[] {"dateTime"};
4220        case -1406328437: /*author*/ return new String[] {"Reference"};
4221        case -1895276325: /*contributor*/ return new String[] {"Reference"};
4222        case -7323378: /*careTeam*/ return new String[] {"Reference"};
4223        case -227148625: /*addressesCode*/ return new String[] {"CodeableConcept"};
4224        case -1878992439: /*addressesReference*/ return new String[] {"Reference"};
4225        case 1922406657: /*supportingInfo*/ return new String[] {"Reference"};
4226        case 3178259: /*goal*/ return new String[] {"Reference"};
4227        case -1655966961: /*activity*/ return new String[] {};
4228        case 3387378: /*note*/ return new String[] {"Annotation"};
4229        default: return super.getTypesForProperty(hash, name);
4230        }
4231
4232      }
4233
4234      @Override
4235      public Base addChild(String name) throws FHIRException {
4236        if (name.equals("identifier")) {
4237          return addIdentifier();
4238        }
4239        else if (name.equals("instantiatesCanonical")) {
4240          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.instantiatesCanonical");
4241        }
4242        else if (name.equals("instantiatesUri")) {
4243          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.instantiatesUri");
4244        }
4245        else if (name.equals("basedOn")) {
4246          return addBasedOn();
4247        }
4248        else if (name.equals("replaces")) {
4249          return addReplaces();
4250        }
4251        else if (name.equals("partOf")) {
4252          return addPartOf();
4253        }
4254        else if (name.equals("status")) {
4255          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.status");
4256        }
4257        else if (name.equals("intent")) {
4258          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.intent");
4259        }
4260        else if (name.equals("category")) {
4261          return addCategory();
4262        }
4263        else if (name.equals("title")) {
4264          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.title");
4265        }
4266        else if (name.equals("description")) {
4267          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.description");
4268        }
4269        else if (name.equals("subject")) {
4270          this.subject = new Reference();
4271          return this.subject;
4272        }
4273        else if (name.equals("encounter")) {
4274          this.encounter = new Reference();
4275          return this.encounter;
4276        }
4277        else if (name.equals("period")) {
4278          this.period = new Period();
4279          return this.period;
4280        }
4281        else if (name.equals("created")) {
4282          throw new FHIRException("Cannot call addChild on a primitive type CarePlan.created");
4283        }
4284        else if (name.equals("author")) {
4285          this.author = new Reference();
4286          return this.author;
4287        }
4288        else if (name.equals("contributor")) {
4289          return addContributor();
4290        }
4291        else if (name.equals("careTeam")) {
4292          return addCareTeam();
4293        }
4294        else if (name.equals("addressesCode")) {
4295          return addAddressesCode();
4296        }
4297        else if (name.equals("addressesReference")) {
4298          return addAddressesReference();
4299        }
4300        else if (name.equals("supportingInfo")) {
4301          return addSupportingInfo();
4302        }
4303        else if (name.equals("goal")) {
4304          return addGoal();
4305        }
4306        else if (name.equals("activity")) {
4307          return addActivity();
4308        }
4309        else if (name.equals("note")) {
4310          return addNote();
4311        }
4312        else
4313          return super.addChild(name);
4314      }
4315
4316  public String fhirType() {
4317    return "CarePlan";
4318
4319  }
4320
4321      public CarePlan copy() {
4322        CarePlan dst = new CarePlan();
4323        copyValues(dst);
4324        return dst;
4325      }
4326
4327      public void copyValues(CarePlan dst) {
4328        super.copyValues(dst);
4329        if (identifier != null) {
4330          dst.identifier = new ArrayList<Identifier>();
4331          for (Identifier i : identifier)
4332            dst.identifier.add(i.copy());
4333        };
4334        if (instantiatesCanonical != null) {
4335          dst.instantiatesCanonical = new ArrayList<CanonicalType>();
4336          for (CanonicalType i : instantiatesCanonical)
4337            dst.instantiatesCanonical.add(i.copy());
4338        };
4339        if (instantiatesUri != null) {
4340          dst.instantiatesUri = new ArrayList<UriType>();
4341          for (UriType i : instantiatesUri)
4342            dst.instantiatesUri.add(i.copy());
4343        };
4344        if (basedOn != null) {
4345          dst.basedOn = new ArrayList<Reference>();
4346          for (Reference i : basedOn)
4347            dst.basedOn.add(i.copy());
4348        };
4349        if (replaces != null) {
4350          dst.replaces = new ArrayList<Reference>();
4351          for (Reference i : replaces)
4352            dst.replaces.add(i.copy());
4353        };
4354        if (partOf != null) {
4355          dst.partOf = new ArrayList<Reference>();
4356          for (Reference i : partOf)
4357            dst.partOf.add(i.copy());
4358        };
4359        dst.status = status == null ? null : status.copy();
4360        dst.intent = intent == null ? null : intent.copy();
4361        if (category != null) {
4362          dst.category = new ArrayList<CodeableConcept>();
4363          for (CodeableConcept i : category)
4364            dst.category.add(i.copy());
4365        };
4366        dst.title = title == null ? null : title.copy();
4367        dst.description = description == null ? null : description.copy();
4368        dst.subject = subject == null ? null : subject.copy();
4369        dst.encounter = encounter == null ? null : encounter.copy();
4370        dst.period = period == null ? null : period.copy();
4371        dst.created = created == null ? null : created.copy();
4372        dst.author = author == null ? null : author.copy();
4373        if (contributor != null) {
4374          dst.contributor = new ArrayList<Reference>();
4375          for (Reference i : contributor)
4376            dst.contributor.add(i.copy());
4377        };
4378        if (careTeam != null) {
4379          dst.careTeam = new ArrayList<Reference>();
4380          for (Reference i : careTeam)
4381            dst.careTeam.add(i.copy());
4382        };
4383        if (addressesCode != null) {
4384          dst.addressesCode = new ArrayList<CodeableConcept>();
4385          for (CodeableConcept i : addressesCode)
4386            dst.addressesCode.add(i.copy());
4387        };
4388        if (addressesReference != null) {
4389          dst.addressesReference = new ArrayList<Reference>();
4390          for (Reference i : addressesReference)
4391            dst.addressesReference.add(i.copy());
4392        };
4393        if (supportingInfo != null) {
4394          dst.supportingInfo = new ArrayList<Reference>();
4395          for (Reference i : supportingInfo)
4396            dst.supportingInfo.add(i.copy());
4397        };
4398        if (goal != null) {
4399          dst.goal = new ArrayList<Reference>();
4400          for (Reference i : goal)
4401            dst.goal.add(i.copy());
4402        };
4403        if (activity != null) {
4404          dst.activity = new ArrayList<CarePlanActivityComponent>();
4405          for (CarePlanActivityComponent i : activity)
4406            dst.activity.add(i.copy());
4407        };
4408        if (note != null) {
4409          dst.note = new ArrayList<Annotation>();
4410          for (Annotation i : note)
4411            dst.note.add(i.copy());
4412        };
4413      }
4414
4415      protected CarePlan typedCopy() {
4416        return copy();
4417      }
4418
4419      @Override
4420      public boolean equalsDeep(Base other_) {
4421        if (!super.equalsDeep(other_))
4422          return false;
4423        if (!(other_ instanceof CarePlan))
4424          return false;
4425        CarePlan o = (CarePlan) other_;
4426        return compareDeep(identifier, o.identifier, true) && compareDeep(instantiatesCanonical, o.instantiatesCanonical, true)
4427           && compareDeep(instantiatesUri, o.instantiatesUri, true) && compareDeep(basedOn, o.basedOn, true)
4428           && compareDeep(replaces, o.replaces, true) && compareDeep(partOf, o.partOf, true) && compareDeep(status, o.status, true)
4429           && compareDeep(intent, o.intent, true) && compareDeep(category, o.category, true) && compareDeep(title, o.title, true)
4430           && compareDeep(description, o.description, true) && compareDeep(subject, o.subject, true) && compareDeep(encounter, o.encounter, true)
4431           && compareDeep(period, o.period, true) && compareDeep(created, o.created, true) && compareDeep(author, o.author, true)
4432           && compareDeep(contributor, o.contributor, true) && compareDeep(careTeam, o.careTeam, true) && compareDeep(addressesCode, o.addressesCode, true)
4433           && compareDeep(addressesReference, o.addressesReference, true) && compareDeep(supportingInfo, o.supportingInfo, true)
4434           && compareDeep(goal, o.goal, true) && compareDeep(activity, o.activity, true) && compareDeep(note, o.note, true)
4435          ;
4436      }
4437
4438      @Override
4439      public boolean equalsShallow(Base other_) {
4440        if (!super.equalsShallow(other_))
4441          return false;
4442        if (!(other_ instanceof CarePlan))
4443          return false;
4444        CarePlan o = (CarePlan) other_;
4445        return compareValues(instantiatesUri, o.instantiatesUri, true) && compareValues(status, o.status, true)
4446           && compareValues(intent, o.intent, true) && compareValues(title, o.title, true) && compareValues(description, o.description, true)
4447           && compareValues(created, o.created, true);
4448      }
4449
4450      public boolean isEmpty() {
4451        return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(identifier, instantiatesCanonical
4452          , instantiatesUri, basedOn, replaces, partOf, status, intent, category, title
4453          , description, subject, encounter, period, created, author, contributor, careTeam
4454          , addressesCode, addressesReference, supportingInfo, goal, activity, note);
4455      }
4456
4457  @Override
4458  public ResourceType getResourceType() {
4459    return ResourceType.CarePlan;
4460   }
4461
4462 /**
4463   * Search parameter: <b>date</b>
4464   * <p>
4465   * Description: <b>Time period plan covers</b><br>
4466   * Type: <b>date</b><br>
4467   * Path: <b>CarePlan.period</b><br>
4468   * </p>
4469   */
4470  @SearchParamDefinition(name="date", path="CarePlan.period", description="Time period plan covers", type="date" )
4471  public static final String SP_DATE = "date";
4472 /**
4473   * <b>Fluent Client</b> search parameter constant for <b>date</b>
4474   * <p>
4475   * Description: <b>Time period plan covers</b><br>
4476   * Type: <b>date</b><br>
4477   * Path: <b>CarePlan.period</b><br>
4478   * </p>
4479   */
4480  public static final ca.uhn.fhir.rest.gclient.DateClientParam DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_DATE);
4481
4482 /**
4483   * Search parameter: <b>care-team</b>
4484   * <p>
4485   * Description: <b>Who's involved in plan?</b><br>
4486   * Type: <b>reference</b><br>
4487   * Path: <b>CarePlan.careTeam</b><br>
4488   * </p>
4489   */
4490  @SearchParamDefinition(name="care-team", path="CarePlan.careTeam", description="Who's involved in plan?", type="reference", target={CareTeam.class } )
4491  public static final String SP_CARE_TEAM = "care-team";
4492 /**
4493   * <b>Fluent Client</b> search parameter constant for <b>care-team</b>
4494   * <p>
4495   * Description: <b>Who's involved in plan?</b><br>
4496   * Type: <b>reference</b><br>
4497   * Path: <b>CarePlan.careTeam</b><br>
4498   * </p>
4499   */
4500  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CARE_TEAM = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CARE_TEAM);
4501
4502/**
4503   * Constant for fluent queries to be used to add include statements. Specifies
4504   * the path value of "<b>CarePlan:care-team</b>".
4505   */
4506  public static final ca.uhn.fhir.model.api.Include INCLUDE_CARE_TEAM = new ca.uhn.fhir.model.api.Include("CarePlan:care-team").toLocked();
4507
4508 /**
4509   * Search parameter: <b>identifier</b>
4510   * <p>
4511   * Description: <b>External Ids for this plan</b><br>
4512   * Type: <b>token</b><br>
4513   * Path: <b>CarePlan.identifier</b><br>
4514   * </p>
4515   */
4516  @SearchParamDefinition(name="identifier", path="CarePlan.identifier", description="External Ids for this plan", type="token" )
4517  public static final String SP_IDENTIFIER = "identifier";
4518 /**
4519   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
4520   * <p>
4521   * Description: <b>External Ids for this plan</b><br>
4522   * Type: <b>token</b><br>
4523   * Path: <b>CarePlan.identifier</b><br>
4524   * </p>
4525   */
4526  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
4527
4528 /**
4529   * Search parameter: <b>performer</b>
4530   * <p>
4531   * Description: <b>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.)</b><br>
4532   * Type: <b>reference</b><br>
4533   * Path: <b>CarePlan.activity.detail.performer</b><br>
4534   * </p>
4535   */
4536  @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", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient"), @ca.uhn.fhir.model.api.annotation.Compartment(name="Practitioner"), @ca.uhn.fhir.model.api.annotation.Compartment(name="RelatedPerson") }, target={CareTeam.class, Device.class, HealthcareService.class, Organization.class, Patient.class, Practitioner.class, PractitionerRole.class, RelatedPerson.class } )
4537  public static final String SP_PERFORMER = "performer";
4538 /**
4539   * <b>Fluent Client</b> search parameter constant for <b>performer</b>
4540   * <p>
4541   * Description: <b>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.)</b><br>
4542   * Type: <b>reference</b><br>
4543   * Path: <b>CarePlan.activity.detail.performer</b><br>
4544   * </p>
4545   */
4546  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PERFORMER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PERFORMER);
4547
4548/**
4549   * Constant for fluent queries to be used to add include statements. Specifies
4550   * the path value of "<b>CarePlan:performer</b>".
4551   */
4552  public static final ca.uhn.fhir.model.api.Include INCLUDE_PERFORMER = new ca.uhn.fhir.model.api.Include("CarePlan:performer").toLocked();
4553
4554 /**
4555   * Search parameter: <b>goal</b>
4556   * <p>
4557   * Description: <b>Desired outcome of plan</b><br>
4558   * Type: <b>reference</b><br>
4559   * Path: <b>CarePlan.goal</b><br>
4560   * </p>
4561   */
4562  @SearchParamDefinition(name="goal", path="CarePlan.goal", description="Desired outcome of plan", type="reference", target={Goal.class } )
4563  public static final String SP_GOAL = "goal";
4564 /**
4565   * <b>Fluent Client</b> search parameter constant for <b>goal</b>
4566   * <p>
4567   * Description: <b>Desired outcome of plan</b><br>
4568   * Type: <b>reference</b><br>
4569   * Path: <b>CarePlan.goal</b><br>
4570   * </p>
4571   */
4572  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam GOAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_GOAL);
4573
4574/**
4575   * Constant for fluent queries to be used to add include statements. Specifies
4576   * the path value of "<b>CarePlan:goal</b>".
4577   */
4578  public static final ca.uhn.fhir.model.api.Include INCLUDE_GOAL = new ca.uhn.fhir.model.api.Include("CarePlan:goal").toLocked();
4579
4580 /**
4581   * Search parameter: <b>subject</b>
4582   * <p>
4583   * Description: <b>Who the care plan is for</b><br>
4584   * Type: <b>reference</b><br>
4585   * Path: <b>CarePlan.subject</b><br>
4586   * </p>
4587   */
4588  @SearchParamDefinition(name="subject", path="CarePlan.subject", description="Who the care plan is for", type="reference", target={Group.class, Patient.class } )
4589  public static final String SP_SUBJECT = "subject";
4590 /**
4591   * <b>Fluent Client</b> search parameter constant for <b>subject</b>
4592   * <p>
4593   * Description: <b>Who the care plan is for</b><br>
4594   * Type: <b>reference</b><br>
4595   * Path: <b>CarePlan.subject</b><br>
4596   * </p>
4597   */
4598  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
4599
4600/**
4601   * Constant for fluent queries to be used to add include statements. Specifies
4602   * the path value of "<b>CarePlan:subject</b>".
4603   */
4604  public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("CarePlan:subject").toLocked();
4605
4606 /**
4607   * Search parameter: <b>replaces</b>
4608   * <p>
4609   * Description: <b>CarePlan replaced by this CarePlan</b><br>
4610   * Type: <b>reference</b><br>
4611   * Path: <b>CarePlan.replaces</b><br>
4612   * </p>
4613   */
4614  @SearchParamDefinition(name="replaces", path="CarePlan.replaces", description="CarePlan replaced by this CarePlan", type="reference", target={CarePlan.class } )
4615  public static final String SP_REPLACES = "replaces";
4616 /**
4617   * <b>Fluent Client</b> search parameter constant for <b>replaces</b>
4618   * <p>
4619   * Description: <b>CarePlan replaced by this CarePlan</b><br>
4620   * Type: <b>reference</b><br>
4621   * Path: <b>CarePlan.replaces</b><br>
4622   * </p>
4623   */
4624  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam REPLACES = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_REPLACES);
4625
4626/**
4627   * Constant for fluent queries to be used to add include statements. Specifies
4628   * the path value of "<b>CarePlan:replaces</b>".
4629   */
4630  public static final ca.uhn.fhir.model.api.Include INCLUDE_REPLACES = new ca.uhn.fhir.model.api.Include("CarePlan:replaces").toLocked();
4631
4632 /**
4633   * Search parameter: <b>instantiates-canonical</b>
4634   * <p>
4635   * Description: <b>Instantiates FHIR protocol or definition</b><br>
4636   * Type: <b>reference</b><br>
4637   * Path: <b>CarePlan.instantiatesCanonical</b><br>
4638   * </p>
4639   */
4640  @SearchParamDefinition(name="instantiates-canonical", path="CarePlan.instantiatesCanonical", description="Instantiates FHIR protocol or definition", type="reference", target={ActivityDefinition.class, Measure.class, OperationDefinition.class, PlanDefinition.class, Questionnaire.class } )
4641  public static final String SP_INSTANTIATES_CANONICAL = "instantiates-canonical";
4642 /**
4643   * <b>Fluent Client</b> search parameter constant for <b>instantiates-canonical</b>
4644   * <p>
4645   * Description: <b>Instantiates FHIR protocol or definition</b><br>
4646   * Type: <b>reference</b><br>
4647   * Path: <b>CarePlan.instantiatesCanonical</b><br>
4648   * </p>
4649   */
4650  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam INSTANTIATES_CANONICAL = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_INSTANTIATES_CANONICAL);
4651
4652/**
4653   * Constant for fluent queries to be used to add include statements. Specifies
4654   * the path value of "<b>CarePlan:instantiates-canonical</b>".
4655   */
4656  public static final ca.uhn.fhir.model.api.Include INCLUDE_INSTANTIATES_CANONICAL = new ca.uhn.fhir.model.api.Include("CarePlan:instantiates-canonical").toLocked();
4657
4658 /**
4659   * Search parameter: <b>part-of</b>
4660   * <p>
4661   * Description: <b>Part of referenced CarePlan</b><br>
4662   * Type: <b>reference</b><br>
4663   * Path: <b>CarePlan.partOf</b><br>
4664   * </p>
4665   */
4666  @SearchParamDefinition(name="part-of", path="CarePlan.partOf", description="Part of referenced CarePlan", type="reference", target={CarePlan.class } )
4667  public static final String SP_PART_OF = "part-of";
4668 /**
4669   * <b>Fluent Client</b> search parameter constant for <b>part-of</b>
4670   * <p>
4671   * Description: <b>Part of referenced CarePlan</b><br>
4672   * Type: <b>reference</b><br>
4673   * Path: <b>CarePlan.partOf</b><br>
4674   * </p>
4675   */
4676  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PART_OF = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PART_OF);
4677
4678/**
4679   * Constant for fluent queries to be used to add include statements. Specifies
4680   * the path value of "<b>CarePlan:part-of</b>".
4681   */
4682  public static final ca.uhn.fhir.model.api.Include INCLUDE_PART_OF = new ca.uhn.fhir.model.api.Include("CarePlan:part-of").toLocked();
4683
4684 /**
4685   * Search parameter: <b>encounter</b>
4686   * <p>
4687   * Description: <b>The Encounter during which this CarePlan was created</b><br>
4688   * Type: <b>reference</b><br>
4689   * Path: <b>CarePlan.encounter</b><br>
4690   * </p>
4691   */
4692  @SearchParamDefinition(name="encounter", path="CarePlan.encounter", description="The Encounter during which this CarePlan was created", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Encounter") }, target={Encounter.class } )
4693  public static final String SP_ENCOUNTER = "encounter";
4694 /**
4695   * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
4696   * <p>
4697   * Description: <b>The Encounter during which this CarePlan was created</b><br>
4698   * Type: <b>reference</b><br>
4699   * Path: <b>CarePlan.encounter</b><br>
4700   * </p>
4701   */
4702  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ENCOUNTER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ENCOUNTER);
4703
4704/**
4705   * Constant for fluent queries to be used to add include statements. Specifies
4706   * the path value of "<b>CarePlan:encounter</b>".
4707   */
4708  public static final ca.uhn.fhir.model.api.Include INCLUDE_ENCOUNTER = new ca.uhn.fhir.model.api.Include("CarePlan:encounter").toLocked();
4709
4710 /**
4711   * Search parameter: <b>intent</b>
4712   * <p>
4713   * Description: <b>proposal | plan | order | option | directive</b><br>
4714   * Type: <b>token</b><br>
4715   * Path: <b>CarePlan.intent</b><br>
4716   * </p>
4717   */
4718  @SearchParamDefinition(name="intent", path="CarePlan.intent", description="proposal | plan | order | option | directive", type="token" )
4719  public static final String SP_INTENT = "intent";
4720 /**
4721   * <b>Fluent Client</b> search parameter constant for <b>intent</b>
4722   * <p>
4723   * Description: <b>proposal | plan | order | option | directive</b><br>
4724   * Type: <b>token</b><br>
4725   * Path: <b>CarePlan.intent</b><br>
4726   * </p>
4727   */
4728  public static final ca.uhn.fhir.rest.gclient.TokenClientParam INTENT = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_INTENT);
4729
4730 /**
4731   * Search parameter: <b>activity-reference</b>
4732   * <p>
4733   * Description: <b>Activity details defined in specific resource</b><br>
4734   * Type: <b>reference</b><br>
4735   * Path: <b>CarePlan.activity.reference</b><br>
4736   * </p>
4737   */
4738  @SearchParamDefinition(name="activity-reference", path="CarePlan.activity.reference", description="Activity details defined in specific resource", type="reference", target={Appointment.class, CommunicationRequest.class, DeviceRequest.class, ImmunizationRecommendation.class, MedicationRequest.class, NutritionOrder.class, RequestGroup.class, ServiceRequest.class, Task.class, VisionPrescription.class } )
4739  public static final String SP_ACTIVITY_REFERENCE = "activity-reference";
4740 /**
4741   * <b>Fluent Client</b> search parameter constant for <b>activity-reference</b>
4742   * <p>
4743   * Description: <b>Activity details defined in specific resource</b><br>
4744   * Type: <b>reference</b><br>
4745   * Path: <b>CarePlan.activity.reference</b><br>
4746   * </p>
4747   */
4748  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTIVITY_REFERENCE = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTIVITY_REFERENCE);
4749
4750/**
4751   * Constant for fluent queries to be used to add include statements. Specifies
4752   * the path value of "<b>CarePlan:activity-reference</b>".
4753   */
4754  public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTIVITY_REFERENCE = new ca.uhn.fhir.model.api.Include("CarePlan:activity-reference").toLocked();
4755
4756 /**
4757   * Search parameter: <b>condition</b>
4758   * <p>
4759   * Description: <b>Health issues this plan addresses</b><br>
4760   * Type: <b>reference</b><br>
4761   * Path: <b>CarePlan.addressesReference</b><br>
4762   * </p>
4763   */
4764  @SearchParamDefinition(name="condition", path="CarePlan.addressesReference", description="Health issues this plan addresses", type="reference", target={Condition.class } )
4765  public static final String SP_CONDITION = "condition";
4766 /**
4767   * <b>Fluent Client</b> search parameter constant for <b>condition</b>
4768   * <p>
4769   * Description: <b>Health issues this plan addresses</b><br>
4770   * Type: <b>reference</b><br>
4771   * Path: <b>CarePlan.addressesReference</b><br>
4772   * </p>
4773   */
4774  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam CONDITION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_CONDITION);
4775
4776/**
4777   * Constant for fluent queries to be used to add include statements. Specifies
4778   * the path value of "<b>CarePlan:condition</b>".
4779   */
4780  public static final ca.uhn.fhir.model.api.Include INCLUDE_CONDITION = new ca.uhn.fhir.model.api.Include("CarePlan:condition").toLocked();
4781
4782 /**
4783   * Search parameter: <b>based-on</b>
4784   * <p>
4785   * Description: <b>Fulfills CarePlan</b><br>
4786   * Type: <b>reference</b><br>
4787   * Path: <b>CarePlan.basedOn</b><br>
4788   * </p>
4789   */
4790  @SearchParamDefinition(name="based-on", path="CarePlan.basedOn", description="Fulfills CarePlan", type="reference", target={CarePlan.class } )
4791  public static final String SP_BASED_ON = "based-on";
4792 /**
4793   * <b>Fluent Client</b> search parameter constant for <b>based-on</b>
4794   * <p>
4795   * Description: <b>Fulfills CarePlan</b><br>
4796   * Type: <b>reference</b><br>
4797   * Path: <b>CarePlan.basedOn</b><br>
4798   * </p>
4799   */
4800  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam BASED_ON = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_BASED_ON);
4801
4802/**
4803   * Constant for fluent queries to be used to add include statements. Specifies
4804   * the path value of "<b>CarePlan:based-on</b>".
4805   */
4806  public static final ca.uhn.fhir.model.api.Include INCLUDE_BASED_ON = new ca.uhn.fhir.model.api.Include("CarePlan:based-on").toLocked();
4807
4808 /**
4809   * Search parameter: <b>patient</b>
4810   * <p>
4811   * Description: <b>Who the care plan is for</b><br>
4812   * Type: <b>reference</b><br>
4813   * Path: <b>CarePlan.subject</b><br>
4814   * </p>
4815   */
4816  @SearchParamDefinition(name="patient", path="CarePlan.subject.where(resolve() is Patient)", description="Who the care plan is for", type="reference", providesMembershipIn={ @ca.uhn.fhir.model.api.annotation.Compartment(name="Patient") }, target={Patient.class } )
4817  public static final String SP_PATIENT = "patient";
4818 /**
4819   * <b>Fluent Client</b> search parameter constant for <b>patient</b>
4820   * <p>
4821   * Description: <b>Who the care plan is for</b><br>
4822   * Type: <b>reference</b><br>
4823   * Path: <b>CarePlan.subject</b><br>
4824   * </p>
4825   */
4826  public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
4827
4828/**
4829   * Constant for fluent queries to be used to add include statements. Specifies
4830   * the path value of "<b>CarePlan:patient</b>".
4831   */
4832  public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("CarePlan:patient").toLocked();
4833
4834 /**
4835   * Search parameter: <b>activity-date</b>
4836   * <p>
4837   * Description: <b>Specified date occurs within period specified by CarePlan.activity.detail.scheduled[x]</b><br>
4838   * Type: <b>date</b><br>
4839   * Path: <b>CarePlan.activity.detail.scheduled[x]</b><br>
4840   * </p>
4841   */
4842  @SearchParamDefinition(name="activity-date", path="CarePlan.activity.detail.scheduled", description="Specified date occurs within period specified by CarePlan.activity.detail.scheduled[x]", type="date" )
4843  public static final String SP_ACTIVITY_DATE = "activity-date";
4844 /**
4845   * <b>Fluent Client</b> search parameter constant for <b>activity-date</b>
4846   * <p>
4847   * Description: <b>Specified date occurs within period specified by CarePlan.activity.detail.scheduled[x]</b><br>
4848   * Type: <b>date</b><br>
4849   * Path: <b>CarePlan.activity.detail.scheduled[x]</b><br>
4850   * </p>
4851   */
4852  public static final ca.uhn.fhir.rest.gclient.DateClientParam ACTIVITY_DATE = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_ACTIVITY_DATE);
4853
4854 /**
4855   * Search parameter: <b>instantiates-uri</b>
4856   * <p>
4857   * Description: <b>Instantiates external protocol or definition</b><br>
4858   * Type: <b>uri</b><br>
4859   * Path: <b>CarePlan.instantiatesUri</b><br>
4860   * </p>
4861   */
4862  @SearchParamDefinition(name="instantiates-uri", path="CarePlan.instantiatesUri", description="Instantiates external protocol or definition", type="uri" )
4863  public static final String SP_INSTANTIATES_URI = "instantiates-uri";
4864 /**
4865   * <b>Fluent Client</b> search parameter constant for <b>instantiates-uri</b>
4866   * <p>
4867   * Description: <b>Instantiates external protocol or definition</b><br>
4868   * Type: <b>uri</b><br>
4869   * Path: <b>CarePlan.instantiatesUri</b><br>
4870   * </p>
4871   */
4872  public static final ca.uhn.fhir.rest.gclient.UriClientParam INSTANTIATES_URI = new ca.uhn.fhir.rest.gclient.UriClientParam(SP_INSTANTIATES_URI);
4873
4874 /**
4875   * Search parameter: <b>category</b>
4876   * <p>
4877   * Description: <b>Type of plan</b><br>
4878   * Type: <b>token</b><br>
4879   * Path: <b>CarePlan.category</b><br>
4880   * </p>
4881   */
4882  @SearchParamDefinition(name="category", path="CarePlan.category", description="Type of plan", type="token" )
4883  public static final String SP_CATEGORY = "category";
4884 /**
4885   * <b>Fluent Client</b> search parameter constant for <b>category</b>
4886   * <p>
4887   * Description: <b>Type of plan</b><br>
4888   * Type: <b>token</b><br>
4889   * Path: <b>CarePlan.category</b><br>
4890   * </p>
4891   */
4892  public static final ca.uhn.fhir.rest.gclient.TokenClientParam CATEGORY = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CATEGORY);
4893
4894 /**
4895   * Search parameter: <b>activity-code</b>
4896   * <p>
4897   * Description: <b>Detail type of activity</b><br>
4898   * Type: <b>token</b><br>
4899   * Path: <b>CarePlan.activity.detail.code</b><br>
4900   * </p>
4901   */
4902  @SearchParamDefinition(name="activity-code", path="CarePlan.activity.detail.code", description="Detail type of activity", type="token" )
4903  public static final String SP_ACTIVITY_CODE = "activity-code";
4904 /**
4905   * <b>Fluent Client</b> search parameter constant for <b>activity-code</b>
4906   * <p>
4907   * Description: <b>Detail type of activity</b><br>
4908   * Type: <b>token</b><br>
4909   * Path: <b>CarePlan.activity.detail.code</b><br>
4910   * </p>
4911   */
4912  public static final ca.uhn.fhir.rest.gclient.TokenClientParam ACTIVITY_CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_ACTIVITY_CODE);
4913
4914 /**
4915   * Search parameter: <b>status</b>
4916   * <p>
4917   * Description: <b>draft | active | on-hold | revoked | completed | entered-in-error | unknown</b><br>
4918   * Type: <b>token</b><br>
4919   * Path: <b>CarePlan.status</b><br>
4920   * </p>
4921   */
4922  @SearchParamDefinition(name="status", path="CarePlan.status", description="draft | active | on-hold | revoked | completed | entered-in-error | unknown", type="token" )
4923  public static final String SP_STATUS = "status";
4924 /**
4925   * <b>Fluent Client</b> search parameter constant for <b>status</b>
4926   * <p>
4927   * Description: <b>draft | active | on-hold | revoked | completed | entered-in-error | unknown</b><br>
4928   * Type: <b>token</b><br>
4929   * Path: <b>CarePlan.status</b><br>
4930   * </p>
4931   */
4932  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
4933
4934
4935}
4936