chore(task): archive 07-02-care-execution-workspace

This commit is contained in:
2026-07-03 00:35:13 -07:00
parent b6b15acc69
commit dddabc706c
6 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1,104 @@
# 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:update` to explicit care permissions:
- `care:read`
- `care:manage`
The unscoped page should:
1. Load `getCurrentAuthContext()`.
2. Redirect unauthenticated users to `/login`.
3. Redirect users without `care:read` to the workspace dashboard.
4. Require an active organization.
5. Load care data through a focused server helper.
6. Render a client workspace with `canManage` based on `care:manage`.
## Data Model
Add one MVP table: `care_tasks`.
- `id`
- `organizationId`
- `elderId` nullable, because some tasks can be room/public-area checks later
- `title`
- `careType`: `daily_care | meal | medication | rehab | inspection | cleaning | other`
- `priority`: `low | normal | high | urgent`
- `status`: `pending | in_progress | completed | cancelled`
- `scheduledAt`
- `assigneeLabel`
- `executionNotes`
- `completedAt`
- `createdByAccountId`
- `completedByAccountId`
- `createdAt`
- `updatedAt`
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.ts`
- `listCareExecutionData(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 }`
- `PATCH /api/care/tasks/[id]`
- permission: `care:manage`
- request: `{ status: "pending" | "in_progress" | "completed" | "cancelled"; executionNotes?: string }`
- completion sets `completedAt` and `completedByAccountId`
- moving out of completed clears completion metadata
- records audit log
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:manage` can 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/care` placeholder 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.

View File

@@ -0,0 +1 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}

View File

@@ -0,0 +1,61 @@
# Implementation Plan
## 1. Schema And Migration
- Add care enums and `care_tasks` table to `modules/core/server/schema.ts`.
- Add indexes for queue and schedule queries.
- Run `pnpm db:generate`.
- Review generated SQL.
## 2. Types And Permissions
- Add `care:read` and `care:manage` to `modules/core/types.ts`.
- Add permission definitions and default role grants in `modules/core/server/permissions.ts`.
- Move navigation `/care` permission to `care:read`.
- Add care DTOs, labels, and validators in `modules/care/types.ts`.
## 3. TDD API Tests
- Add `app/api/care/care-routes.test.ts` before implementation.
- Cover:
- list care tasks
- permission denial
- missing active organization
- start task
- complete task with notes
- invalid status
- missing/cross-organization task
## 4. Server Operations And API Routes
- Add `modules/care/server/operations.ts`.
- Add `GET /api/care/tasks`.
- Add `PATCH /api/care/tasks/[id]`.
- Use `requirePermission`, structured failures, organization scoping, and audit logs.
## 5. Workspace UI
- Replace `app/(app)/app/care/page.tsx` placeholder with real Server Component.
- Keep scoped route delegating to the unscoped route.
- Add `modules/care/components/CareWorkspaceClient.tsx`.
- Implement metrics, filters, table, and start/complete actions.
## 6. Default Workspace Data
- Extend `modules/core/server/default-workspace-data.ts` with care task examples tied to seeded elders.
- Keep seed insertion inside the first-run default workspace transaction.
## 7. Verification
- `pnpm test`
- `pnpm lint`
- `pnpm type-check`
- `pnpm db:generate`
- Review generated SQL.
- `pnpm build`
## Rollback Points
- Before migration generation: remove schema and care module files.
- After migration generation: remove generated care migration plus schema changes.
- After UI/API: remove care API routes, `modules/care`, page changes, permissions, nav permission change, and seed rows.

View File

@@ -0,0 +1,76 @@
# 护理服务执行工作台
## Goal
Replace the current `护理服务` placeholder with a real daily care execution workspace. The MVP unit is a persisted care task / service execution record, not a care-plan generation engine.
## Confirmed Facts
- `/app/care` currently renders `ModulePage` only.
- `/app/{organizationSlug}/care` delegates to the unscoped care page.
- Existing elder, bed, and admission data are persisted in Drizzle.
- Navigation already exposes `护理服务` under the operation group.
- Historical product direction includes care tasks, dispatch,巡检打卡, service records, and service evaluation.
## Requirements
- Add Drizzle-backed care execution records scoped by organization.
- Care records should link to a real elder where applicable.
- Care records should support at least:
- title/name
- care type
- priority
- status
- scheduled time or due time
- assignee label or executor label
- execution notes
- completed time
- Replace `/app/care` and `/app/{organizationSlug}/care` with a real workspace.
- The workspace should show summary metrics, filters, and a dense care task table/list.
- Operators must be able to filter by status, priority, care type, and elder/search terms.
- Authorized operators can mark care items as in progress and completed.
- Completion must persist notes and completion timestamp.
- Mutations must record audit logs.
- Default workspace seed data must include representative care examples covering multiple statuses and care types.
## Permissions
- Prefer explicit care permissions if adding new permissions is practical:
- `care:read`
- `care:manage`
- If scope needs to stay smaller, reuse existing `elder:update` temporarily only if documented in the design.
- Server-side permissions are required for all mutation APIs.
## Acceptance Criteria
- [ ] `/app/care` no longer renders the generic placeholder.
- [ ] `/app/{organizationSlug}/care` renders the same real care workspace.
- [ ] Care records are loaded from Drizzle and scoped to the active organization.
- [ ] Default seeded workspace includes care tasks tied to seeded elders.
- [ ] The UI shows pending, in-progress, completed, and overdue/high-priority examples.
- [ ] Authorized users can move a care item to in-progress and completed from the UI.
- [ ] Completed care items persist execution notes and completion time.
- [ ] Unauthorized mutation attempts return structured failures.
- [ ] Care mutations write audit log entries.
- [ ] `pnpm db:generate` is run if schema changes are made.
- [ ] `pnpm lint` passes.
- [ ] `pnpm type-check` passes.
- [ ] `pnpm build` passes.
## Dependencies
- Can start after or parallel with health management because it primarily depends on existing elder/admission data.
- Dashboard integration should wait until this task is complete.
## Out Of Scope
- Care plan template management.
- Automatic recurring task generation.
- Service billing or pricing.
- Family notifications.
- Mobile QR/NFC check-in.
- AI care recommendations.
## Open Questions
- None currently blocking planning.

View File

@@ -0,0 +1,26 @@
{
"id": "care-execution-workspace",
"name": "care-execution-workspace",
"title": "护理服务执行工作台",
"description": "",
"status": "completed",
"dev_type": null,
"scope": null,
"package": null,
"priority": "P2",
"creator": "TalexDreamSoul",
"assignee": "TalexDreamSoul",
"createdAt": "2026-07-02",
"completedAt": "2026-07-03",
"branch": null,
"base_branch": "main",
"worktree_path": null,
"commit": null,
"pr_url": null,
"subtasks": [],
"children": [],
"parent": "07-02-operations-module-roadmap",
"relatedFiles": [],
"notes": "",
"meta": {}
}