chore(task): archive 07-02-elder-bed-context-optimization

This commit is contained in:
2026-07-03 00:46:18 -07:00
parent 0ce8cb9644
commit 4a9a7351e3
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,72 @@
# Elder Bed Context Optimization Design
## Summary
Add read-only cross-module context to the existing elder and bed workspaces. The implementation should not merge workflows; it only surfaces concise recent signals from persisted admissions, care tasks, health records, and emergency incidents.
## Data Boundary
Use existing persisted tables:
- admissions / beds / rooms for current bed state.
- care_tasks for recent and active care execution.
- vital_records and health_anomaly_reviews for health context.
- system_incidents for safety/emergency context.
No schema change is required. `system_incidents` does not have elder/bed foreign keys yet, so emergency context is shown only when an incident's title, description, or source clearly mentions the elder name, bed code, or room label.
## Permission Boundary
Server pages decide which context to load:
- `admission:read` / `facility:read`: bed/admission context.
- `care:read`: recent care task context.
- `health:read`: health anomalies and latest vitals.
- `incident:read`: matching open/acknowledged emergency context.
Users without a permission should not receive that context in props.
## Server Helper
Add `modules/operations/server/context.ts`:
- `listElderBedContextData(input)`
- input:
- `organizationId`
- `permissions`
- `elders`
- `beds`
- `admissions`
- output:
- `elderContexts: Record<string, ElderOperationalContext>`
- `bedContexts: Record<string, BedOperationalContext>`
The helper should batch queries and keep bounded result sizes.
## UI Design
### Elder list
Add a compact "近期联动" column:
- current bed/admission is already shown in the bed column.
- show up to three concise lines:
- latest active/recent care task.
- latest health anomaly or vital summary.
- matching open/acknowledged emergency event.
- If no permitted context exists, show `-`.
### Bed workspace
Add an occupant context column to the bed status table:
- show current elder care level/status.
- show active/recent care task for that occupant.
- show matching emergency event for occupant or bed when present.
- Keep actions in the existing workflows; context is read-only.
## Compatibility
- Existing elder CRUD remains unchanged.
- Existing admission workflows remain unchanged.
- Client refresh continues to update elder/bed/admission tables; cross-module snippets are refreshed on page reload.

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,38 @@
# Implementation Plan
## 1. Start Task And Read Specs
- Start the Trellis task.
- Reuse existing frontend/backend specs.
- Preserve existing uncommitted UI cleanup in elder and bed components.
## 2. Types And Server Helper
- Add context DTO types in `modules/operations/types.ts`.
- Add `modules/operations/server/context.ts`.
- Batch-load care, health, and incident context based on permissions.
- Avoid fabricating emergency links; match text only when the persisted incident names the elder/bed/room.
## 3. Wire Pages
- Update `app/(app)/app/elders/page.tsx` to load and pass `elderContexts`.
- Update `app/(app)/app/beds/page.tsx` to load and pass `bedContexts`.
## 4. Update Client Components
- Extend `EldersClient` with optional `elderContexts`.
- Extend `BedsWorkspace` with optional `bedContexts`.
- Render compact read-only context lines.
- Preserve existing CRUD/admission behavior.
## 5. Verification
- `pnpm lint`
- `pnpm type-check`
- `pnpm test`
- `pnpm build`
## Rollback
- Remove operations context helper/types.
- Remove context props and columns from elder/bed clients/pages.

View File

@@ -0,0 +1,55 @@
# 老人床位联动优化
## Goal
Improve the existing elder and bed workspaces so operators can see relevant cross-module context without leaving the workflow: current admission, bed, recent care tasks, health abnormal records, and safety incidents.
## Confirmed Facts
- `老人档案` already supports persisted elder CRUD.
- `床位房间` already supports persisted room, bed, admission, transfer, and discharge workflows.
- Elder rows already show current active bed labels from admissions.
- Bed rows already show current elder names where occupied.
- Health, care, and emergency modules will add additional context after their child tasks.
## Requirements
- Add cross-module context to elder and bed surfaces only after the relevant underlying persisted data exists.
- Elder detail/edit surfaces should expose concise recent context:
- current bed/admission state
- recent care execution records
- recent health abnormalities or latest vital summary
- open safety/emergency incidents tied to the elder when available
- Bed workspace should expose concise current occupant context:
- elder status and care level
- active/recent care tasks for the occupant
- open safety/emergency incidents for the bed/occupant when available
- The UI should remain dense and operational; avoid nested cards or large explanatory blocks.
- Cross-module data must be read-only context unless the user is in that module's own workflow.
- Server data loading should stay scoped by active organization.
## Acceptance Criteria
- [ ] Elder pages show current bed/admission context from persisted data.
- [ ] Elder pages show recent health/care/emergency context once those records exist.
- [ ] Bed workspace shows current occupant context without requiring manual lookup.
- [ ] Cross-module context does not fabricate records when a module has no data.
- [ ] Unauthorized users do not see context that they lack permission to read.
- [ ] Existing elder CRUD and bed/admission workflows still work.
- [ ] `pnpm lint` passes.
- [ ] `pnpm type-check` passes.
- [ ] `pnpm build` passes.
## Dependencies
- Should run after health data management, care execution workspace, and emergency incident workspace have shipped basic persisted data.
## Out Of Scope
- Moving all workflows into a single giant elder detail page.
- Editing health/care/emergency records from elder or bed context panels.
- Replacing existing elder or bed workspace architecture.
## Open Questions
- None currently blocking planning.

View File

@@ -0,0 +1,26 @@
{
"id": "elder-bed-context-optimization",
"name": "elder-bed-context-optimization",
"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": {}
}