feat(documents): gate document, lab and medication reading on their capabilities

Reading a document, scanning a lab report and turning a medication
description into a schedule follow documentAi, labsOcr and
medicationExtract. Unavailable, the action is not offered. With only the
document-reading consent missing, the place that reads asks for it and
grants exactly that (ai_extraction), nothing wider.

Refusals are read by meta.errorCode: a 403 is no longer always called a
missing consent, and a spent daily budget no longer shows the rate-limit
sentence.
This commit is contained in:
Marc-André Bombeck committed 2026-09-24 11:05:49 +02:00
1 parent 48d97ef70d
commit 4449b34ac7
15 files changed
+466 -40

No files matched your search

+8 -2
View File
@@ -62,8 +62,6 @@ export const settingsKeys = {
/** v1.11.0 — owner's clinician share links (Settings → Sharing). */
shareLinks: () => ["share-links"] as const,
featureFlags: () => ["feature-flags"] as const,
/**
* The account's standing AI consent receipt (`GET /api/consent/ai/latest`).
* Keyed by kind because the endpoint answers per kind and a shared key
@@ -71,4 +69,12 @@ export const settingsKeys = {
*/
aiConsentReceipt: (kind: string) =>
["consent", "ai", "latest", kind] as const,
/**
* Mutation key for granting the document-reading consent (`ai_extraction`)
* from the place that asks for it: a document read, a lab scan, the
* medication text reader.
*/
aiExtractionConsentGrant: () =>
["consent", "ai", "grant", "ai_extraction"] as const,
};