Skip to content

Rebuild Patient Factsheets as a first-class mode from the imported design#879

Merged
BigSimmo merged 11 commits into
mainfrom
claude/patient-factsheets-impl-ra7yi9
Jul 18, 2026
Merged

Rebuild Patient Factsheets as a first-class mode from the imported design#879
BigSimmo merged 11 commits into
mainfrom
claude/patient-factsheets-impl-ra7yi9

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the placeholder Patient Factsheets feature (3 generic "sample" sheets in a bespoke local shell) with the imported Patient Factsheets design, rebuilt with Tailwind + design tokens (dark mode / forced-colors / reduced-motion all work).
  • Data: new discriminated Factsheet model with 5 kinds (medRich/medLite/condition/therapy/procedure), 8 plain-language sheets with cited Australian consumer-health sources, category theming, and print/TOC projections; icon-key to Lucide map in factsheets-icons.ts.
  • Home: shared ModeHomeHero + hero composer slot + browse-by-topic pills + colour-coded featured cards + governance verification footer.
  • Search: server-driven results, category filter chips, List/Cards toggle, empty state, content-status note.
  • Detail: category hero band, five kind-specific layouts, sources, "more in topic", related sheets, sticky sidebar, Easy-read/Standard toggle, Save, and Download PDF that prints a clean A4 sheet (scoped @media print rule hides the shell chrome).
  • Mode registration + shared shell: registers factsheets across app-modes, app-mode-icons, the universal-search domain map, route-ownership, global-search-shell, and the sidebar nav; factsheets/layout.tsx now uses GlobalSearchShell and the bespoke FactsheetShell is deleted. Adds Factsheets to the mode switcher (MODE dropdown) and gives it its own mode home; the shared composer routes to /factsheets/search.

Verification

  • npm run verify:pr-local
  • Verification not run: ran the component gates individually and all pass — check:type-scale, check:icon-scale, brand:check, sitemap:check, lint (changed files), typecheck (factsheets/mode files clean), and the factsheets-data + app-modes vitest suites (26 tests); the full verify:pr-local unit run has pre-existing jsdom and Python-OCR environment gaps in this local container, unrelated to this change (they pass in CI where those deps are installed).
  • UI verification not run: performed manual Chromium (Playwright) QA instead of the verify:ui gate — screenshotted Home, Search (list/cards/filter/empty), all five detail kinds, print-media emulation (clean A4 with shell chrome hidden), dark mode, and mobile at 390px with no horizontal overflow; confirmed the shared composer routes to /factsheets/search and the MODE dropdown + sidebar show Factsheets.

Risk and rollout

  • Risk: Low — self-contained UI feature in the /factsheets route family plus additive, exhaustive-map-safe mode registration; no API, data, auth, privacy, Supabase, retrieval, or answer-generation changes.
  • Rollback: Revert this PR's commit; the mode registration is additive and isolated, with no migrations or provider state involved.
  • Provider or production effects: None.

Clinical Governance Preflight

Factsheets present static, read-only patient information (no ingestion / answer-generation / retrieval / document-access / Supabase changes); the content is clinical in nature, so the preflight is completed below. Governance context: each sheet cites dated sources, and the UI carries "Connect only governance-approved content before publication" (home footer + search content-status note + per-detail disclaimer). It does not touch the RAG corpus or demo-mode synthetic data.

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

  • The Easy-read/Standard reading-level toggle renders only on the medication-rich detail (the only sheet with differentiated copy) to avoid a no-op control.
  • Print output uses a hidden .factsheet-print-sheet revealed via an html.factsheets-printing body class + @media print visibility rule, so only the clean A4 sheet prints.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U9NNpe5W616C4XvjRgW6pV

Summary by CodeRabbit

  • New Features
    • Added a new Factsheets mode with a dedicated home, featured sheets, and a category-filtered search experience.
    • Updated the navigation to include Factsheets under the Tools section.
    • Delivered a redesigned Factsheet detail view with bookmarking, share/copy, related links, and an “On this page” table of contents.
  • Improvements
    • Improved performance by pre-rendering known Factsheet routes.
    • Enhanced print/PDF output to show only the print-ready sheet content.
  • Documentation
    • Updated the site map with the new Factsheets routes.

…sign

Replace the placeholder factsheet pages (3 generic "sample" sheets in a
bespoke local shell) with the imported Patient Factsheets design, wired into
the app's universal shell and registered as a proper app mode.

Data & content
- Rewrite factsheets-data.ts: discriminated Factsheet model with 5 kinds
  (medRich/medLite/condition/therapy/procedure), 8 plain-language sheets with
  cited Australian sources, category theming, and print/TOC projections.
- Add factsheets-icons.ts mapping icon keys + categories to Lucide glyphs.

Pages (rebuilt to the design, using Tailwind + design tokens so dark mode,
forced-colors and reduced-motion all work)
- Home: shared ModeHomeHero + hero composer slot + browse-by-topic pills +
  colour-coded featured cards + governance verification footer.
- Search: server-driven results, category filter chips, List/Cards toggle,
  empty state, content-status note.
- Detail: category hero band, five kind-specific layouts, sources,
  more-in-topic, related sheets, sticky sidebar, Easy-read/Standard toggle,
  Save, and Download PDF that prints a clean A4 sheet (globals.css print rule
  hides the shell chrome).
- [slug] route gains generateStaticParams + dynamicParams=false.

Mode registration & shared shell
- Register "factsheets" in app-modes (id, definition, namespace-isolated,
  /factsheets/search query special-case), app-mode-icons, the universal-search
  domain map, route-ownership, the standalone-home + prefetch in
  global-search-shell, and the sidebar nav.
- Swap factsheets/layout.tsx to GlobalSearchShell; delete the bespoke
  FactsheetShell. All factsheet routes now share the universal
  header/sidebar/composer, and the composer drives /factsheets/search.

Tests & docs
- Rewrite factsheets-data.test.ts for the new model; extend app-modes.test.ts
  with factsheets coverage; regenerate docs/site-map.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U9NNpe5W616C4XvjRgW6pV
@supabase

supabase Bot commented Jul 18, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9edadd02-8542-47e8-ae1d-cf872fd21ff9

📥 Commits

Reviewing files that changed from the base of the PR and between e015450 and df98fd4.

📒 Files selected for processing (2)
  • src/components/factsheets/factsheet-detail-page.tsx
  • src/components/factsheets/factsheets-search-page.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/factsheets/factsheets-search-page.tsx
  • src/components/factsheets/factsheet-detail-page.tsx

📝 Walkthrough

Walkthrough

Adds a data-driven patient factsheets library with typed content, home/search/detail pages, static routes, print rendering, and integration with shared application modes, navigation, routing, and sitemap systems.

Changes

Factsheets vertical slice

Layer / File(s) Summary
Factsheet data model and projections
src/components/factsheets/factsheets-data.ts, tests/factsheets-data.test.ts
Defines typed factsheet variants, embeds the library, adds filtering and relationship utilities, and produces print and table-of-contents projections with coverage.
Factsheet home and search flow
src/components/factsheets/factsheets-icons.ts, src/components/factsheets/factsheets-home-page.tsx, src/components/factsheets/factsheets-search-page.tsx, src/app/factsheets/search/page.tsx
Adds themed category browsing, featured content, server-side query filtering, category chips, list/card views, and empty states.
Factsheet detail and print rendering
src/components/factsheets/factsheet-detail-page.tsx, src/app/factsheets/[slug]/page.tsx, src/app/globals.css
Adds kind-specific detail layouts, actions, related content, static slug generation, and print-only output.
Factsheets mode and application wiring
src/lib/app-modes.ts, src/lib/app-mode-icons.ts, src/lib/search-route-ownership.ts, src/lib/universal-search-mode-context.ts, src/components/clinical-dashboard/*, src/app/factsheets/layout.tsx, scripts/generate-site-map.ts, docs/site-map.md, tests/app-modes.test.ts
Registers the factsheets tools mode, connects navigation and standalone routing, configures prefetching and ownership, and documents and tests the mode contract.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant FactsheetsSearchRoute
  participant FactsheetsData
  participant FactsheetsSearchPage
  Browser->>FactsheetsSearchRoute: Request factsheets query
  FactsheetsSearchRoute->>FactsheetsData: Filter by query and category
  FactsheetsData-->>FactsheetsSearchRoute: Return matching factsheets
  FactsheetsSearchRoute->>FactsheetsSearchPage: Pass query, category, and results
  FactsheetsSearchPage-->>Browser: Render results
Loading

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.90% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: rebuilding Patient Factsheets as a first-class mode.
Description check ✅ Passed The description largely matches the template, including Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/patient-factsheets-impl-ra7yi9

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo marked this pull request as ready for review July 18, 2026 15:29
@BigSimmo
BigSimmo enabled auto-merge (squash) July 18, 2026 15:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ec0b5ddba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/factsheets/factsheet-detail-page.tsx Outdated
Comment thread src/components/factsheets/factsheets-data.ts Outdated
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0a444a2a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/factsheets/search/page.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/factsheets/factsheets-data.ts`:
- Around line 41-54: Update FactsheetBase and its consumers so reviewedOn is not
treated as clinical approval: add explicit approval status and reviewer
metadata, then conditionally render “Reviewed” and “clinician-reviewed” claims
only when approval is present; otherwise remove those claims. Update
demonstration factsheet data accordingly and run focused verification plus npm
run check:production-readiness.

In `@src/components/factsheets/factsheets-home-page.tsx`:
- Around line 40-53: Replace render-time factsheetIcon calls with the static
glyph helper or direct createElement usage so icon selection does not create
component bindings during render. Apply this across
src/components/factsheets/factsheets-home-page.tsx lines 40-53 and 91-107;
src/components/factsheets/factsheets-search-page.tsx lines 88-104, 135-149, and
183-199; and src/components/factsheets/factsheet-detail-page.tsx lines 223-236,
262-275, and 519-530, while preserving the existing
factsheetCategoryIcons/CategoryIcon rendering behavior.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b08fff6-7cac-452c-9b27-e48daea54796

📥 Commits

Reviewing files that changed from the base of the PR and between ebb8c90 and 9e96d00.

📒 Files selected for processing (20)
  • docs/site-map.md
  • scripts/generate-site-map.ts
  • src/app/factsheets/[slug]/page.tsx
  • src/app/factsheets/layout.tsx
  • src/app/factsheets/search/page.tsx
  • src/app/globals.css
  • src/components/clinical-dashboard/ClinicalSidebar.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/factsheets/factsheet-detail-page.tsx
  • src/components/factsheets/factsheet-shell.tsx
  • src/components/factsheets/factsheets-data.ts
  • src/components/factsheets/factsheets-home-page.tsx
  • src/components/factsheets/factsheets-icons.ts
  • src/components/factsheets/factsheets-search-page.tsx
  • src/lib/app-mode-icons.ts
  • src/lib/app-modes.ts
  • src/lib/search-route-ownership.ts
  • src/lib/universal-search-mode-context.ts
  • tests/app-modes.test.ts
  • tests/factsheets-data.test.ts
💤 Files with no reviewable changes (1)
  • src/components/factsheets/factsheet-shell.tsx

Comment thread src/components/factsheets/factsheets-data.ts
Comment thread src/components/factsheets/factsheets-home-page.tsx Outdated
BigSimmo and others added 2 commits July 18, 2026 23:43
…, verifiable sources

- Normalize repeated search params: /factsheets/search?q=a&q=b previously threw
  on .trim() (App Router passes string[]), returning a 500; collapse q/category to
  the first value like the DSM/Services search routes.
- Include the brand suffix (e.g. "(Zoloft)") in factsheet search so brand-name
  queries resolve even though brand is stored separately from the title.
- Make source citations honest: add an optional url to FactsheetSource and render
  each "Where this information comes from" row as an outbound link only when a
  verifiable url is present (dropping the external-link glyph otherwise), instead
  of implying every inert citation is openable. No source URLs are fabricated;
  governance can attach approved links.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U9NNpe5W616C4XvjRgW6pV

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc2c9a722

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/factsheets/factsheets-data.ts
Comment thread src/components/factsheets/factsheet-detail-page.tsx
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

cursoragent and others added 3 commits July 18, 2026 15:58
Add real public healthdirect/Beyond Blue/NIMH/Mayo Clinic URLs to every
citation so "Where this information comes from" is clickable and checkable.
Soften Reviewed/clinician-reviewed UI copy to dated demonstration language,
and route icon rendering through static glyph helpers to avoid render-time
component bindings.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
The static-components autofix left factsheet-detail-page.tsx and
factsheets-search-page.tsx unformatted, failing the Static PR checks
`format:check` (prettier --check) gate. Apply prettier --write; no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U9NNpe5W616C4XvjRgW6pV

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccb7c30250

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/app-modes.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df98fd4540

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/globals.css
Comment thread src/lib/app-modes.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 196bf6582f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/factsheets/factsheet-detail-page.tsx
@BigSimmo
BigSimmo merged commit 7c5679f into main Jul 18, 2026
31 checks passed
@BigSimmo
BigSimmo deleted the claude/patient-factsheets-impl-ra7yi9 branch July 18, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants