Harden API memory and CPU usage across Phases 19–22.
CI / changes (push) Successful in 17s
dotnet8-ci / build-and-test (push) Successful in 8m23s
CI / backend (push) Successful in 8m24s
node-ci / build (push) Failing after 2m1s
CI / frontend (push) Failing after 2m2s

Bound list/PDF payloads, stream MinIO I/O with cancellation, paginate history and FHIR $everything, tighten OCR lifetimes/buffers, and add phase tracking docs.
This commit is contained in:
2026-11-30 23:55:56 +08:00
parent 192cb36dc7
commit a17bc2b734
46 changed files with 1677 additions and 215 deletions
+110
View File
@@ -0,0 +1,110 @@
# Phase 18 — Surface Existing Unused APIs
## What exists
From [Phases 14–17](./phase-17-plan.md): redesigned UI chrome and screens.
Backend already provides capabilities the web UI underuses or does not expose:
| API | Controller | Current web usage |
|---|---|---|
| `GET /api/v1/digitization-batches/{id}/events` | [`DigitizationBatchesController`](../../VigilCareRecordsAPI/Controllers/DigitizationBatchesController.cs) | Not shown on workstation screens (history has embedded audit) |
| `GET /api/v1/work-queue/entry` | [`WorkQueueController`](../../VigilCareRecordsAPI/Controllers/WorkQueueController.cs) | Entry uses generic batch list + `assignedTo` |
| `GET /api/v1/work-queue/verification` | same | Verification filters `status: PENDING_VERIFICATION` via list |
| `GET /api/v1/work-queue/clinical-approval` | same | Approval filters status via list |
| `GET/POST/PATCH /api/v1/users`, reset-password | [`UsersController`](../../VigilCareRecordsAPI/Controllers/UsersController.cs) | List-by-role used for assign clerks; **no admin Users page** |
Design reference: [design-doc.md](../designs/design-doc.md) §§19, 30, 35 (Users under Administration — only where API exists).
## What needs to be built
Wire these existing endpoints into the redesigned UI. **No new backend endpoints or behavior.** This is the last phase of the UI redesign track.
---
## Step 1 — Batch audit / events panel
Add a collapsible **Audit trail** panel on Entry / Verification / Approval (and optionally Intake batch detail) that loads:
`GET digitization-batches/{id}/events?pageSize=…`
- Cursor pagination if `hasMore` / cursor returned
- Display: event type, actor, timestamp, relevant payload summary
- Matches design-doc §30 (actor, role if present, timestamp, state transitions)
Extend [`stores/batches.ts`](../../vigilcare-records-web/src/stores/batches.ts) with `fetchEvents(batchId, cursor?)`. Types in [`types/index.ts`](../../vigilcare-records-web/src/types/index.ts) as needed from API response shape.
---
## Step 2 — Dedicated work-queue fetches
Prefer age-sorted work queues for operator lists:
| Screen | Endpoint | Roles (API) |
|---|---|---|
| Data Entry queue | `work-queue/entry` | `DATA_ENTRY_CLERK`, `ADMINISTRATOR` |
| Verification queue | `work-queue/verification` | `VERIFIER`, `CLINICAL_APPROVER`, `ADMINISTRATOR` |
| Clinical Approval queue | `work-queue/clinical-approval` | `CLINICAL_APPROVER`, `ADMINISTRATOR` |
Implementation notes:
- Add store methods or thin API helpers; map response items into existing `BatchList` props
- Preserve open-batch-by-id routes (`/entry/:batchId`, etc.)
- Keep overview dashboard on `work-queue/overview` (already used)
Update batch store tests accordingly.
---
## Step 3 — Administrator Users page
New view e.g. [`UsersView.vue`](../../vigilcare-records-web/src/views/UsersView.vue):
- Route `/users`, `meta.roles: ['ADMINISTRATOR']`
- Sidebar link under Administration (or after FHIR Explorer) when `canSupervise` / admin role
- Features backed by existing API:
- List users (`GET /users`, optional `?role=`)
- Create user (`POST /users`)
- Update fullName / role / isActive (`PATCH /users/{id}`)
- Reset password (`POST /users/{id}/reset-password`)
- Optional: self-service change password via `POST /users/me/change-password` from profile menu (nice-to-have if time)
Use Phase 15 ConfirmDialog for reset-password. Forms: Phase 14 tokens.
Update router guards tests for the new route.
---
## Step 4 — Navigation and docs touch-up
- AppShell: add **Users** for administrators only
- Do **not** add Workload / Reports / Master Data / Configuration / Audit Logs links (still no APIs)
- Update [plans README](./README.md) status for Phase 18 → Done when complete; PRD status table when implementing (not required in this docs-only authoring pass)
---
## Success criteria
- [x] Events panel loads and paginates audit events for an open batch
- [x] Entry / Verification / Approval queues use `work-queue/*` endpoints (oldest-first behavior matches API)
- [x] `/users` admin CRUD + reset password works against running API for `ADMINISTRATOR`
- [x] Sidebar shows Users only for admin; no dead Supervision links
- [x] `npm test` passes; add tests for Users view and events/queue store methods
## Out of scope
- Everything in [README deferred table](./README.md#deferred-needs-new-api-or-product-scope)
- New reporting/analytics endpoints
- Changing SoD or promotion rules on the server
## Verification
1. `cd vigilcare-records-web && npm test`
2. Manual: open batch → Audit trail shows create/assign/submit/verify events from seed or fresh workflow
3. Manual: compare queue order to API (`curl` work-queue vs UI)
4. Manual: as admin, create user, patch role, reset password; as new user, log in
5. Confirm non-admin cannot open `/users` (guard redirect)
## Gate
UI redesign track complete when success criteria pass. Further work requires new product phases (API + UI) for deferred design-doc items.