9.6 KiB
9.6 KiB
Next Step - Feature Implementation Guide
Overview
This guide explains how to integrate the 5 new features into the main Next Step codebase.
Features Implemented
1. Treatment Milestone Tracker ✅
Files:
prisma/schema.prisma- Add TreatmentPlan and TreatmentMilestone modelssrc/app/(app)/treatment/page.tsx- Main treatment pagesrc/app/(app)/treatment/new/page.tsx- Create treatment plansrc/components/treatment/TreatmentProgress.tsx- Progress widgetsrc/components/treatment/TreatmentPlanForm.tsx- Form componentsrc/app/api/workspaces/[id]/treatment-plan/route.ts- API routessrc/app/api/workspaces/[id]/treatment-plan/complete-cycle/route.ts- Complete cycle
Integration Steps:
- Add models to schema.prisma
- Run
npm run db:migrate - Copy page files to app directory
- Copy component files
- Copy API routes
- Add navigation link to treatment page
2. Enhanced Symptom Tracking ✅
Files:
src/app/(app)/symptoms/page.tsx- Enhanced symptoms page (overwrite)src/components/symptoms/SymptomTrendChart.tsx- Trend visualizationsrc/components/symptoms/SymptomReportGenerator.tsx- PDF export
Integration Steps:
- Replace existing symptoms page with enhanced version
- Add new components
- Update SymptomQuickLog to include medication correlation
- Add API route for PDF generation
3. Caregiver Coordination ✅
Files:
prisma/schema.prisma- Add CareTask and HandoffNote modelssrc/app/(app)/care/page.tsx- Care coordination pagesrc/app/(app)/care/new-task/page.tsx- Create tasksrc/app/(app)/care/new-note/page.tsx- Create handoff notesrc/app/api/workspaces/[id]/care-tasks/route.ts- Task APIsrc/app/api/workspaces/[id]/handoff-notes/route.ts- Notes API
Integration Steps:
- Add models to schema
- Migrate database
- Copy page and component files
- Copy API routes
- Add navigation link
4. Emergency Quick Access Widget ✅
Files:
src/components/emergency/EmergencyWidget.tsx- Floating widgetsrc/app/(app)/layout.tsx- Add widget to layout
Integration Steps:
- Copy widget component
- Import and add to main app layout
- Ensure it appears on all pages
5. Calendar Integration ✅
Files:
prisma/schema.prisma- Add CalendarFeed modelsrc/components/calendar/CalendarIntegration.tsx- Settings componentsrc/app/api/workspaces/[id]/calendar-feed/route.ts- ICS feed APIsrc/app/(app)/settings/calendar/page.tsx- Settings page
Integration Steps:
- Add model to schema
- Migrate database
- Copy components and API routes
- Add to settings navigation
Database Schema Additions
Add these models to prisma/schema.prisma:
// ============================================
// TREATMENT MILESTONE TRACKER
// ============================================
model TreatmentPlan {
id String @id @default(cuid())
workspaceId String @unique
title String
totalCycles Int
currentCycle Int @default(0)
startDate DateTime?
estimatedEnd DateTime?
status String @default("ACTIVE")
cycleType String @default("WEEKLY")
cycleDays Int @default(7)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdById String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
createdBy User @relation(fields: [createdById], references: [id])
milestones TreatmentMilestone[]
@@index([workspaceId])
}
model TreatmentMilestone {
id String @id @default(cuid())
planId String
cycleNumber Int
date DateTime
status String @default("UPCOMING")
notes String?
sideEffects String?
celebratedAt DateTime?
createdAt DateTime @default(now())
plan TreatmentPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
@@index([planId])
@@index([planId, cycleNumber])
}
// ============================================
// CAREGIVER COORDINATION
// ============================================
model CareTask {
id String @id @default(cuid())
workspaceId String
title String
description String?
assignedToId String?
dueAt DateTime?
completedAt DateTime?
completedById String?
priority String @default("MEDIUM")
category String @default("GENERAL")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdById String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
assignedTo User? @relation("AssignedTasks", fields: [assignedToId], references: [id])
completedBy User? @relation("CompletedTasks", fields: [completedById], references: [id])
createdBy User @relation(fields: [createdById], references: [id])
@@index([workspaceId])
@@index([workspaceId, assignedToId])
@@index([workspaceId, completedAt])
}
model HandoffNote {
id String @id @default(cuid())
workspaceId String
content String
category String @default("GENERAL")
priority String @default("NORMAL")
expiresAt DateTime
createdById String
createdAt DateTime @default(now())
acknowledgedBy String[]
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
createdBy User @relation(fields: [createdById], references: [id])
@@index([workspaceId])
@@index([workspaceId, expiresAt])
}
// ============================================
// CALENDAR INTEGRATION
// ============================================
model CalendarFeed {
id String @id @default(cuid())
workspaceId String
token String @unique
includeMeds Boolean @default(false)
includeAppointments Boolean @default(true)
daysAhead Int @default(90)
createdAt DateTime @default(now())
lastAccessedAt DateTime?
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@index([token])
@@index([workspaceId])
}
Run migration:
npm run db:migrate
Navigation Updates
Add to Today Page Dashboard
Add this section to src/app/(app)/today/page.tsx:
{/* Treatment Progress */}
<section>
<div className="flex items-center justify-between mb-3">
<h2 className="text-lg font-semibold text-secondary-900">Treatment Progress</h2>
<button
onClick={() => router.push('/treatment')}
className="text-sm text-primary-600 font-medium flex items-center"
>
View all
<ChevronRight className="w-4 h-4" />
</button>
</div>
<TreatmentProgress
plan={treatmentPlan}
workspaceId={currentWorkspace.id}
compact
/>
</section>
Add to Settings Navigation
Add to src/app/(app)/settings/page.tsx:
<SettingsSection title="Integrations">
<SettingsItem
icon={<Calendar className="w-5 h-5" />}
label="Calendar Integration"
description="Sync appointments to your calendar"
href="/settings/calendar"
/>
</SettingsSection>
Dexie DB Updates
Add to src/lib/sync/db.ts:
export interface LocalTreatmentPlan {
id: string
workspaceId: string
title: string
totalCycles: number
currentCycle: number
startDate: string | null
estimatedEnd: string | null
status: string
cycleType: string
cycleDays: number
version: number
syncedAt: string
}
export interface LocalTreatmentMilestone {
id: string
planId: string
cycleNumber: number
date: string
status: string
notes?: string
sideEffects?: string
celebratedAt?: string
syncedAt: string
}
export interface LocalCareTask {
id: string
workspaceId: string
title: string
description?: string
assignedToId?: string
dueAt?: string
completedAt?: string
completedById?: string
priority: string
category: string
createdAt: string
updatedAt: string
}
export interface LocalHandoffNote {
id: string
workspaceId: string
content: string
category: string
priority: string
expiresAt: string
createdAt: string
acknowledgedBy: string[]
}
And add tables to NextStepDB:
treatmentPlans!: Table<LocalTreatmentPlan, string>
treatmentMilestones!: Table<LocalTreatmentMilestone, string>
careTasks!: Table<LocalCareTask, string>
handoffNotes!: Table<LocalHandoffNote, string>
calendarFeeds!: Table<any, string>
Update version:
this.version(3).stores({
// ... existing tables ...
treatmentPlans: 'id, workspaceId',
treatmentMilestones: 'id, planId, cycleNumber',
careTasks: 'id, workspaceId, assignedToId, completedAt',
handoffNotes: 'id, workspaceId, expiresAt',
calendarFeeds: 'id, workspaceId, token',
})
Testing Checklist
Treatment Milestone Tracker
- Create treatment plan
- View progress widget
- Complete a cycle
- See celebration modal
- Check milestone details
Enhanced Symptom Tracking
- Log symptom with details
- View trend charts
- Filter by symptom type
- Export PDF report
- Copy text summary
Caregiver Coordination
- Create care task
- Assign to caregiver
- Mark task complete
- Add handoff note
- Acknowledge note
Emergency Widget
- See floating button
- Click to open modal
- Quick dial buttons work
- Medical info displays
Calendar Integration
- Create calendar feed
- Copy feed URL
- Subscribe in calendar app
- Verify appointments sync
Notes
- All features maintain offline-first capability
- Follow existing patterns for auth and workspace access
- Use existing UI components and styling
- Add appropriate audit logging
- Handle VIEWER role restrictions