Harden API memory and CPU usage across Phases 19–22.
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:
@@ -0,0 +1,118 @@
|
||||
# VigilCare Records — Phase Plans
|
||||
|
||||
Implementation guides for the digitization platform. Product Phases **1–13 are complete** (API + initial workstation UI). Historical Phase 1–13 plan files are **not in this repository**; verification scripts under `scripts/` still reference those filenames for provenance only.
|
||||
|
||||
## UI redesign (Phases 14–18)
|
||||
|
||||
These phases redesign [`vigilcare-records-web`](../../vigilcare-records-web/) against the design specification. **No new backend behavior** — restyle, re-layout, and wire endpoints that already exist.
|
||||
|
||||
| Phase | Plan | Focus | Status |
|
||||
|---|---|---|---|
|
||||
| 14 | [phase-14-plan.md](./phase-14-plan.md) | Design tokens, app shell (sidebar), login | Planned |
|
||||
| 15 | [phase-15-plan.md](./phase-15-plan.md) | Shared UX primitives (status, OCR badges, SoD, sticky actions) | Planned |
|
||||
| 16 | [phase-16-plan.md](./phase-16-plan.md) | Entry / Verification / Clinical Approval workstation layouts | Planned |
|
||||
| 17 | [phase-17-plan.md](./phase-17-plan.md) | Intake, Cover Sheets, Live Capture, History, Dashboard, FHIR Explorer | Planned |
|
||||
| 18 | [phase-18-plan.md](./phase-18-plan.md) | Surface unused existing APIs (events, work queues, Users admin) | Done |
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
P14[Phase14_Tokens_Shell_Login]
|
||||
P15[Phase15_Shared_UX]
|
||||
P16[Phase16_Workstation]
|
||||
P17[Phase17_Support_Screens]
|
||||
P18[Phase18_Unused_APIs]
|
||||
P14 --> P15 --> P16 --> P17 --> P18
|
||||
```
|
||||
|
||||
Complete phases in order. Do not start Phase *N+1* until Phase *N* success criteria pass.
|
||||
|
||||
## Performance hardening (Phases 19–22)
|
||||
|
||||
Backend CPU/memory/reliability remediations from the VigilCareRecordsAPI performance audit. Master tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
|
||||
|
||||
| Phase | Plan | Focus | Status |
|
||||
|---|---|---|---|
|
||||
| 19 | [phase-19-plan.md](./phase-19-plan.md) | Bounds, AsNoTracking, slim GetDocument, FHIR serializer | Done |
|
||||
| 20 | [phase-20-plan.md](./phase-20-plan.md) | MinIO async/CT, history + `$everything` paging, overview aggregates | Done |
|
||||
| 21 | [phase-21-plan.md](./phase-21-plan.md) | OCR CT, Azure singleton client, buffer reductions, RawText cap | Done |
|
||||
| 22 | [phase-22-plan.md](./phase-22-plan.md) | Fuzzy Take cap, seed N+1/CT, PromoteAsync CT, ops notes | Done |
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
P19[Phase19_Bounds]
|
||||
P20[Phase20_Memory]
|
||||
P21[Phase21_OCR]
|
||||
P22[Phase22_Polish]
|
||||
P19 --> P20 --> P21 --> P22
|
||||
```
|
||||
|
||||
Prefer one PR per phase. Keep overview + phase-plan checklists updated in the same PR as the code.
|
||||
|
||||
## Design source of truth
|
||||
|
||||
- **Spec:** [../designs/design-doc.md](../designs/design-doc.md)
|
||||
- **Mockups:** PNG files in [`../designs/`](../designs/)
|
||||
- **Corrections override mockups:** design-doc §36 (no login role picker; no infra health on operator dashboard; OCR is assistive; consistent naming)
|
||||
|
||||
### Image → screen mapping
|
||||
|
||||
Rename mockup files when convenient so implementers do not rely on ChatGPT timestamps:
|
||||
|
||||
| Suggested name | Screen |
|
||||
|---|---|
|
||||
| `01-login.png` | Login |
|
||||
| `02-dashboard.png` | Queue / operator dashboard |
|
||||
| `03-intake.png` | Intake |
|
||||
| `04-data-entry.png` | Data Entry |
|
||||
| `05-verification.png` | Verification |
|
||||
| `06-clinical-approval.png` | Clinical Approval |
|
||||
| `07-live-capture.png` | Live Capture |
|
||||
| `08-patient-history.png` | Patient History |
|
||||
| `09-cover-sheets.png` | Cover Sheets (if present) |
|
||||
| `10-fhir-explorer.png` | FHIR Explorer (if present) |
|
||||
|
||||
Until renamed, match mockups to design-doc sections by visual content, then apply §36 corrections before implementing.
|
||||
|
||||
## Constraint (Phases 14–18)
|
||||
|
||||
Allowed:
|
||||
|
||||
- Visual system (colors, density, typography scale) — **keep Public Sans**; adopt navy/blue palette from design-doc
|
||||
- App shell and navigation labels for **existing routes**
|
||||
- Layout and copy changes on existing views
|
||||
- Frontend-only OCR badge thresholds and SoD UI mirroring API rules
|
||||
- Calling existing API endpoints the web UI underuses (`…/events`, `work-queue/*`, `users`)
|
||||
|
||||
Not allowed without a later phase / API work:
|
||||
|
||||
- New clinical or workflow backend rules
|
||||
- Fake metrics (API/Redis/MinIO uptime cards, MEWS panels without data)
|
||||
- SSO, forgot-password, password step-up unless already implemented
|
||||
- OCR bounding-box click-to-highlight (no coordinates in API)
|
||||
|
||||
## Deferred (needs new API or product scope)
|
||||
|
||||
Design-doc / mockup items **out of scope for Phases 14–18**:
|
||||
|
||||
| Item | Why deferred |
|
||||
|---|---|
|
||||
| Global ⌘K search across patients/batches/documents | No unified search API |
|
||||
| Notifications center | No notifications API |
|
||||
| Help Center | Content/product, not Records API |
|
||||
| Supervision: Workload, Reports, Queues (as separate BI) | Beyond `work-queue/overview` |
|
||||
| Master Data, Configuration, Audit Logs admin UIs | No dedicated admin APIs for config/master data |
|
||||
| Infra service-health widgets on dashboard | Health probes are ops, not operator UX |
|
||||
| Multi-document “18 of 76” batch progress | Batches are single-document today |
|
||||
| OCR region highlight on scan | No field coordinates in OCR payload |
|
||||
| Hospital SSO / Forgot password | Auth surface not implemented |
|
||||
| Live Capture password re-auth / critical alert MEWS cards | Not in live-capture API contract as mocked |
|
||||
|
||||
Track these in [../vigilcare-records-gap-analysis.md](../vigilcare-records-gap-analysis.md) or a future phase when APIs exist.
|
||||
|
||||
## Related docs
|
||||
|
||||
- [../vigilcare-records-prd.md](../vigilcare-records-prd.md) — product requirements and phase roadmap
|
||||
- [../digitization-workstation-guide.md](../digitization-workstation-guide.md) — operator workflows
|
||||
- [../vigilcare-records-gap-analysis.md](../vigilcare-records-gap-analysis.md) — hardening backlog
|
||||
- [performance-hardening-overview.md](./performance-hardening-overview.md) — Phases 19–22 audit finding tracker
|
||||
- [../../README.md](../../README.md) — API reference and quick start
|
||||
@@ -0,0 +1,70 @@
|
||||
# Performance Hardening Overview (Phases 19–22)
|
||||
|
||||
Master tracker for CPU/memory/reliability remediations identified in the VigilCareRecordsAPI static performance audit. Status values: `Not started` | `In progress` | `Done`.
|
||||
|
||||
**Do not invent runtime benchmarks.** Verify with code review, integration tests, and existing verification scripts. Measure with `dotnet-counters` / `dotnet-gcdump` only when validating Phase 20–21 under load.
|
||||
|
||||
## Phase map
|
||||
|
||||
| Audit phase | Product phase | Plan | Focus | Status |
|
||||
|---|---|---|---|---|
|
||||
| Phase 0 quick wins | **19** | [phase-19-plan.md](./phase-19-plan.md) | Bounds, tracking, over-fetch | Done |
|
||||
| Phase 1 memory safety | **20** | [phase-20-plan.md](./phase-20-plan.md) | MinIO buffering, history / `$everything` paging | Done |
|
||||
| Phase 2 OCR reliability | **21** | [phase-21-plan.md](./phase-21-plan.md) | OCR buffers, Azure client lifetime, cancellation | Done |
|
||||
| Phase 3 polish | **22** | [phase-22-plan.md](./phase-22-plan.md) | Fuzzy match cap, seed N+1, promote CT, ops notes | Done |
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
P19[Phase19_Bounds]
|
||||
P20[Phase20_Memory]
|
||||
P21[Phase21_OCR]
|
||||
P22[Phase22_Polish]
|
||||
P19 --> P20 --> P21 --> P22
|
||||
```
|
||||
|
||||
Complete phases in order. Prefer one PR per phase; keep the phase plan checklist and this overview in sync in the same PR.
|
||||
|
||||
## Finding → phase checklist
|
||||
|
||||
| # | Severity | Finding | Phase | Key files | Status |
|
||||
|---|---|---|---|---|---|
|
||||
| 1 | Critical | MinIO download full-buffer + sync `CopyTo` | 20 | `DocumentStorageService.cs` | Done |
|
||||
| 2 | High | OCR/PDF multiplies large in-memory copies | 21 | `ImagePreprocessor.cs`, `TesseractOcrService.cs`, `AzureDocumentOcrService.cs` | Done |
|
||||
| 3 | High | Unbounded patient digitization history | 20 | `DigitizationHistoryService.cs` | Done |
|
||||
| 4 | High | FHIR `$everything` loads all clinical rows | 20 | `FhirService.cs` | Done |
|
||||
| 5 | High | Unclamped `pageSize` on list/queue endpoints | 19 | `BatchService`, `WorkQueueService`, `CoverSheetService` | Done |
|
||||
| 6 | Medium | Azure OCR client scoped (handler churn) | 21 | `Program.cs`, `AzureDocumentOcrService.cs` | Done |
|
||||
| 7 | Medium | Missing CT on download / OCR / promote | 20–22 | storage, OCR, `PromotionService` | Done |
|
||||
| 8 | Medium | Unbounded cover-sheet batch PDF | 19 | `CoverSheetController`, `BatchPdfRequest` | Done |
|
||||
| 9 | Medium | 1 GB container limit / OCR peak RAM | 22 | `docker-compose.prod.yml`, this overview | Done |
|
||||
| 10 | Medium | FHIR Pretty serializer per response | 19 | `FhirJsonOutputFormatter.cs` | Done |
|
||||
| 11 | Medium | Missing `AsNoTracking` / over-fetch | 19 | batch, cover sheet, verification, promotion reads | Done |
|
||||
| 12 | Medium | Work-queue overview loads all pending timestamps | 20 | `WorkQueueService.cs` | Done |
|
||||
| 13 | Medium | Upload full buffer + `EnsureBucket` every time | 20 | `DocumentStorageService.cs`, bootstrap | Done |
|
||||
| 14 | Low–Med | Fuzzy match loads all same-DOB patients | 22 | `PromotionService.cs` | Done |
|
||||
| 15 | Low–Med | Seed bootstrap MinIO N+1 | 22 | `SeedDocumentStorage.cs` | Done |
|
||||
| 16 | Low | Tesseract engine per document | 21 | `TesseractOcrService.cs` | Done |
|
||||
|
||||
## Diagnostic notes (ops)
|
||||
|
||||
| Symptom | Tool |
|
||||
|---|---|
|
||||
| High working set / GC | `dotnet-counters` (`gc-heap-size`, `gen-2-gc-count`, `loh-size`, `working-set`); `dotnet-gcdump` |
|
||||
| Thread starvation / blocking | `dotnet-counters` (`threadpool-*`); `dotnet-trace` |
|
||||
| EF / large payloads | Response size checks; Npgsql/EF command logging at Warning in Production |
|
||||
| Container OOM | Correlate with concurrent document downloads + OCR; see Phase 22 ops note |
|
||||
|
||||
**Memory distinctions:** GC heap = managed; working set = process RSS (includes unmanaged Tesseract/ImageSharp/sockets). This hardening targets managed buffering and bounded queries first.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Premature GC / `DOTNET_gcServer` tuning without measured need
|
||||
- Unbounded Parallel / Channel fan-out
|
||||
- Replacing API document proxy with presigned-only delivery
|
||||
- Frontend redesign beyond consumers broken by history / `$everything` paging
|
||||
|
||||
## Related
|
||||
|
||||
- [phase-19-plan.md](./phase-19-plan.md) … [phase-22-plan.md](./phase-22-plan.md)
|
||||
- [../vigilcare-records-gap-analysis.md](../vigilcare-records-gap-analysis.md)
|
||||
- [../vigilcare-records-prd.md](../vigilcare-records-prd.md)
|
||||
@@ -0,0 +1,139 @@
|
||||
# Phase 14 — Design System, App Shell, and Login
|
||||
|
||||
## What exists
|
||||
|
||||
From Phases 7–13 (workstation UI):
|
||||
|
||||
- Teal primary palette + Public Sans in [`vigilcare-records-web/tailwind.config.js`](../../vigilcare-records-web/tailwind.config.js)
|
||||
- Global utilities in [`vigilcare-records-web/src/assets/main.css`](../../vigilcare-records-web/src/assets/main.css)
|
||||
- Top horizontal nav in [`AppHeader.vue`](../../vigilcare-records-web/src/components/AppHeader.vue) — each view embeds `<AppHeader title="…">`
|
||||
- Centered card login in [`LoginView.vue`](../../vigilcare-records-web/src/views/LoginView.vue) — username/password only (no role picker)
|
||||
- Role flags and default routes in [`stores/auth.ts`](../../vigilcare-records-web/src/stores/auth.ts) (`canIntake`, `canEntry`, `canVerify`, `canApprove`, `canLiveCapture`, `canSupervise`)
|
||||
- Routes in [`router/index.ts`](../../vigilcare-records-web/src/router/index.ts)
|
||||
|
||||
Design reference: [design-doc.md](../designs/design-doc.md) §§1–10, §35 (sidebar labels for **existing** routes only), §36 (login corrections).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Establish the visual foundation and application chrome so later phases only restyle content areas. **Keep Public Sans** (do not switch to Inter). Adopt the navy/blue token set from the design doc. Replace header-only navigation with a role-filtered left sidebar shell. Redesign login as a split brand + form layout without inventing auth features.
|
||||
|
||||
Do not start Phase 15 until tokens, shell, and login meet the success criteria below.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Design tokens in Tailwind + CSS
|
||||
|
||||
**[`tailwind.config.js`](../../vigilcare-records-web/tailwind.config.js)** — replace/extend `primary` and `clinical` to match design-doc §3:
|
||||
|
||||
| Token | Hex | Use |
|
||||
|---|---|---|
|
||||
| Navy / sidebar | `#08254A` | Sidebar, logo backdrop |
|
||||
| Primary blue | `#155EEF` | CTA, selected nav, links, focus |
|
||||
| Primary blue hover | `#0B4FD6` | Hover |
|
||||
| Soft blue | `#EEF4FF` | Selected rows, info panels |
|
||||
| Page background | `#F7F9FC` | App canvas |
|
||||
| Surface | `#FFFFFF` | Cards / panels |
|
||||
| Strong / body / secondary / disabled text | `#101828` / `#344054` / `#667085` / `#98A2B3` | Typography |
|
||||
| Border / strong border | `#E4E7EC` / `#D0D5DD` | Dividers |
|
||||
| Success / warning / error | per design-doc §3 Semantic | Status + clinical |
|
||||
|
||||
Keep `fontFamily.sans` as Public Sans.
|
||||
|
||||
**[`main.css`](../../vigilcare-records-web/src/assets/main.css)** — map existing utility classes (`.btn-primary`, `.form-input`, `.card`, `.status-badge`, `.app-header`, `.nav-link`, `.split-pane`) onto the new tokens so legacy class names still work during migration. Add CSS variables if helpful for non-Tailwind consumers:
|
||||
|
||||
```css
|
||||
:root {
|
||||
--vc-navy: #08254A;
|
||||
--vc-primary: #155EEF;
|
||||
--vc-primary-hover: #0B4FD6;
|
||||
--vc-bg: #F7F9FC;
|
||||
--vc-surface: #FFFFFF;
|
||||
/* … */
|
||||
}
|
||||
```
|
||||
|
||||
Radius: inputs/buttons ~6–8px; cards ~8–12px (design-doc §6). Shadows: minimal (design-doc §7).
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — `AppShell.vue` + page chrome
|
||||
|
||||
Create [`vigilcare-records-web/src/components/AppShell.vue`](../../vigilcare-records-web/src/components/AppShell.vue):
|
||||
|
||||
- Left sidebar (~240px, collapsible to icon rail): navy background, VigilCare Records logo, nav sections
|
||||
- Main column: optional thin top bar (page title slot, user name, Sign Out) + `<slot />` for page content
|
||||
- Login route must **not** use the shell
|
||||
|
||||
**Sidebar items — only existing routes**, filtered by auth flags:
|
||||
|
||||
| Label | Route | Flag |
|
||||
|---|---|---|
|
||||
| Intake | `/intake` | `canIntake` |
|
||||
| Cover Sheets | `/cover-sheets` | `canIntake` |
|
||||
| Data Entry | `/entry` | `canEntry` |
|
||||
| Verification | `/verification` | `canVerify` |
|
||||
| Clinical Approval | `/approval` | `canApprove` |
|
||||
| Live Capture | `/live-capture` | `canLiveCapture` |
|
||||
| Patient History | `/patients` | authenticated |
|
||||
| Queue Dashboard | `/dashboard` | `canSupervise` |
|
||||
| FHIR Explorer | `/fhir-explorer` | `canSupervise` |
|
||||
|
||||
Optional “Dashboard” label: for administrators, Queue Dashboard is the home; do **not** add empty Supervision/Admin destinations (Users lands in Phase 18).
|
||||
|
||||
Selected item: soft blue / primary treatment per design-doc §8. Collapse control at sidebar bottom.
|
||||
|
||||
**Migrate views:** either wrap each authenticated view in `<AppShell>` or introduce a layout route. Prefer a single authenticated layout so `AppHeader` can shrink to a title/actions bar or be removed.
|
||||
|
||||
Update [`AppHeader.vue`](../../vigilcare-records-web/src/components/AppHeader.vue) to stop duplicating nav links (title + actions only), or delete nav from it once shell owns navigation.
|
||||
|
||||
Update router/tests that assert on header nav links ([`__tests__/router/guards.test.ts`](../../vigilcare-records-web/src/__tests__/router/guards.test.ts) and view tests) as needed.
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Login redesign
|
||||
|
||||
**[`LoginView.vue`](../../vigilcare-records-web/src/views/LoginView.vue)** — two-column desktop layout (design-doc §10):
|
||||
|
||||
- **Left (~45%):** navy brand panel — logo, headline “Digitize. Verify. Trust.”, short subtext. Restrained illustration optional; avoid marketing feature clutter.
|
||||
- **Right:** centered auth card (≈420–460px) — username, password, Sign In. Keep existing `auth.login` flow.
|
||||
|
||||
**Must not include:** role selector, SSO button, forgot-password (unless those APIs exist — they do not).
|
||||
|
||||
Mobile: stack brand above form or show form-only.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Naming consistency in chrome
|
||||
|
||||
Use these labels everywhere in shell/header (design-doc §36):
|
||||
|
||||
- **Data Entry** (not “Entry”)
|
||||
- **Clinical Approval** (not “Approvals”)
|
||||
- **Queue Dashboard** (supervisor overview)
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [ ] Tailwind/CSS tokens match design-doc primary/neutral/semantic hex values; Public Sans unchanged
|
||||
- [ ] Authenticated pages render navy left sidebar; nav filtered by role; no dead links
|
||||
- [ ] Login is split layout; no role selector; existing seeded users still sign in
|
||||
- [ ] Existing Vitest suites pass (`cd vigilcare-records-web && npm test`) after test updates for shell/nav
|
||||
- [ ] Visual: white/gray surfaces, blue primary CTA, no purple SaaS gradient aesthetic
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Supervision nav (Workload, Reports, Master Data, Configuration, Audit Logs)
|
||||
- Users admin page (Phase 18)
|
||||
- Workstation density / sticky actions (Phase 15–16)
|
||||
- Restyling Intake/Entry forms beyond inheriting new button/input tokens
|
||||
|
||||
## Verification
|
||||
|
||||
1. `cd vigilcare-records-web && npm test`
|
||||
2. Manual: log in as `intake1`, `entry1`, `verifier1`, `approver1` (or seed equivalents), `clinician1`, admin — confirm sidebar items match role and default landing routes still work
|
||||
3. Manual: login page at desktop width shows brand + form; no role dropdown
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 15](./phase-15-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,129 @@
|
||||
# Phase 15 — Shared UX Primitives
|
||||
|
||||
## What exists
|
||||
|
||||
From [Phase 14](./phase-14-plan.md): design tokens, `AppShell`, redesigned login.
|
||||
|
||||
Still fragmented across views:
|
||||
|
||||
- Status rendering via ad-hoc Tailwind classes / `.status-badge` in lists and forms
|
||||
- OCR assist via [`useOcrFieldConfidence.ts`](../../vigilcare-records-web/src/composables/useOcrFieldConfidence.ts) (thresholds 0.85 / 0.7) and banners in [`EntryForm.vue`](../../vigilcare-records-web/src/components/EntryForm.vue) / [`VerificationForm.vue`](../../vigilcare-records-web/src/components/VerificationForm.vue)
|
||||
- SoD: Verification subtitle shows truncated `enteredByUserId` only ([`VerificationView.vue`](../../vigilcare-records-web/src/views/VerificationView.vue))
|
||||
- Toasts: [`ToastContainer.vue`](../../vigilcare-records-web/src/components/ToastContainer.vue) + [`useToast.ts`](../../vigilcare-records-web/src/composables/useToast.ts)
|
||||
- Empty/loading: inconsistent per view (`BatchList` loading text, etc.)
|
||||
|
||||
Design reference: [design-doc.md](../designs/design-doc.md) §§9, 14 (OCR), 15 (SoD), 26–29, 31.
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Reusable components and composables that Phases 16–17 apply. Prefer shared primitives over one-off markup. Frontend-only threshold tweaks for OCR badges are allowed; no API changes.
|
||||
|
||||
Do not start Phase 16 until these primitives exist and have basic tests.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Status badge system
|
||||
|
||||
Create e.g. [`StatusBadge.vue`](../../vigilcare-records-web/src/components/StatusBadge.vue):
|
||||
|
||||
- Input: batch `status` string (`UPLOADED`, `IN_ENTRY`, `PENDING_VERIFICATION`, `AWAITING_CLINICAL_APPROVAL`, `VERIFIED`, `APPROVED`, `PROMOTED`, `REJECTED`, `CANCELLED`, …)
|
||||
- Output: label (humanized) + semantic color + optional icon
|
||||
- Must not rely on color alone (icon or text prefix)
|
||||
|
||||
Wire into [`BatchList.vue`](../../vigilcare-records-web/src/components/BatchList.vue) and any header chips that show status.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Empty, loading, error patterns
|
||||
|
||||
Create small presentational components (names flexible):
|
||||
|
||||
| Component | Behavior |
|
||||
|---|---|
|
||||
| `EmptyState.vue` | Operational copy (“No batches are waiting for verification.”) + optional CTA |
|
||||
| `SkeletonBlock.vue` / row skeletons | Prefer over full-page spinner (design-doc §27) |
|
||||
| `InlineError.vue` | What happened / what was preserved / Retry action (design-doc §28) |
|
||||
|
||||
Apply to queue lists as the first consumer; other views adopt in Phase 16–17.
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Sticky workstation action bar
|
||||
|
||||
Create e.g. [`WorkstationActionBar.vue`](../../vigilcare-records-web/src/components/WorkstationActionBar.vue):
|
||||
|
||||
- Sticky bottom of the form/panel column
|
||||
- Slots: `left` (e.g. Reject), `center` (Save Draft), `primary` (Submit…), `right` (Next)
|
||||
- Uses Phase 14 primary/destructive button styles
|
||||
|
||||
Not wired into Entry/Verification/Approval until Phase 16 — but component + Story/test fixture ready.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — OCR field badges
|
||||
|
||||
Update [`useOcrFieldConfidence.ts`](../../vigilcare-records-web/src/composables/useOcrFieldConfidence.ts):
|
||||
|
||||
- Expose numeric confidence and a badge label helper (`OCR 98%`) in addition to CSS class
|
||||
- Align thresholds with design-doc §14 (recommended): **95–100%** subtle green, **80–94%** amber, **<80%** strong warning (adjust from current 0.85 / 0.7)
|
||||
|
||||
Update Entry/Verification forms to show compact badges beside fields when `ocrConfidence.fieldConfidences[path]` exists. Banner copy must say OCR is assistive, not authoritative (e.g. “Pre-filled by OCR — review against the scan”).
|
||||
|
||||
**Out of this step:** click-to-highlight regions on the scan (no coordinates in API).
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — Separation of Duties banner
|
||||
|
||||
Create e.g. [`SeparationOfDutiesBanner.vue`](../../vigilcare-records-web/src/components/SeparationOfDutiesBanner.vue):
|
||||
|
||||
Props: `enteredByUserId`, `enteredByUserName?`, `currentUserId`, `currentUserName?`
|
||||
|
||||
- When IDs differ: restrained info banner — “Separation of Duties Enforced” + entered by / current verifier
|
||||
- When same: blocking message — “You cannot verify a batch you entered.” Emit/`disabled` flag for parent to disable Pass actions
|
||||
|
||||
Use `enteredByUserId` from batch detail today; names optional until API/history provides them.
|
||||
|
||||
Unit-test both states.
|
||||
|
||||
---
|
||||
|
||||
## Step 6 — Confirmation dialog pattern
|
||||
|
||||
Create e.g. [`ConfirmDialog.vue`](../../vigilcare-records-web/src/components/ConfirmDialog.vue) for **meaningful** actions only:
|
||||
|
||||
- Approve & Promote
|
||||
- Reject batch / return for rework
|
||||
- Cancel batch / delete unsubmitted upload (if used)
|
||||
|
||||
Props: title, body, confirmLabel, variant (`primary` | `danger`). Do not use for harmless navigation.
|
||||
|
||||
Approval copy must state promotion into live clinical tables (design-doc §16).
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [ ] `StatusBadge` covers all batch statuses used in the UI
|
||||
- [ ] Empty/skeleton/error components exist and are used at least on one queue list
|
||||
- [ ] `WorkstationActionBar` renders sticky with slots; documented for Phase 16
|
||||
- [ ] OCR badges show percentage + threshold colors; banner is non-authoritative
|
||||
- [ ] SoD banner blocks same-user verify in UI (in addition to API 409)
|
||||
- [ ] Confirm dialog used for at least one destructive/irreversible path or ready with tests
|
||||
- [ ] `npm test` passes; new component tests under `src/__tests__/components/`
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Full Entry/Verification/Approval layout redesign (Phase 16)
|
||||
- Batch events audit panel (Phase 18)
|
||||
- Changing verification/approval API contracts
|
||||
|
||||
## Verification
|
||||
|
||||
1. `cd vigilcare-records-web && npm test`
|
||||
2. Manual: open a batch with OCR confidence (OCR enabled env) — badges visible
|
||||
3. Manual: as entry clerk who entered a batch, open verification for that batch — SoD banner + disabled Pass (if seed allows; else unit test covers)
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 16](./phase-16-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,138 @@
|
||||
# Phase 16 — Core Digitization Workstation (Entry, Verification, Approval)
|
||||
|
||||
## What exists
|
||||
|
||||
From [Phase 14](./phase-14-plan.md) + [Phase 15](./phase-15-plan.md): shell, tokens, shared primitives.
|
||||
|
||||
Workstation screens today:
|
||||
|
||||
| View | Files | Layout |
|
||||
|---|---|---|
|
||||
| Data Entry | [`EntryView.vue`](../../vigilcare-records-web/src/views/EntryView.vue), [`EntryForm.vue`](../../vigilcare-records-web/src/components/EntryForm.vue) | Queue list **or** scan + form split |
|
||||
| Verification | [`VerificationView.vue`](../../vigilcare-records-web/src/views/VerificationView.vue), [`VerificationForm.vue`](../../vigilcare-records-web/src/components/VerificationForm.vue) | Same pattern |
|
||||
| Clinical Approval | [`ApprovalView.vue`](../../vigilcare-records-web/src/views/ApprovalView.vue) | Same pattern + approval panel |
|
||||
| Scan | [`ScanViewer.vue`](../../vigilcare-records-web/src/components/ScanViewer.vue) | Document iframe/blob |
|
||||
|
||||
Stores/API: [`stores/batches.ts`](../../vigilcare-records-web/src/stores/batches.ts) — draft CRUD, submit, verify, reject, approve. **Do not change endpoint contracts.**
|
||||
|
||||
Design reference: [design-doc.md](../designs/design-doc.md) §§14–16, §22 (density), §34 (evidence hierarchy).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Redesign the three high-risk screens for dense, scan-first workflows. Same store methods and routes. Apply Phase 15 SoD, OCR badges, sticky action bars, status badges, confirm dialogs.
|
||||
|
||||
Do not start Phase 17 until Entry, Verification, and Clinical Approval meet success criteria.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Shared workstation layout pattern
|
||||
|
||||
Introduce a consistent layout (component or shared structure in each view):
|
||||
|
||||
1. **Optional left rail:** queue / document list (when useful) — can show assigned/pending items while a batch is open, without new APIs (reuse current list payloads)
|
||||
2. **Center:** source scan (`ScanViewer`) — dominant evidence (Level 1)
|
||||
3. **Right:** structured form / draft / clinical summary — Levels 2–4
|
||||
|
||||
Queue-only mode (no `batchId`) remains a full-width list with EmptyState/skeletons.
|
||||
|
||||
Target desktop width ≥1280px; do not force phone layouts for these flows (design-doc §32).
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Scan viewer chrome
|
||||
|
||||
Polish [`ScanViewer.vue`](../../vigilcare-records-web/src/components/ScanViewer.vue):
|
||||
|
||||
- Neutral page surface, subtle page shadow only
|
||||
- Controls: zoom, fit width (keep existing capabilities; add only if trivial)
|
||||
- Loading/error via Phase 15 patterns
|
||||
- No decorative overlays or “AI confidence” chrome on the image itself
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Data Entry
|
||||
|
||||
**[`EntryView.vue`](../../vigilcare-records-web/src/views/EntryView.vue) / [`EntryForm.vue`](../../vigilcare-records-web/src/components/EntryForm.vue):**
|
||||
|
||||
- Dense form sections driven by existing `fieldRequirements` (unchanged logic)
|
||||
- OCR badges + assistive banner (Phase 15)
|
||||
- Sticky `WorkstationActionBar`:
|
||||
- Left: reject/flag if already supported; otherwise omit
|
||||
- Center: Save Draft (existing autosave/save)
|
||||
- Primary: **Submit for Verification**
|
||||
- Right: optional next-batch navigation if list context exists
|
||||
- Autosave feedback per design-doc §9 (use existing save behavior; improve visible “Last saved” if data available)
|
||||
|
||||
Update tests in [`__tests__/components/EntryForm.test.ts`](../../vigilcare-records-web/src/__tests__/components/EntryForm.test.ts).
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Verification
|
||||
|
||||
**[`VerificationView.vue`](../../vigilcare-records-web/src/views/VerificationView.vue) / [`VerificationForm.vue`](../../vigilcare-records-web/src/components/VerificationForm.vue):**
|
||||
|
||||
- Mount `SeparationOfDutiesBanner`; disable Pass when same user
|
||||
- Source scan + draft with validation markers remain primary; avoid analytics chrome
|
||||
- Sticky actions:
|
||||
- **Pass Verification** when pass selected
|
||||
- **Return for Rework** when reject selected (with reason — existing reject flow)
|
||||
- Avoid generic “Submit Decision” labeling
|
||||
- Confirm dialog for reject if not already modal-confirmed
|
||||
|
||||
Update [`__tests__/components/VerificationForm.test.ts`](../../vigilcare-records-web/src/__tests__/components/VerificationForm.test.ts).
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — Clinical Approval
|
||||
|
||||
**[`ApprovalView.vue`](../../vigilcare-records-web/src/views/ApprovalView.vue):**
|
||||
|
||||
- Visually distinct from verification (stronger clinical framing, not a clone with purple chip only)
|
||||
- Show scan + verified draft summary; highlight high-stakes fields from existing draft data when present
|
||||
- Retroactive alerts toggle: keep existing `enableRetroactiveAlerts` behavior; copy per design-doc §16
|
||||
- Primary: **Approve & Promote** via `ConfirmDialog` stating promotion to live clinical tables
|
||||
- Destructive: **Reject Batch** with reason
|
||||
- Post-success: show promotion result if already returned by API (`promotion-result` / approve response fields) — polish presentation only
|
||||
|
||||
---
|
||||
|
||||
## Step 6 — Evidence hierarchy (copy + visual weight)
|
||||
|
||||
Across all three screens, reinforce design-doc §34:
|
||||
|
||||
1. Source scan
|
||||
2. Entered / verified structured data
|
||||
3. Verification / approval decision controls
|
||||
4. Promotion outcome
|
||||
|
||||
Do not let secondary panels overpower the scan or draft.
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [ ] Entry, Verification, Approval use shell + dense split layout; sticky CTAs with design-doc labels
|
||||
- [ ] SoD enforced in Verification UI; OCR badges on Entry/Verification when confidence present
|
||||
- [ ] Approve & Promote uses confirmation copy about live promotion
|
||||
- [ ] No new API calls beyond what stores already perform (except optional read-only list for queue rail using existing list/queue fetch)
|
||||
- [ ] Component/view tests updated and `npm test` passes
|
||||
- [ ] Manual: walk upload→entry→verify→approve on seed data still works end-to-end
|
||||
|
||||
## Out of scope
|
||||
|
||||
- OCR region click-to-highlight
|
||||
- Multi-document batch progress (18/76)
|
||||
- Switching queues to `work-queue/*` endpoints (Phase 18)
|
||||
- Batch events audit panel (Phase 18)
|
||||
- Intake / Live Capture / Dashboard restyle (Phase 17)
|
||||
|
||||
## Verification
|
||||
|
||||
1. `cd vigilcare-records-web && npm test`
|
||||
2. Manual E2E with seeded users through Entry → Verification → Clinical Approval
|
||||
3. Manual: same-user verify attempt shows SoD block
|
||||
4. Spot-check against design-doc §§14–16 (ignore mockup infra/analytics clutter)
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 17](./phase-17-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,128 @@
|
||||
# Phase 17 — Supporting Screens
|
||||
|
||||
## What exists
|
||||
|
||||
From [Phases 14–16](./phase-16-plan.md): shell, tokens, primitives, redesigned Entry/Verification/Approval.
|
||||
|
||||
Supporting views still use pre-redesign layout density and teal-era patterns (they inherit tokens if Phase 14 remapped utilities, but structure/copy need alignment):
|
||||
|
||||
| View | File | Role |
|
||||
|---|---|---|
|
||||
| Intake | [`IntakeView.vue`](../../vigilcare-records-web/src/views/IntakeView.vue) | Upload, cover sheet lookup, assign |
|
||||
| Cover Sheets | [`CoverSheetView.vue`](../../vigilcare-records-web/src/views/CoverSheetView.vue) | Generate / list / PDF |
|
||||
| Live Capture | [`LiveCaptureView.vue`](../../vigilcare-records-web/src/views/LiveCaptureView.vue) | Bedside observations |
|
||||
| Patient History | [`PatientHistoryView.vue`](../../vigilcare-records-web/src/views/PatientHistoryView.vue) | Digitization timeline |
|
||||
| Queue Dashboard | [`QueueDashboardView.vue`](../../vigilcare-records-web/src/views/QueueDashboardView.vue) | `work-queue/overview` |
|
||||
| FHIR Explorer | [`FhirExplorerView.vue`](../../vigilcare-records-web/src/views/FhirExplorerView.vue) | FHIR read UI |
|
||||
|
||||
Design reference: [design-doc.md](../designs/design-doc.md) §§11–13, 17–20; §36 (dashboard: work first, no infra health).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Restyle and restructure these screens with **existing data and actions only**. No fake metrics, SSO, MEWS, or multi-doc chrome.
|
||||
|
||||
Do not start Phase 18 until these screens meet success criteria.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Intake
|
||||
|
||||
**[`IntakeView.vue`](../../vigilcare-records-web/src/views/IntakeView.vue)** (design-doc §12):
|
||||
|
||||
- Main column (~70%): upload zone + batch details (type, track, patient link, cover sheet code) — existing fields
|
||||
- Right (~30%): recent uploads / guidance
|
||||
- States: idle, uploading, success, error via Phase 15 patterns
|
||||
- Keep assign clerk dialog ([`AssignClerkDialog.vue`](../../vigilcare-records-web/src/components/AssignClerkDialog.vue))
|
||||
|
||||
Update [`__tests__/views/IntakeView.test.ts`](../../vigilcare-records-web/src/__tests__/views/IntakeView.test.ts) as needed.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Cover Sheets
|
||||
|
||||
**[`CoverSheetView.vue`](../../vigilcare-records-web/src/views/CoverSheetView.vue)** (design-doc §13):
|
||||
|
||||
- Generation form + preview + existing list table
|
||||
- Clear primary CTA for generate / print PDF (existing endpoints)
|
||||
- StatusBadge for any status columns
|
||||
- Update [`__tests__/views/CoverSheetView.test.ts`](../../vigilcare-records-web/src/__tests__/views/CoverSheetView.test.ts)
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Live Capture
|
||||
|
||||
**[`LiveCaptureView.vue`](../../vigilcare-records-web/src/views/LiveCaptureView.vue)** (design-doc §17):
|
||||
|
||||
- Keep New / Existing encounter modes and attestation checkbox flows already implemented
|
||||
- Clearer section hierarchy: patient → encounter → observations → attestation → submit
|
||||
- **Do not add:** password re-entry step, MEWS/critical alert side panels, fake “submission outcome” cards without API data
|
||||
- Prefer table density for observations consistent with Phase 14 tokens
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Patient History
|
||||
|
||||
**[`PatientHistoryView.vue`](../../vigilcare-records-web/src/views/PatientHistoryView.vue)** (design-doc §18):
|
||||
|
||||
- Search + timeline using existing digitization-history payload
|
||||
- StatusBadge for batch statuses
|
||||
- Audit trail presentation: actor / timestamp / event type already in payload — improve readability
|
||||
- Promotion attribution: show names/roles from history response; do not invent “entry clerk promoted” if data shows approver (design-doc §36)
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — Queue Dashboard
|
||||
|
||||
**[`QueueDashboardView.vue`](../../vigilcare-records-web/src/views/QueueDashboardView.vue)** (design-doc §§11, 19; §36):
|
||||
|
||||
Data source remains `GET work-queue/overview` only:
|
||||
|
||||
- `statusCounts`
|
||||
- `averageTimeInQueueMinutes`
|
||||
- `rejectRate`
|
||||
- `oldestPendingVerificationMinutes`
|
||||
- Existing batch list section if already loaded via batch list API
|
||||
|
||||
**Prioritize work metrics** (pending entry, in entry, pending verification, oldest age, reject rate).
|
||||
|
||||
**Must not add:** PostgreSQL / Redis / MinIO / FHIR API uptime cards, vanity trend sparklines without data, Quick Actions that deep-link nowhere.
|
||||
|
||||
Supervisor framing is fine; this is the administrator dashboard today (`canSupervise`).
|
||||
|
||||
---
|
||||
|
||||
## Step 6 — FHIR Explorer
|
||||
|
||||
**[`FhirExplorerView.vue`](../../vigilcare-records-web/src/views/FhirExplorerView.vue)** (design-doc §20):
|
||||
|
||||
- Visual polish only: shell, typography, tables, JSON panel
|
||||
- Keep existing fhirClient behavior
|
||||
- Update [`__tests__/views/FhirExplorerView.test.ts`](../../vigilcare-records-web/src/__tests__/views/FhirExplorerView.test.ts) if selectors change
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [ ] All six views render inside AppShell with consistent tokens
|
||||
- [ ] Intake/Cover Sheets usable for existing upload/generate flows
|
||||
- [ ] Live Capture submit/attestation still works; no invented clinical alert UI
|
||||
- [ ] Dashboard shows only overview-backed metrics (no infra health)
|
||||
- [ ] Patient History timeline/audit readable; StatusBadges applied
|
||||
- [ ] FHIR Explorer functional parity preserved
|
||||
- [ ] `npm test` passes
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Users admin, batch events panel, work-queue endpoint swap (Phase 18)
|
||||
- Global search, notifications, reports, master data
|
||||
- Changing Live Capture API to require password confirm if not already required by backend
|
||||
|
||||
## Verification
|
||||
|
||||
1. `cd vigilcare-records-web && npm test`
|
||||
2. Manual smoke per role: intake upload, cover sheet generate, live capture observation, patient search/history, admin dashboard refresh, FHIR metadata/search
|
||||
3. Confirm dashboard has **no** service-uptime widgets
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 18](./phase-18-plan.md) until success criteria above are met.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,87 @@
|
||||
# Phase 19 — Bounds and Read-Path Hygiene
|
||||
|
||||
## What exists
|
||||
|
||||
- List endpoints accept `page` / `pageSize` without a service-layer clamp: [`BatchService.ListAsync`](../../VigilCareRecordsAPI/Services/BatchService.cs), [`WorkQueueService.BuildQueueResponseAsync`](../../VigilCareRecordsAPI/Services/WorkQueueService.cs), [`CoverSheetService.ListAsync`](../../VigilCareRecordsAPI/Services/CoverSheetService.cs). [`BatchEventService`](../../VigilCareRecordsAPI/Services/BatchEventService.cs) already clamps to 200.
|
||||
- Cover-sheet create clamps `Count` to 100; [`GenerateBatchPdf`](../../VigilCareRecordsAPI/Controllers/CoverSheetController.cs) accepts unbounded [`BatchPdfRequest.CoverSheetIds`](../../VigilCareRecordsAPI/Models/Records/CoverSheet/BatchPdfRequest.cs).
|
||||
- Read queries often omit `AsNoTracking`; [`VerificationService.VerifyAsync`](../../VigilCareRecordsAPI/Services/VerificationService.cs) includes unused `Events`.
|
||||
- [`GetDocument`](../../VigilCareRecordsAPI/Controllers/DigitizationBatchesController.cs) calls full [`GetByIdAsync`](../../VigilCareRecordsAPI/Services/BatchService.cs) (drafts + observations).
|
||||
- [`FhirJsonOutputFormatter`](../../VigilCareRecordsAPI/Infrastructure/Fhir/FhirJsonOutputFormatter.cs) constructs a Pretty serializer per response.
|
||||
|
||||
Tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Prevent single-request memory/CPU blowups and cut unnecessary EF tracking and over-fetch. Low risk; no MinIO/OCR/history pagination in this phase.
|
||||
|
||||
Do not start [Phase 20](./phase-20-plan.md) until success criteria below pass.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Clamp pagination in services
|
||||
|
||||
In `BatchService.ListAsync`, `WorkQueueService.BuildQueueResponseAsync`, and `CoverSheetService.ListAsync`:
|
||||
|
||||
```csharp
|
||||
pageSize = Math.Clamp(pageSize, 1, 100);
|
||||
page = Math.Max(1, page);
|
||||
```
|
||||
|
||||
Clamp in the **service** layer so all callers are safe.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Cap batch cover-sheet PDF IDs
|
||||
|
||||
- Reject or truncate `CoverSheetIds` to max **100** (align with create clamp) in `CoverSheetController.GenerateBatchPdf` or `CoverSheetService.GetByIdsAsync`.
|
||||
- Prefer `ValidationException` when count > 100 so clients get a clear error.
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — AsNoTracking and unused Includes
|
||||
|
||||
- Add `AsNoTracking()` on read-only paths: batch list; cover-sheet lookups that do not mutate; promotion result reads where tracked entities are not updated.
|
||||
- Remove `.Include(b => b.Events)` from `VerificationService.VerifyAsync` if Events are unused.
|
||||
- Keep tracking on mutation paths (verify/approve/assign/promote).
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Slim GetDocument
|
||||
|
||||
- Stop calling `GetByIdAsync` for document streaming.
|
||||
- Query only `DocumentRef` (and not-found) plus `ScannedDocuments.ContentType`.
|
||||
- Preserve document-access audit behavior.
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — FHIR serializer reuse
|
||||
|
||||
- Static/`Lazy` `FhirJsonSerializer` with `Pretty = false`.
|
||||
- Avoid allocating a new serializer (and pretty whitespace) on every FHIR write.
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [x] `pageSize=1000000` on batch list / work-queue / cover-sheet list returns ≤ 100 items
|
||||
- [x] Batch PDF with > 100 IDs fails validation (or is hard-capped) — documented in API behavior
|
||||
- [x] `GetDocument` does not load draft graphs; still returns 200 for seeded batches with objects
|
||||
- [x] Verification still succeeds without loading Events collection
|
||||
- [x] FHIR JSON responses are compact (not pretty-printed)
|
||||
- [x] `dotnet test` on `VigilCareRecordsAPI.Tests` passes
|
||||
|
||||
## Out of scope
|
||||
|
||||
- MinIO async download / upload streaming (Phase 20)
|
||||
- Patient history / `$everything` pagination (Phase 20)
|
||||
- OCR changes (Phase 21)
|
||||
|
||||
## Verification
|
||||
|
||||
1. `dotnet test VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj`
|
||||
2. Manual or test: list with oversized `pageSize`; GetDocument on a seeded batch; FHIR Patient read payload is single-line/compact JSON
|
||||
3. Update overview finding statuses 5, 8, 10, 11 → Done when this phase merges
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 20](./phase-20-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,88 @@
|
||||
# Phase 20 — Memory Safety (MinIO + Unbounded Clinical Payloads)
|
||||
|
||||
## What exists
|
||||
|
||||
- [`DocumentStorageService.DownloadAsync`](../../VigilCareRecordsAPI/Services/DocumentStorageService.cs) buffers the full object and uses sync `CopyTo` in the MinIO callback; no `CancellationToken` on the interface.
|
||||
- Upload copies the full stream then hashes; `EnsureBucketAsync` runs on every upload.
|
||||
- [`GetDocument`](../../VigilCareRecordsAPI/Controllers/DigitizationBatchesController.cs) calls `ObjectExistsAsync` then downloads.
|
||||
- [`DigitizationHistoryService.GetPatientHistoryAsync`](../../VigilCareRecordsAPI/Services/DigitizationHistoryService.cs) loads all batches + drafts + events (tracked).
|
||||
- [`FhirService.GetPatientEverythingAsync`](../../VigilCareRecordsAPI/Services/FhirService.cs) loads all encounters and observations.
|
||||
- [`WorkQueueService.GetOverviewAsync`](../../VigilCareRecordsAPI/Services/WorkQueueService.cs) materializes every pending `UpdatedAt`.
|
||||
|
||||
Requires [Phase 19](./phase-19-plan.md). Tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Reduce peak RAM for document I/O and history/FHIR dumps. Keep returning `MemoryStream` from download for OCR compatibility; true HTTP pipe-through is out of scope unless required after measuring.
|
||||
|
||||
Do not start [Phase 21](./phase-21-plan.md) until success criteria below pass.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Async MinIO download + CancellationToken
|
||||
|
||||
- Add `CancellationToken` to `IDocumentStorageService` download/upload (and call sites).
|
||||
- In `DownloadAsync`, use async copy inside the MinIO callback (`CopyToAsync` + CT).
|
||||
- Propagate CT from controllers / OCR hosted service where already available.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Upload hashing and bucket ensure
|
||||
|
||||
- Hash while buffering once (single `MemoryStream` pass) where practical.
|
||||
- Ensure bucket once at bootstrap ([`AppBootstrapHostedService`](../../VigilCareRecordsAPI/BackgroundServices/AppBootstrapHostedService.cs)) and drop per-upload `EnsureBucketAsync`, or cache a process-lifetime “bucket ready” flag.
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — GetDocument without redundant StatObject
|
||||
|
||||
- Remove `ObjectExistsAsync` when missing objects can be expressed as 404 from download failure / MinIO not-found.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Paginate patient digitization history
|
||||
|
||||
- Add `page` / `pageSize` (default 20, max 50) to history API + service.
|
||||
- Use `AsNoTracking`; project summaries.
|
||||
- Cap audit trail size per entry (e.g. last N events) or defer full trail so payload stays bounded.
|
||||
- Update DTO / controller / web client callers if they assume an unpaged full list.
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — FHIR `$everything` paging
|
||||
|
||||
- Honor `_count` (default 100, max 500) with Bundle `next` link.
|
||||
- Do not load the entire observation history in one query/response.
|
||||
|
||||
---
|
||||
|
||||
## Step 6 — Work-queue overview SQL aggregates
|
||||
|
||||
- Replace pending `UpdatedAt` `ToListAsync` with EF aggregates for average age and oldest pending (avg / min `UpdatedAt`).
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [x] Download path uses async copy and accepts CT
|
||||
- [x] Bucket ensure is not invoked on every upload
|
||||
- [x] History returns `Entries.Count ≤ pageSize` with accurate total count metadata
|
||||
- [x] `$everything?_count=10` returns ≤ 10 resource entries (plus paging metadata as designed)
|
||||
- [x] Overview no longer materializes all pending timestamps in memory
|
||||
- [x] GetDocument / OCR download still work in integration tests
|
||||
- [x] `dotnet test` passes; Phase 11 FHIR script still green if run
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Tesseract engine reuse / Azure singleton (Phase 21)
|
||||
- Fuzzy match / seed N+1 (Phase 22)
|
||||
|
||||
## Verification
|
||||
|
||||
1. `dotnet test VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj`
|
||||
2. `./scripts/run-vigilcare-records-phase-11-verification.sh` (optional but recommended)
|
||||
3. Update overview findings 1, 3, 4, 7 (storage CT), 12, 13 → Done when this phase merges
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 21](./phase-21-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,75 @@
|
||||
# Phase 21 — OCR Reliability
|
||||
|
||||
## What exists
|
||||
|
||||
- [`OcrProcessingService`](../../VigilCareRecordsAPI/BackgroundServices/OcrProcessingService.cs) polls with `Take(5)` and uses `stoppingToken` for queries/`Delay`, but download / OCR / prefill omit CT.
|
||||
- [`AzureDocumentOcrService`](../../VigilCareRecordsAPI/Services/Ocr/AzureDocumentOcrService.cs) constructs `DocumentIntelligenceClient` per scoped resolve (`Program.cs` `AddScoped`).
|
||||
- [`TesseractOcrService`](../../VigilCareRecordsAPI/Services/Ocr/TesseractOcrService.cs) builds a new `TesseractEngine` per document; [`ImagePreprocessor`](../../VigilCareRecordsAPI/Services/Ocr/ImagePreprocessor.cs) sync-copies PDF and allocates large BGRA rasters.
|
||||
- [`OcrResult.RawText`](../../VigilCareRecordsAPI/Domain/Entities/OcrResult.cs) stores unbounded OCR text.
|
||||
|
||||
Requires [Phase 20](./phase-20-plan.md). OCR remains opt-in (`Ocr:Enabled`, default false). Tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Lower LOH/CPU spikes and make shutdown cooperative when OCR is enabled.
|
||||
|
||||
Do not start [Phase 22](./phase-22-plan.md) until success criteria below pass.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — CancellationToken through OCR pipeline
|
||||
|
||||
- Extend `IOcrService.ExtractAsync(..., CancellationToken ct = default)`.
|
||||
- Pass CT into `OcrDraftPreFiller.PreFillAsync` and MinIO download from `OcrProcessingService`.
|
||||
- Azure analyze must observe CT; Tesseract path checks CT between preprocess and process.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Singleton Azure Document Intelligence client
|
||||
|
||||
- Register `DocumentIntelligenceClient` as singleton in [`Program.cs`](../../VigilCareRecordsAPI/Program.cs) when provider is Azure.
|
||||
- Inject into scoped `AzureDocumentOcrService` (thin wrapper).
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — Tesseract / ImagePreprocessor buffer reductions
|
||||
|
||||
- Prefer async `CopyToAsync` for PDF buffering.
|
||||
- Avoid redundant `ToArray()` where a single buffer suffices.
|
||||
- Reuse one `TesseractEngine` per scoped service instance (hosted service remains sequential).
|
||||
- Keep processing sequential (no Parallel fan-out).
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Cap RawText persistence
|
||||
|
||||
- Truncate `RawText` (e.g. 64 KB) or store null when only field confidences are needed by draft GET.
|
||||
- Document the cap in the phase checklist / overview.
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [x] Phase 13 verification script passes with OCR disabled
|
||||
- [x] CT is on `IOcrService` / prefill / OCR hosted heavy path
|
||||
- [x] Azure client is singleton when Azure provider is configured
|
||||
- [x] Tesseract does not construct a new engine per page when the same scope processes one batch
|
||||
- [x] Stored `RawText` length is capped (or omitted)
|
||||
- [x] `dotnet test` passes
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Enabling OCR by default
|
||||
- Parallel OCR across batches
|
||||
- Fuzzy / seed / PromoteAsync CT (Phase 22)
|
||||
|
||||
## Verification
|
||||
|
||||
1. `./scripts/run-vigilcare-records-phase-13-verification.sh`
|
||||
2. `dotnet test VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj`
|
||||
3. Optional live OCR (`VIGILCARE_OCR_LIVE=1`) when credentials exist
|
||||
4. Update overview findings 2, 6, 7 (OCR CT), 16 → Done when this phase merges
|
||||
|
||||
## Gate
|
||||
|
||||
Do not start [Phase 22](./phase-22-plan.md) until success criteria above are met.
|
||||
@@ -0,0 +1,70 @@
|
||||
# Phase 22 — Polish and Ops
|
||||
|
||||
## What exists
|
||||
|
||||
- [`PromotionService`](../../VigilCareRecordsAPI/Services/PromotionService.cs) loads all same-DOB patients for Levenshtein logging before creating a new patient.
|
||||
- [`SeedDocumentStorage`](../../VigilCareRecordsAPI/Data/Seed/SeedDocumentStorage.cs) StatObject/Put per batch on bootstrap.
|
||||
- `PromoteAsync` / seed paths used by hosted services omit `CancellationToken`.
|
||||
- [`docker-compose.prod.yml`](../../docker-compose.prod.yml) sets API `memory: 1G` with no measured guidance comment.
|
||||
- [`UserDirectoryService.ListByRoleAsync`](../../VigilCareRecordsAPI/Services/UserDirectoryService.cs) is unbounded.
|
||||
|
||||
Requires [Phase 21](./phase-21-plan.md). Tracker: [performance-hardening-overview.md](./performance-hardening-overview.md).
|
||||
|
||||
## What needs to be built
|
||||
|
||||
Long-running / edge-case hardening and ops documentation. Do not raise the container memory limit with invented numbers — document how to measure with `dotnet-counters` and only change the limit if justified by measured peak.
|
||||
|
||||
---
|
||||
|
||||
## Step 1 — Cap fuzzy same-DOB candidates
|
||||
|
||||
- Before Levenshtein, `.Take(50)` (or equivalent) on same-DOB projection.
|
||||
- Keep warning logs for near-misses within the capped set.
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — Seed MinIO loop + CT
|
||||
|
||||
- Honor `CancellationToken` through seed document storage.
|
||||
- Reduce N+1 pressure: skip exists checks when unnecessary, or batch/limit work; bootstrap must still succeed on empty and re-run environments.
|
||||
|
||||
---
|
||||
|
||||
## Step 3 — PromoteAsync CancellationToken
|
||||
|
||||
- Add CT to `IPromotionService.PromoteAsync` and pass from [`PromotionRetryService`](../../VigilCareRecordsAPI/BackgroundServices/PromotionRetryService.cs).
|
||||
- Propagate into EF calls inside promote where practical.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Ops notes + user directory clamp
|
||||
|
||||
- Add a short comment near the 1 G limit in `docker-compose.prod.yml` pointing at counters workflow in the overview (do not invent a new limit).
|
||||
- Clamp `UserDirectoryService.ListByRoleAsync` with a sane max (e.g. 500) or document intentional unbounded small directories — prefer clamp for safety.
|
||||
|
||||
---
|
||||
|
||||
## Success criteria
|
||||
|
||||
- [x] Same-DOB fuzzy path never loads more than the configured Take cap
|
||||
- [x] Seed bootstrap respects CT and does not regress empty-DB seed
|
||||
- [x] Promotion retry still promotes with CT plumbed
|
||||
- [x] User directory list is capped
|
||||
- [x] Overview + this plan checklists updated; gap-analysis matrix rows 26–31 marked Done when Phases 19–22 complete
|
||||
- [x] `dotnet test` passes
|
||||
|
||||
## Out of scope
|
||||
|
||||
- Premature GC mode changes
|
||||
- Raising memory limit without measured peak evidence
|
||||
- Frontend redesign
|
||||
|
||||
## Verification
|
||||
|
||||
1. `dotnet test VigilCareRecordsAPI.Tests/VigilCareRecordsAPI.Tests.csproj`
|
||||
2. Smoke bootstrap against local compose
|
||||
3. Mark overview Phase 22 + findings 9, 14, 15 → Done; mark Phases 19–22 complete in PRD / plans README when all merge
|
||||
|
||||
## Gate
|
||||
|
||||
Performance hardening stream complete when this phase and overview checklists are Done.
|
||||
Reference in New Issue
Block a user