Repository navigation
Partner imports find their booking, and patient links behind the QR (0.1.5) - #37
Merged
Merged
Conversation
…ch on upload (0.1.5) - ExternalReport.candidates(first): bookings of patients found by the printed name, scored by name, sex, age ±1, partner tests that map to booked tests, and recency; reasons, mismatches, mappings - An upload without a booking is matched on its own when exactly one strong candidate stands out (audited external_report.auto_match); staff still review and apply - suggestedTestCode prefers the matched booking's tests - Lockfile: client 1.10.0 (published from client v1.10.0; hash filled on the next install) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohjC7uBfVPopxyZBtS1
…page - patientPage(token) and patientDocument(token, kind, invoiceId): public, rate-limited per IP (PATIENT_LINK_PER_IP), null for any token that does not open; one booking's issued bills and released reports only, the patient's name shortened. - patientLink(bookingId) (booking:read + report:read) and revokePatientLinks(bookingId) (booking:update, audited). - Tokens are HMAC(PATIENT_LINK_SECRET, nonce); db-kit stores only the SHA-256 and the nonce. - Printed reports and a booking's bills carry the link in their QR when PATIENT_LINK_SECRET and PATIENT_LINK_BASE_URL are set. - Kits: db-kit ^2.2.0, report-kit ^2.3.0, invoice-kit ^2.2.0, client ^1.12.0. - docs/21-patient-links.md, configuration, example, schema, reference and llms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohjC7uBfVPopxyZBtS1
Contributor
Author
|
CI goes green once these tags are published, in this order:
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does two things: it finds the booking a partner PDF belongs to, and it adds patient links (the QR on reports and bills opens the patient's page).
1. Partner imports: find the booking
ExternalReport.candidates(first = 5): finds patients by the printed name (the whole name first, then each word of three or more letters). It takes their bookings from the last 90 days that are not cancelled, keeping only those in branches where the caller hasreport:import. Each booking gets a score from 0 to 100, built from:strongmeans name, sex and age agree and at least one test maps. Each candidate carriesreasons,patientMismatchesand per-testmappings.Auto-match on upload: an upload without
bookingIdis matched when exactly one strong candidate in the upload's branch stands out (no other strong one within 20 points). It is audited asexternal_report.auto_match. Nothing is applied automatically.suggestedTestCode: prefers the matched booking's tests.2. Patient links (docs/21-patient-links.md)
patientPage(token)shows the lab, the patient's shortened name ("Ravi K. S."), the booking number, the branch, issued bills, released reports and tests still in the lab;patientDocument(token, kind, invoiceId)returns one of those bills, or the released reports, as a PDF.null.PATIENT_LINK_PER_IP, default 60 per 10 minutes, shared through Redis) and answersRATE_LIMITEDwithretryAfterMswhen over.patientDocumentcounts as a document field in the cost limit.patientLink(bookingId)needsbooking:read+report:read;revokePatientLinks(bookingId)needsbooking:updateand is audited aspatient_link.revoke.HMAC-SHA256(PATIENT_LINK_SECRET, nonce)in base64url.PATIENT_LINK_SECRET(32+ characters) andPATIENT_LINK_BASE_URL(https) set,bookingReportDocumentand a booking'sinvoiceDocumentput the link in their QR. Without them, nothing changes.Kits
db-kit ^2.2.0 (patientLinks storage), report-kit ^2.3.0 and invoice-kit ^2.2.0 (QR value and caption, UPI pay QR), and client ^1.12.0.
kits.jsonand the lockfile are updated to match. The lockfile entries have no hash yet; npm fills it in on the next install.CI needs these tags published first: client
v1.10.0, clientv1.12.0(after client#19), db-kitv2.2.0, report-kitv2.3.0, then invoice-kitv2.2.0.Checks
npm run typecheck.TEST_BACKENDS=pg npm test: 281 passed. New checks cover:MongoDB can't be downloaded in my container; CI runs both databases. Schema, reference and llms-full are regenerated.
🤖 Generated with Claude Code
https://claude.ai/code/session_018jBohjC7uBfVPopxyZBtS1