Skip to content

Privacy: check every search box for patient details before text leaves the page (S1) - #3834

Merged
BigSimmo merged 6 commits into
mainfrom
claude/project-thread-96ls8n
Oct 26, 2026
Merged

BigSimmo merged 6 commits into
mainfrom
claude/project-thread-96ls8n

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Requested by Josh · project thread

Summary

Stream S1 of the 26 Oct plan (privacy audit, 2026-10-26). Josh asked for it to be completed and taken out of draft on 26 Oct. Ordinary code: no database, no paid calls, no protected search files.

Patient-detail check (PD-01, PD-02) in src/lib/clinical-question-bare-name.ts and src/lib/clinical-question-patient-check.ts, used by Answer, Clinical Ask, feedback notes and every search box:

  • Given names beyond the English list (Vietnamese, Chinese, Indian, Arabic, African, Māori and Pacific, Aboriginal, European, common modern Australian), plus Mary with "Mary Jane" read past.
  • A listed surname on either side, so surname-first names ("Nguyen Thi Lan") and unlisted given names beside a common surname are caught. Surnames that are eponyms or everyday words (Wilson, Williams, Turner, Brown, Young, Hamilton, Bell, Park, Li) are left out.
  • A surname then a given name ("Testpatient Jane"), "Jane T.", "Jane (Testpatient)", a possessive given name ("Jane's lithium"), Prof and Sr titles, and "mrs t".
  • 1300 and 1800 service numbers, and dates a guideline, policy or protocol carries, are set aside before the phone and date checks. "protocol DOB 01/02/1990" and mobiles are still refused.
  • New known pairs read past: John Cade, Mary Jane, Sally Anne, Lee Silverman, Miller Fisher, Kurt Schneider, Marsha Linehan. "Royal" joins the place prefixes.

Synthetic corpus, before and after (the audit's corpus plus a held-out set written before any change, both now in tests/fixtures/patient-detail-corpus.ts with floors in tests/patient-detail-corpus.test.ts):

Before After
Audit identifiers caught 149 of 214 187 of 214
Audit ordinary questions wrongly refused 7 of 158 0 of 158
Held-out names caught 0 of 36 35 of 36
Held-out ordinary questions wrongly refused 11 of 36 1 of 36 ("Ken Kesey One Flew Over")
Repository fixture questions (371) newly refused none

Still missed (needs a decision, not more lists): a surname typed alone ("Can Testpatient have ECT", 10 cases), given names not on the list, quasi-identifiers ("the 92 year old from Wiluna"), DVA, CRN and passport numbers, PO boxes, "@handle". The audit corpus was used while tuning, so the held-out numbers are the fairer guide; the held-out set was also written by the same author.

Search boxes

  • D26-01, CA-02, CA-05: Medication and differentials typing-pause fetches await the check first, so a name never reaches /api/medications or /api/differentials, including a deep link's first request. The held-back sentence shows instead; differentials shows "This search was not sent" with no Retry.
  • CA-02: the in-document search (DocumentViewer.tsx) awaits the check before calling /api/documents/<id>/search, and shows the held-back sentence on the search's error line. This does not touch fix(a11y): announce document viewer offline state #3804's Offline badge hunk.
  • CA-01: suggested, recent and cross-mode Medication searches (setMedicationSearchQuery) and the Medication, Services, Forms and Favourites chips run the check before writing the address, history or recent searches. Chips are not hidden (that would be a design change).
  • CA-03: Tools results box, Tools launcher, Calculators, On Call Refer services link, Dictionary menu search and the Dictionary topic box (each keystroke) leave a patient detail out of ?q=.
  • CA-04: the shared guard fails closed. Until the full check has loaded it holds text back as "Checking this search for patient details", and when it cannot load it holds back with a connection message. Dashboard searches that stay on our servers also hold back when the check cannot load. The check now preloads when a search box mounts, so a quick Enter is not affected.
  • CA-05: a shared link whose ?q= holds a patient detail is cleaned on arrival on every search page, not only the dashboard.

Headers and fields

  • CA-06: Referrer-Policy: strict-origin (was strict-origin-when-cross-origin). CSRF and the local-project guard read only the host, so they are unaffected.
  • CA-08: safety plan entry inputs and the My Day quick note opt out of autofill, spelling and grammar extensions, like the other note fields.

Already fixed on main, verified: the whole-codebase and security-test rows "Bare first-and-last names (and street addresses) pass the clinical-question patient check" (owner decision 25 Oct, bareNameOrAddressProblem).

Not in this PR

Overlap: #3836 also edits ClinicalDashboard.tsx, use-dashboard-search-execution.ts, use-medication-catalog.ts and patient-safety-plan.tsx. Whichever lands second will need a sync.

Areas touched: App experience, Answer engine, Data platform and access, Personal practice (plus 2 files not yet placed in any area)

RAG impact: no retrieval behaviour change. No file in ragRankingPatterns is touched; the check only decides whether a question is sent.

Verification

  • Checks run:
    • Full offline unit suite (npm run test) on c9261d9 plus the fixes: Test Files 2 failed | 2096 passed | 2 skipped, Tests 4 failed | 33574 passed. The 4 failures are environmental: tests/cloud-platform-smoke.test.ts (3) and tests/rag-plan-package-parity.test.ts (1), "npm 11.17.0 is required; detected 11.19.1" in this container.
    • Every DocumentViewer test after the in-document search change: Test Files 27 passed, Tests 356 passed. Typecheck and lint clean.
    • tests/clinical-question-patient-check.test.ts (139 passed, including the 20 high-risk evaluation questions and every retrieval golden query), tests/patient-detail-corpus.test.ts, tests/search-box-patient-detail.dom.test.tsx (17), tests/search-patient-detail-guard.test.ts, tests/security-headers.test.ts.
    • Not run: browser journeys (verify:ui). Hosted CI runs them now that the PR is ready.

Risk and rollout

  • Risk: more refusals is the main risk. A clinician typing a listed given name beside a capitalised word (for example "Ken Kesey") is held back. Search boxes are held back for a moment if the check has not loaded yet.
  • Rollback: revert the PR.
  • Provider or production effects: None.

Clinical Governance Preflight

  • 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 PsychSift Production (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

Evidence / not applicable / unresolved:

  • Privacy hardening only; no clinical output changes. TGA item not applicable. All corpus text is synthetic.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD

…s and guideline dates

Privacy audit PD-01 and PD-02 (2026-10-26). The Clinical question check now
reads given names beyond the English list, a listed surname on either side
(surname-first names too), a surname then a given name, 'Jane T.',
'Jane (Surname)', a possessive given name, Prof and Sr titles, and a
lower-case title with one letter. 1300 and 1800 service numbers and dates a
guideline, policy or protocol carries are set aside before the phone and
date checks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
Privacy audit S1 (2026-10-26):
- D26-01, CA-02, CA-05: Medication and differentials typing-pause fetches
  await the patient-detail check first, so a name never reaches our server.
- CA-01: suggested, recent and cross-mode Medication searches and the
  Services, Forms and Favourites chips run the check before navigating.
- CA-03: Tools, launcher, Calculators, On Call Refer link, Dictionary menu and
  the Dictionary topic box leave a patient detail out of ?q=.
- CA-04: the search guard fails closed while the full check loads or when it
  cannot load.
- CA-05: shared links with a patient detail in ?q= are cleaned on arrival on
  every search page.
- CA-06: Referrer-Policy strict-origin.
- CA-08: safety plan and My Day note fields opt out of autofill, spelling and
  grammar extensions.
- Synthetic corpus floors for the widened name check.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
The search guard now fails closed until the full check has loaded, so tests
that expect a search to go out load it first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
The guard fails closed until the check has loaded, so loading it on mount
keeps a quick Enter from being held back as unchecked.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
@BigSimmo BigSimmo self-assigned this Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 89 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0275f56 and da18ffd.

Files selected for processing: 30
  • src/components/ClinicalDashboard.tsx
  • src/components/DocumentViewer.tsx
  • src/components/applications-launcher-page.tsx
  • src/components/calculators/search-page.tsx
  • src/components/clinical-dashboard/differentials-home.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/clinical-dashboard/master-search-header-actions.ts
  • src/components/clinical-dashboard/search-patient-detail-guard.ts
  • src/components/clinical-dashboard/use-dashboard-search-execution.ts
  • src/components/clinical-dashboard/use-differential-catalog.ts
  • src/components/clinical-dashboard/use-medication-catalog.ts
  • src/components/dictionary/dictionary-catalogue-pages.tsx
  • src/components/my-day/my-day-work-me-cards.tsx
  • src/components/on-call/refer/refer-page.tsx
  • src/components/patient-safety-plan.tsx
  • src/components/tools/tools-search-results-page.tsx
  • src/lib/clinical-question-bare-name.ts
  • src/lib/clinical-question-patient-check.ts
  • src/lib/security-headers.ts
  • tests/catalog-refetch-privacy.dom.test.tsx
  • tests/clinical-question-patient-check.test.ts
  • tests/fixtures/patient-detail-corpus.ts
  • tests/instant-results.dom.test.tsx
  • tests/medication-catalog-errors.dom.test.tsx
  • tests/patient-detail-corpus.test.ts
  • tests/search-box-patient-detail.dom.test.tsx
  • tests/search-patient-detail-guard.test.ts
  • tests/security-headers.test.ts
  • tests/therapy-submit-query-patient-guard.dom.test.tsx
  • tests/use-differential-search.dom.test.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@supabase

supabase Bot commented Oct 26, 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 ↗︎.

@gitar-bot

gitar-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

…s sent (CA-02)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
@BigSimmo
BigSimmo marked this pull request as ready for review October 26, 2026 09:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T09:36:42.924707Z 173f9da Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@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: 173f9da613

ℹ️ 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".

… (review on #3834)

Service-number digits are replaced by a word instead of removed, so the
same digits as an MRN or inside an email are still caught. Document dates
now need a document word, and a patient word between blocks the exemption.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyULT41weiAuu3CroGX7oD
@BigSimmo
BigSimmo merged commit 97b30e7 into main Oct 26, 2026
36 checks passed
@BigSimmo
BigSimmo deleted the claude/project-thread-96ls8n branch October 26, 2026 12:02
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.

2 participants