// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
// SPDX-License-Identifier: Apache-2.0
/*
 * This is a generated file
 * Do not edit manually.
 */

import type { Annotation } from './Annotation.d.ts';
import type { Appointment } from './Appointment.d.ts';
import type { CareTeam } from './CareTeam.d.ts';
import type { CodeableConcept } from './CodeableConcept.d.ts';
import type { CommunicationRequest } from './CommunicationRequest.d.ts';
import type { Condition } from './Condition.d.ts';
import type { Device } from './Device.d.ts';
import type { DeviceRequest } from './DeviceRequest.d.ts';
import type { DiagnosticReport } from './DiagnosticReport.d.ts';
import type { DocumentReference } from './DocumentReference.d.ts';
import type { Encounter } from './Encounter.d.ts';
import type { Extension } from './Extension.d.ts';
import type { Goal } from './Goal.d.ts';
import type { Group } from './Group.d.ts';
import type { HealthcareService } from './HealthcareService.d.ts';
import type { Identifier } from './Identifier.d.ts';
import type { Location } from './Location.d.ts';
import type { Medication } from './Medication.d.ts';
import type { MedicationRequest } from './MedicationRequest.d.ts';
import type { Meta } from './Meta.d.ts';
import type { Narrative } from './Narrative.d.ts';
import type { NutritionOrder } from './NutritionOrder.d.ts';
import type { Observation } from './Observation.d.ts';
import type { Organization } from './Organization.d.ts';
import type { Patient } from './Patient.d.ts';
import type { Period } from './Period.d.ts';
import type { Practitioner } from './Practitioner.d.ts';
import type { PractitionerRole } from './PractitionerRole.d.ts';
import type { Quantity } from './Quantity.d.ts';
import type { Reference } from './Reference.d.ts';
import type { RelatedPerson } from './RelatedPerson.d.ts';
import type { RequestGroup } from './RequestGroup.d.ts';
import type { Resource } from './Resource.d.ts';
import type { ServiceRequest } from './ServiceRequest.d.ts';
import type { Substance } from './Substance.d.ts';
import type { Task } from './Task.d.ts';
import type { Timing } from './Timing.d.ts';
import type { VisionPrescription } from './VisionPrescription.d.ts';

/**
 * 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.
 */
export interface CarePlan {

  /**
   * This is a CarePlan resource
   */
  readonly resourceType: 'CarePlan';

  /**
   * The logical id of the resource, as used in the URL for the resource.
   * Once assigned, this value never changes.
   */
  id?: string;

  /**
   * The metadata about the resource. This is content that is maintained by
   * the infrastructure. Changes to the content might not always be
   * associated with version changes to the resource.
   */
  meta?: Meta;

  /**
   * A reference to a set of rules that were followed when the resource was
   * constructed, and which must be understood when processing the content.
   * Often, this is a reference to an implementation guide that defines the
   * special rules along with other profiles etc.
   */
  implicitRules?: string;

  /**
   * The base language in which the resource is written.
   */
  language?: string;

  /**
   * A human-readable narrative that contains a summary of the resource and
   * can be used to represent the content of the resource to a human. The
   * narrative need not encode all the structured data, but is required to
   * contain sufficient detail to make it &quot;clinically safe&quot; for a human to
   * just read the narrative. Resource definitions may define what content
   * should be represented in the narrative to ensure clinical safety.
   */
  text?: Narrative;

  /**
   * These resources do not have an independent existence apart from the
   * resource that contains them - they cannot be identified independently,
   * and nor can they have their own independent transaction scope.
   */
  contained?: Resource[];

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the resource. To make the use of extensions
   * safe and manageable, there is a strict set of governance  applied to
   * the definition and use of extensions. Though any implementer can
   * define an extension, there is a set of requirements that SHALL be met
   * as part of the definition of the extension.
   */
  extension?: Extension[];

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the resource and that modifies the
   * understanding of the element that contains it and/or the understanding
   * of the containing element's descendants. Usually modifier elements
   * provide negation or qualification. To make the use of extensions safe
   * and manageable, there is a strict set of governance applied to the
   * definition and use of extensions. Though any implementer is allowed to
   * define an extension, there is a set of requirements that SHALL be met
   * as part of the definition of the extension. Applications processing a
   * resource are required to check for modifier extensions.
   *
   * Modifier extensions SHALL NOT change the meaning of any elements on
   * Resource or DomainResource (including cannot change the meaning of
   * modifierExtension itself).
   */
  modifierExtension?: Extension[];

  /**
   * 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.
   */
  identifier?: Identifier[];

  /**
   * 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.
   */
  instantiatesCanonical?: string[];

  /**
   * 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.
   */
  instantiatesUri?: string[];

  /**
   * A care plan that is fulfilled in whole or in part by this care plan.
   */
  basedOn?: Reference<CarePlan>[];

  /**
   * Completed or terminated care plan whose function is taken by this new
   * care plan.
   */
  replaces?: Reference<CarePlan>[];

  /**
   * A larger care plan of which this particular care plan is a component
   * or step.
   */
  partOf?: Reference<CarePlan>[];

  /**
   * Indicates whether the plan is currently being acted upon, represents
   * future intentions or is now a historical record.
   */
  status: 'draft' | 'active' | 'on-hold' | 'revoked' | 'completed' | 'entered-in-error' | 'unknown';

  /**
   * Indicates the level of authority/intentionality associated with the
   * care plan and where the care plan fits into the workflow chain.
   */
  intent: 'proposal' | 'plan' | 'order' | 'option';

  /**
   * Identifies what &quot;kind&quot; of plan this is to support differentiation
   * between multiple co-existing plans; e.g. &quot;Home health&quot;, &quot;psychiatric&quot;,
   * &quot;asthma&quot;, &quot;disease management&quot;, &quot;wellness plan&quot;, etc.
   */
  category?: CodeableConcept[];

  /**
   * Human-friendly name for the care plan.
   */
  title?: string;

  /**
   * A description of the scope and nature of the plan.
   */
  description?: string;

  /**
   * Identifies the patient or group whose intended care is described by
   * the plan.
   */
  subject: Reference<Patient | Group>;

  /**
   * The Encounter during which this CarePlan was created or to which the
   * creation of this record is tightly associated.
   */
  encounter?: Reference<Encounter>;

  /**
   * Indicates when the plan did (or is intended to) come into effect and
   * end.
   */
  period?: Period;

  /**
   * Represents when this particular CarePlan record was created in the
   * system, which is often a system-generated date.
   */
  created?: string;

  /**
   * When populated, the author is responsible for the care plan.  The care
   * plan is attributed to the author.
   */
  author?: Reference<Patient | Practitioner | PractitionerRole | Device | RelatedPerson | Organization | CareTeam>;

  /**
   * Identifies the individual(s) or organization who provided the contents
   * of the care plan.
   */
  contributor?: Reference<Patient | Practitioner | PractitionerRole | Device | RelatedPerson | Organization | CareTeam>[];

  /**
   * Identifies all people and organizations who are expected to be
   * involved in the care envisioned by this plan.
   */
  careTeam?: Reference<CareTeam>[];

  /**
   * Identifies the conditions/problems/concerns/diagnoses/etc. whose
   * management and/or mitigation are handled by this plan.
   */
  addresses?: Reference<Condition>[];

  /**
   * 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.
   */
  supportingInfo?: Reference<Resource>[];

  /**
   * Describes the intended objective(s) of carrying out the care plan.
   */
  goal?: Reference<Goal>[];

  /**
   * Identifies a planned action to occur as part of the plan.  For
   * example, a medication to be used, lab tests to perform,
   * self-monitoring, education, etc.
   */
  activity?: CarePlanActivity[];

  /**
   * General notes about the care plan not covered elsewhere.
   */
  note?: Annotation[];
}

/**
 * Identifies a planned action to occur as part of the plan.  For
 * example, a medication to be used, lab tests to perform,
 * self-monitoring, education, etc.
 */
export interface CarePlanActivity {

  /**
   * Unique id for the element within a resource (for internal references).
   * This may be any string value that does not contain spaces.
   */
  id?: string;

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the element. To make the use of extensions
   * safe and manageable, there is a strict set of governance  applied to
   * the definition and use of extensions. Though any implementer can
   * define an extension, there is a set of requirements that SHALL be met
   * as part of the definition of the extension.
   */
  extension?: Extension[];

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the element and that modifies the
   * understanding of the element in which it is contained and/or the
   * understanding of the containing element's descendants. Usually
   * modifier elements provide negation or qualification. To make the use
   * of extensions safe and manageable, there is a strict set of governance
   * applied to the definition and use of extensions. Though any
   * implementer can define an extension, there is a set of requirements
   * that SHALL be met as part of the definition of the extension.
   * Applications processing a resource are required to check for modifier
   * extensions.
   *
   * Modifier extensions SHALL NOT change the meaning of any elements on
   * Resource or DomainResource (including cannot change the meaning of
   * modifierExtension itself).
   */
  modifierExtension?: Extension[];

  /**
   * 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).
   */
  outcomeCodeableConcept?: CodeableConcept[];

  /**
   * Details of the outcome or action resulting from the activity.  The
   * reference to an &quot;event&quot; 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 &ldquo;request&rdquo; resource).
   */
  outcomeReference?: Reference<Resource>[];

  /**
   * Notes about the adherence/status/progress of the activity.
   */
  progress?: Annotation[];

  /**
   * The details of the proposed activity represented in a specific
   * resource.
   */
  reference?: Reference<Appointment | CommunicationRequest | DeviceRequest | MedicationRequest | NutritionOrder | Task
      | ServiceRequest | VisionPrescription | RequestGroup>;

  /**
   * 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.
   */
  detail?: CarePlanActivityDetail;
}

/**
 * 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.
 */
export interface CarePlanActivityDetail {

  /**
   * Unique id for the element within a resource (for internal references).
   * This may be any string value that does not contain spaces.
   */
  id?: string;

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the element. To make the use of extensions
   * safe and manageable, there is a strict set of governance  applied to
   * the definition and use of extensions. Though any implementer can
   * define an extension, there is a set of requirements that SHALL be met
   * as part of the definition of the extension.
   */
  extension?: Extension[];

  /**
   * May be used to represent additional information that is not part of
   * the basic definition of the element and that modifies the
   * understanding of the element in which it is contained and/or the
   * understanding of the containing element's descendants. Usually
   * modifier elements provide negation or qualification. To make the use
   * of extensions safe and manageable, there is a strict set of governance
   * applied to the definition and use of extensions. Though any
   * implementer can define an extension, there is a set of requirements
   * that SHALL be met as part of the definition of the extension.
   * Applications processing a resource are required to check for modifier
   * extensions.
   *
   * Modifier extensions SHALL NOT change the meaning of any elements on
   * Resource or DomainResource (including cannot change the meaning of
   * modifierExtension itself).
   */
  modifierExtension?: Extension[];

  /**
   * 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.
   */
  kind?: 'Appointment' | 'CommunicationRequest' | 'DeviceRequest' | 'MedicationRequest' | 'NutritionOrder' | 'Task' | 'ServiceRequest' | 'VisionPrescription';

  /**
   * 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.
   */
  instantiatesCanonical?: string[];

  /**
   * 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.
   */
  instantiatesUri?: string[];

  /**
   * Detailed description of the type of planned activity; e.g. what lab
   * test, what procedure, what kind of encounter.
   */
  code?: 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.
   */
  reasonCode?: CodeableConcept[];

  /**
   * 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.
   */
  reasonReference?: Reference<Condition | Observation | DiagnosticReport | DocumentReference>[];

  /**
   * Internal reference that identifies the goals that this activity is
   * intended to contribute towards meeting.
   */
  goal?: Reference<Goal>[];

  /**
   * Identifies what progress is being made for the specific activity.
   */
  status: 'not-started' | 'scheduled' | 'in-progress' | 'on-hold' | 'completed' | 'cancelled' | 'stopped' | 'unknown' | 'entered-in-error';

  /**
   * Provides reason why the activity isn't yet started, is on hold, was
   * cancelled, etc.
   */
  statusReason?: CodeableConcept;

  /**
   * 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.
   */
  doNotPerform?: boolean;

  /**
   * The period, timing or frequency upon which the described activity is
   * to occur.
   */
  scheduledTiming?: Timing;

  /**
   * The period, timing or frequency upon which the described activity is
   * to occur.
   */
  scheduledPeriod?: Period;

  /**
   * The period, timing or frequency upon which the described activity is
   * to occur.
   */
  scheduledString?: string;

  /**
   * Identifies the facility where the activity will occur; e.g. home,
   * hospital, specific clinic, etc.
   */
  location?: Reference<Location>;

  /**
   * Identifies who's expected to be involved in the activity.
   */
  performer?: Reference<Practitioner | PractitionerRole | Organization | RelatedPerson | Patient | CareTeam | HealthcareService | Device>[];

  /**
   * Identifies the food, drug or other product to be consumed or supplied
   * in the activity.
   */
  productCodeableConcept?: CodeableConcept;

  /**
   * Identifies the food, drug or other product to be consumed or supplied
   * in the activity.
   */
  productReference?: Reference<Medication | Substance>;

  /**
   * Identifies the quantity expected to be consumed in a given day.
   */
  dailyAmount?: Quantity;

  /**
   * Identifies the quantity expected to be supplied, administered or
   * consumed by the subject.
   */
  quantity?: Quantity;

  /**
   * 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.
   */
  description?: string;
}

/**
 * The period, timing or frequency upon which the described activity is
 * to occur.
 */
export type CarePlanActivityDetailScheduled = Period | string | Timing;

/**
 * Identifies the food, drug or other product to be consumed or supplied
 * in the activity.
 */
export type CarePlanActivityDetailProduct = CodeableConcept | Reference<Medication | Substance>;
