Kulcare Docs
DeveloperCare plansCare planFuture state

Episode of Care Implementation Plan

Status: Planned Priority: High Dependencies: None

Overview

An Episode of Care represents a longitudinal course of treatment spanning multiple encounters. It provides the container for grouping related clinical encounters into a cohesive treatment program.

Problem Statement

Current Limitation: Encounters exist independently without grouping into treatment programs.

Impact:

  • Physiotherapists cannot track progress across a 12-session rehab program
  • Therapists cannot monitor treatment goals over multiple sessions
  • Dietitians cannot measure outcomes across a weight management program
  • No way to track "sessions completed" vs "sessions planned"

Data Model

EpisodeOfCare Table

create_table :episodes_of_care do |t|
  t.references :patient, null: false, foreign_key: true
  t.references :clinic, null: false, foreign_key: true
  t.references :primary_provider, foreign_key: { to_table: :users }

  # Episode identification
  t.string :episode_type      # therapy | physio | nutrition | chronic_care
  t.string :status            # active | on_hold | completed | discharged
  t.string :reason            # chief complaint / referral reason
  t.string :title             # "Post-ACL Rehab" (optional display name)

  # Dates
  t.date :start_date
  t.date :end_date
  t.date :target_end_date

  # Session tracking
  t.integer :total_sessions_planned
  t.integer :sessions_completed, default: 0
  t.string :frequency         # weekly | biweekly | monthly | as_needed

  # Content
  t.text :long_term_goals
  t.text :discharge_summary
  t.jsonb :metadata, default: {}

  t.boolean :deleted, default: false
  t.timestamps
end

add_index :episodes_of_care, [:patient_id, :status]
add_index :episodes_of_care, [:clinic_id, :status]
add_index :episodes_of_care, :episode_type

Model Associations

class EpisodeOfCare < ApplicationRecord
  belongs_to :patient
  belongs_to :clinic
  belongs_to :primary_provider, class_name: 'User', optional: true

  has_many :encounters
  has_many :treatment_goals, dependent: :destroy
  has_many :progress_notes, dependent: :destroy

  enum status: {
    active: 'active',
    on_hold: 'on_hold',
    completed: 'completed',
    discharged: 'discharged'
  }

  enum episode_type: {
    therapy: 'therapy',
    physio: 'physio',
    nutrition: 'nutrition',
    chronic_care: 'chronic_care'
  }
end

Update Encounter Model

class Encounter < ApplicationRecord
  belongs_to :episode_of_care, optional: true  # Can be standalone

  # Existing associations remain unchanged
  belongs_to :patient
  belongs_to :clinic
  belongs_to :practitioner, polymorphic: true
end

# Migration
add_reference :encounters, :episode_of_care, foreign_key: true, null: true

TreatmentGoal Table

create_table :treatment_goals do |t|
  t.references :episode_of_care, null: false, foreign_key: true
  t.references :created_by, foreign_key: { to_table: :users }

  t.text :description
  t.string :status           # active | achieved | discontinued
  t.date :target_date
  t.date :achieved_date
  t.integer :progress_percentage, default: 0
  t.text :notes

  t.timestamps
end

API Endpoints

# Episode CRUD
GET    /api/v1/patients/:patient_id/episodes_of_care
POST   /api/v1/patients/:patient_id/episodes_of_care
GET    /api/v1/episodes_of_care/:id
PATCH  /api/v1/episodes_of_care/:id
DELETE /api/v1/episodes_of_care/:id

# Episode encounters
GET    /api/v1/episodes_of_care/:id/encounters
POST   /api/v1/episodes_of_care/:id/encounters

# Treatment goals
GET    /api/v1/episodes_of_care/:id/treatment_goals
POST   /api/v1/episodes_of_care/:id/treatment_goals
PATCH  /api/v1/episodes_of_care/:id/treatment_goals/:goal_id
DELETE /api/v1/episodes_of_care/:id/treatment_goals/:goal_id

# Progress notes
GET    /api/v1/episodes_of_care/:id/progress_notes
POST   /api/v1/episodes_of_care/:id/progress_notes

Frontend Components

New Components

ComponentPurpose
EpisodeListList all episodes for a patient
EpisodeDetailEpisode overview with progress, goals, sessions
EpisodeCreateCreate new treatment program
EpisodeProgressVisual progress tracking (sessions, goals)
TreatmentGoalManagerCRUD for treatment goals within Episode

Updated Components

ComponentUpdate
PatientSummaryDashboardAdd "Active Episodes" card
EncounterHistoryGroup by Episode (collapsible)
EncounterHeaderShow Episode badge if linked
EncounterCreateOption to link to existing Episode

UI/UX Design

Episode Detail View

+-----------------------------------------------------------+
| Episode: Post-ACL Rehab                [<- Back to LHR]   |
| Patient: John Doe                      [View Full LHR]    |
| --------------------------------------------------------- |
| Progress: ████████░░░░ 5/12 sessions                      |
| Frequency: Weekly | Started: Dec 1 | Target End: Feb 28   |
| --------------------------------------------------------- |
| Treatment Goals                        [+ Add Goal]       |
| +-------------------------------------------------------+ |
| | 1. Restore full ROM (90%)                   [Edit]    | |
| | 2. Return to sports activities (0%)         [Edit]    | |
| +-------------------------------------------------------+ |
| --------------------------------------------------------- |
| Sessions in this Episode               [+ Add Session]    |
| +-------------------------------------------------------+ |
| | Session 5 - Dec 24                  [Open Encounter]  | |
| | Session 4 - Dec 17                  [Open Encounter]  | |
| | Session 3 - Dec 10                  [Open Encounter]  | |
| | ...                                                   | |
| +-------------------------------------------------------+ |
+-----------------------------------------------------------+

LHR Active Episodes Card

+-----------------------------------------------------------+
| Active Episodes                          [View All ->]    |
| +-------------------------------------------------------+ |
| | Post-ACL Rehab (5/12)              [Open] [+ Session] | |
| | Anxiety Treatment (3/10)           [Open] [+ Session] | |
| +-------------------------------------------------------+ |
+-----------------------------------------------------------+

Implementation Steps

Phase 1: Database & Models

  1. Create EpisodeOfCare migration
  2. Create TreatmentGoal migration
  3. Create ProgressNote migration
  4. Add episode_of_care_id to encounters
  5. Create models with validations and scopes

Phase 2: Backend API

  1. Create EpisodesOfCareController
  2. Create TreatmentGoalsController
  3. Create serializers for Episode data
  4. Add Episode context to LHR endpoint response

Phase 3: Frontend Components

  1. Create Episode types and API hooks
  2. Build EpisodeList and EpisodeDetail components
  3. Build TreatmentGoalManager component
  4. Update EncounterCreate with Episode linking

Phase 4: LHR Integration

  1. Update PatientSummaryDashboard
  2. Update EncounterHistory with Episode grouping
  3. Add Episode filter to trends views

Backward Compatibility

  • Existing encounters: Continue to work without episode linking
  • Standalone encounters: Acute care, walk-ins remain standalone
  • Episode linking: Optional, not required
  • LHR aggregation: Shows all data regardless of episode grouping

On this page