3.6 KiB
3.6 KiB
Care Execution Workspace Design
Summary
Replace the reserved /care module page with a real operational workspace backed by persisted care execution records. This task owns daily care execution only: task list, status movement, completion notes, and seeded examples.
Route Boundary
- Unscoped route:
app/(app)/app/care/page.tsx - Scoped route:
app/(app)/app/[organizationSlug]/care/page.tsx - Navigation item remains in the
运营group. - Permission should move from
elder:updateto explicit care permissions:care:readcare:manage
The unscoped page should:
- Load
getCurrentAuthContext(). - Redirect unauthenticated users to
/login. - Redirect users without
care:readto the workspace dashboard. - Require an active organization.
- Load care data through a focused server helper.
- Render a client workspace with
canManagebased oncare:manage.
Data Model
Add one MVP table: care_tasks.
idorganizationIdelderIdnullable, because some tasks can be room/public-area checks latertitlecareType:daily_care | meal | medication | rehab | inspection | cleaning | otherpriority:low | normal | high | urgentstatus:pending | in_progress | completed | cancelledscheduledAtassigneeLabelexecutionNotescompletedAtcreatedByAccountIdcompletedByAccountIdcreatedAtupdatedAt
Indexes:
(organizationId, status, priority)for queues.(organizationId, scheduledAt)for daily schedule ordering.
Server Helpers
Create modules/care/:
modules/care/types.ts- enum values, labels, DTOs, validators.
modules/care/server/operations.tslistCareExecutionData(organizationId: string)updateCareTaskStatus(input)
modules/care/components/CareWorkspaceClient.tsx- dense tabs/filters/table and status action dialogs.
Reads should batch the care tasks and elder names in one query shape. Mutations must filter by organizationId and update by task ID plus organization ID.
API Design
GET /api/care/tasks- permission:
care:read - response:
{ success: true; reason: string; data: CareExecutionData }
- permission:
PATCH /api/care/tasks/[id]- permission:
care:manage - request:
{ status: "pending" | "in_progress" | "completed" | "cancelled"; executionNotes?: string } - completion sets
completedAtandcompletedByAccountId - moving out of completed clears completion metadata
- records audit log
- permission:
All failures use { success: false; reason: string }.
UI Design
The care workspace should be operational and compact:
- Metrics: pending, in-progress, completed today, high/urgent.
- Filters: status, priority, care type, search by elder/title/assignee.
- Table columns: task, elder, type, priority, status, scheduled time, assignee, completed time, actions.
- Actions:
- pending -> start
- in-progress/pending -> complete with notes
- completed/cancelled are visible but not primary work queue items
- Users without
care:managecan view but action buttons are disabled or hidden.
Default Workspace Data
Extend seedDefaultWorkspaceData() with care tasks after seeded elders exist. Examples should cover:
- pending morning care
- in-progress rehabilitation or inspection
- completed meal/medication task
- urgent/high overdue-style task scheduled in the past
Compatibility And Rollback
- Existing
/app/careplaceholder is replaced only for this module. - New tables are additive; rollback is dropping generated care migration and removing
modules/care, care API routes, and route/page changes. - Dashboard integration remains out of scope until the dedicated dashboard task.