Skip to content

Patient links storage for the QR on reports and bills (2.2.0) - #14

Merged
BackStacked merged 2 commits into
mainfrom
claude/project-thread-w4wng5
Nov 11, 2026
Merged

BackStacked merged 2 commits into
mainfrom
claude/project-thread-w4wng5

Conversation

@BackStacked

Copy link
Copy Markdown
Contributor

This is the storage half of handoff list B1. The QR on a report or a bill opens a read-only page with that one booking's bill and released reports. The api owns the logic (tokens, expiry, rate limits, what is shown); this PR only stores the links.

What changes

  • PatientLink type and a patientLinks repository on MongoDB and PostgreSQL, in the patient_links table / collection.
  • Fields: organisation, branch, booking, patient, tokenHash (unique), nonce, expiresAt, revokedAt / revokedBy, createdBy, lastViewedAt, viewCount.
  • The token is never stored. Rows hold its SHA-256 for lookup and a nonce. The api re-derives the token as an HMAC of the nonce with its own secret, so it can reprint the same QR. The nonce is useless without that secret.
  • Docs: docs/PATIENT-LINKS.md, AGENTS.md rule 12, llms-full. Version 2.2.0.

Checks

  • npm run typecheck, npm run build.
  • TEST_BACKENDS=pg npm test: 103 passed, including 3 new contract checks (look up by hash with expiry kept, the unique token hash, revoke with view count and list per booking).
  • MongoDB binaries can't be downloaded in my container; CI runs both backends.

Generated by Claude Code

Read-only links behind the QR on reports and bills: token hash (unique) and nonce, never the token;
booking, patient, expiry, revocation, view count. Contract tests on both backends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jBohjC7uBfVPopxyZBtS1
@BackStacked BackStacked self-assigned this Nov 11, 2026
@BackStacked
BackStacked merged commit 82c70a7 into main Nov 11, 2026
1 check passed
@BackStacked
BackStacked deleted the claude/project-thread-w4wng5 branch November 11, 2026 19:13
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