feat: add elder bed operational context
This commit is contained in:
@@ -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.
|
||||
@@ -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.
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "elder-bed-context-optimization",
|
||||
"title": "老人床位联动优化",
|
||||
"description": "",
|
||||
"status": "planning",
|
||||
"status": "in_progress",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
|
||||
Reference in New Issue
Block a user