Skip to content

feat(patient): lab results viewer with abnormal-value highlighting - #132

Open
VeronicDev wants to merge 18 commits into
DocForum:mainfrom
VeronicDev:feat/lab-results-viewer-with-abnormal-value
Open

VeronicDev wants to merge 18 commits into
DocForum:mainfrom
VeronicDev:feat/lab-results-viewer-with-abnormal-value

Conversation

@VeronicDev

Copy link
Copy Markdown

Closes #24.

Implements PRD §4 patient core flow (results are the end of the book → consult → order → fulfil thread).

What changed and why:

  • Results list + detail per lab order showing status, facility, date, summary, and abnormality flag (normal/abnormal/critical badge).
  • In-app file viewer, lazy-loaded via React.lazy (own 1.3 kB chunk): native for images, browser built-in viewer via <iframe> for PDFs, plain anchors for download / open-in-new-tab. No third-party viewer script from a CDN at runtime (CSP-safe by construction); unknown types fall back to download-only.
  • Abnormal/critical show calm 'What happens next' copy with doctor-notified reassurance + acknowledgement status (pending / acknowledged / escalated) instead of alarming raw text.
  • Critical results withheld pending doctor review (docforum-core [Phase W6] Stuck referrals console: reassign or cancel with a reason #72 open question) render as a waiting notice — summary + file stay hidden, so both backend decisions render safely.
  • Routes: /patient/results + /patient/results/:id (patient-gated), linked from PatientDashboardPage. Standalone until [Phase W2] Orders list + facility-selection screen #5's orders list exists to link from (navigation-only dependency, not data).

Assumed contract (backend #72 not merged — documented in ARCHITECTURE_ESSENTIALS.md 'Known assumptions'):

  • GET /lab-results/mine → LabResult[], GET /lab-results/:id → LabResult
  • LabResult = real columns (id/resultFileUrl/summary/createdAt) + assumed labOrderId/testName/facilityId/facilityName/status/abnormalityFlag/acknowledgementStatus/doctorNotifiedAt/acknowledgedAt/withheldPendingReview. Doctor acknowledge endpoint is doctor-side only; this UI only reads acknowledgementStatus.
  • No Stellar/docforum-escrow touched (hard rule 1); types mirror backend schema; pages/components/features/hooks/services/store/types shape kept.

Tests:

  • 18 new component tests, 45/45 passing (npm test). Covers each flag state (normal/abnormal/critical), acknowledgement variants (pending/acknowledged/escalated), withheld, empty/error states, viewer kinds (pdf/image/unknown, incl. no-CDN-script assertion).
  • npm run typecheck: clean. npm run build: clean (ResultFileViewer code-split confirmed).

Screenshots: not attached — no browser tool in this environment, so not visually verified (same disclosed gap as prior UI work here). Please confirm rendered result at the preview URL.

ROADMAP.md Phase W2 + changelog updated; ARCHITECTURE_ESSENTIALS.md Known assumptions added.

Patient results list + detail per lab order (status, facility, date,
summary, abnormality flag), lazy native PDF/image viewer with download,
and calm next-steps + acknowledgement status for abnormal/critical.
Withheld-pending-review results render as a waiting notice. Assumed
contract against docforum-core DocForum#72 documented in
ARCHITECTURE_ESSENTIALS.md; ROADMAP.md Phase W2 updated.
@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@VeronicDev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev pls fix conflicts

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev fix CI

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev

CI is red on typecheck: src/types/models doesn't export LabResult or AbnormalityFlag. The branch uses those types but never adds them to models.ts, or they were lost in a merge. Please add the types, rebase onto the latest main, and run npm run typecheck locally.

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev Thanks for the PR. It can't be merged yet. To unblock it:

CI is failing. Here's what broke:

Frontend (typecheck + test + build):

src/features/results/components/AbnormalityBadge.tsx(1,15): error TS2305: Module '"../../../types/models"' has no exported member 'AbnormalityFlag'.
src/features/results/components/LabResultDetail.test.tsx(7,15): error TS2305: Module '"../../../types/models"' has no exported member 'LabResult'.
src/features/results/components/LabResultDetail.tsx(5,15): error TS2305: Module '"../../../types/models"' has no exported member 'LabResult'.
src/features/results/components/LabResultsList.test.tsx(7,15): error TS2305: Module '"../../../types/models"' has no exported member 'LabResult'.

Please fix these errors and run the same steps locally before pushing (npm run typecheck && npm test && npm run build, or cargo test for contracts).

Merge conflicts: this branch conflicts with main. Please rebase onto the latest main (git fetch upstream && git rebase upstream/main), resolve the conflicts (often ROADMAP.md, ARCHITECTURE*.md or prisma/schema.prisma), and force-push.

Push to this same branch and CI will re-run. Once it's green and conflict-free, it'll be reviewed for merge.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 20, 2026
@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 21, 2026
@Cjay-Cyber-2

Copy link
Copy Markdown

CI Checks Failed — Action Needed

The continuous integration checks on this pull request are failing. I can't merge until all required checks pass.

Failing checks:

  • Frontend (typecheck + test + build): failure

What to do: review the failing checks in the "Checks" tab above, fix the issues in your code, and push the changes.

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev CI is failing on this branch against the latest main, so it can't be merged yet. The errors from the latest run:

Frontend (typecheck + test + build)

src/App.tsx(11,10): error TS6133: 'PatientResultsPage' is declared but its value is never read.
src/App.tsx(12,10): error TS6133: 'PatientResultDetailPage' is declared but its value is never read.
src/features/results/components/AbnormalityBadge.tsx(1,15): error TS2305: Module '"../../../types/models"' has no exported member 'AbnormalityFlag'.
src/features/results/components/LabResultDetail.test.tsx(14,5): error TS2353: Object literal may only specify known properties, and 'labOrderId' does not exist in type 'LabResult'.
src/features/results/components/LabResultDetail.test.tsx(34,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.
src/features/results/components/LabResultDetail.test.tsx(38,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.
src/features/results/components/LabResultDetail.test.tsx(38,75): error TS2353: Object literal may only specify known properties, and 'abnormalityFlag' does not exist in type 'Partial<LabResult>'.
src/features/results/components/LabResultDetail.test.tsx(49,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.

src/types/models.ts doesn't export AbnormalityFlag, and LabResult has no labOrderId. Those additions were probably dropped while resolving the rebase, and the two result pages are imported but no longer routed.

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev CI is failing on this branch against the latest main, so it can't be merged yet. The errors from the latest run:

Frontend (typecheck + test + build)

src/App.tsx(11,10): error TS6133: 'PatientResultsPage' is declared but its value is never read.
src/App.tsx(12,10): error TS6133: 'PatientResultDetailPage' is declared but its value is never read.
src/features/results/components/AbnormalityBadge.tsx(1,15): error TS2305: Module '"../../../types/models"' has no exported member 'AbnormalityFlag'.
src/features/results/components/LabResultDetail.test.tsx(14,5): error TS2353: Object literal may only specify known properties, and 'labOrderId' does not exist in type 'LabResult'.
src/features/results/components/LabResultDetail.test.tsx(34,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.
src/features/results/components/LabResultDetail.test.tsx(38,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.
src/features/results/components/LabResultDetail.test.tsx(38,75): error TS2353: Object literal may only specify known properties, and 'abnormalityFlag' does not exist in type 'Partial<LabResult>'.
src/features/results/components/LabResultDetail.test.tsx(49,30): error TS2339: Property 'getLabResult' does not exist on type 'typeof import("/home/runner/work/docforum-web/docforum-web/src/services/results-service")'.

AbnormalityFlag, getLabResult and the labOrderId/abnormalityFlag fields on LabResult aren't defined on this branch, and PatientResultsPage/PatientResultDetailPage are imported in App.tsx but never routed. These names were probably lost while resolving the rebase. Restore their definitions from your earlier commits.

@VeronicDev

Copy link
Copy Markdown
Author

Fix Applied

Restore LabResult types, results-service methods, routing, and resolve typecheck errors in results feature.

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev pls fix CI

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev CI is failing on this branch against the latest main, so it can't be merged yet. The errors from the latest run:

Browser (journeys + accessibility + visual)

[WebServer] Error:   Failed to scan for dependencies from entries:
    Error: expect(locator).toBeVisible() failed
    Error: element(s) not found

Frontend (typecheck + test + build)

src/App.tsx(91,16): error TS2304: Cannot find name 'PatientResultsPage'.
src/App.tsx(99,16): error TS2304: Cannot find name 'PatientResultDetailPage'.
src/features/availability/calendar.ts(384,24): error TS2339: Property 'appointment' does not exist on type 'AvailabilitySlot'.
src/features/availability/components/AvailabilityCalendar.test.tsx(20,34): error TS2339: Property 'appointment' does not exist on type 'AvailabilitySlot'.
src/features/availability/components/GenerateSlotsForm.test.tsx(8,15): error TS2305: Module '"../../../types/models"' has no exported member 'SlotGenerationResult'.
src/features/availability/hooks/useSlotManagement.ts(8,33): error TS2305: Module '"../../../types/models"' has no exported member 'BlockRangeResult'.
src/features/availability/hooks/useSlotManagement.ts(8,51): error TS2305: Module '"../../../types/models"' has no exported member 'SlotGenerationResult'.
src/features/availability/hooks/useSlotManagement.ts(118,103): error TS2345: Argument of type 'Set<unknown>' is not assignable to parameter of type 'ReadonlySet<string>'.

PatientResultsPage/PatientResultDetailPage are routed in App.tsx but no longer imported, and several types (SlotGenerationResult, BlockRangeResult, AvailabilitySlot.appointment) aren't on this branch. These names were probably lost while resolving the rebase. Restore their definitions or exports from your earlier commits.

@VeronicDev

Copy link
Copy Markdown
Author

Fix Applied

Restore missing types (PatientResultsPage, PatientResultDetailPage, SlotGenerationResult, BlockRangeResult, EvaluatedFlags, NotificationChannel, NotificationPreferences, AvailabilitySlot.appointment) in models.ts and App.tsx, fix type safety in useSlotManagement and preferences.test.ts

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@VeronicDev CI is failing on this branch against the latest main, so it can't be merged yet. The errors from the latest run:

Frontend (typecheck + test + build)

src/components/Flag.test.tsx(42,9): error TS2322: ... not assignable to type '(value: { flags: Record<string, boolean>; }) => void'.
src/components/Flag.test.tsx(78,7): error TS2322: Type '{ notification_preferences: false; }' is not assignable to type 'boolean'.
src/features/availability/calendar.ts(384,37): error TS2339: Property 'patientFullName' does not exist on type 'PatientAppointment'.
src/features/availability/components/GenerateSlotsForm.test.tsx(16,12): error TS2353: ... 'created' does not exist in type 'SlotGenerationResult'.

The missing-import errors from before are fixed, but your branch's types and tests don't match main any more. On main, the flags API returns { flags: Record<string, boolean> }, PatientAppointment has no patientFullName, and SlotGenerationResult has no created. Update the tests and calendar.ts to main's types (or add the fields where your feature needs them), then run npm run typecheck locally. The Browser job fails only because the app doesn't build.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 25, 2026
@github-actions

Copy link
Copy Markdown

@VeronicDev This PR now has merge conflicts with main, most likely because #157 (feat(platform): complete W7 API client, errors, PWA, and i18n) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-web.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Has merge conflicts with main; the author needs to rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase W2] Lab results viewer with abnormal-value highlighting

3 participants