feat(documents): review and extract lab values on the document itself

The server chain existed end to end (extract stages PENDING facts, per-fact
edit clears the low-confidence gate, confirm is the only write into the
structured stores) but the document detail offered no control over any of
it: it counted observation facts and linked to Labs. A user whose automatic
staging run was skipped had to re-upload the same PDF through Labs > Scan a
report.

- The detail sheet gains a staged-facts block with honest states: pending
  facts open an inline review (approve/reject per fact; a low-confidence
  fact is checked and saved first via the existing per-fact edit); a
  lab-filed, already-read document with nothing staged offers "Extract lab
  values" over its stored text; otherwise nothing renders.
- The extract route gains { mode: "stored" }: the same text-structuring
  pass the automatic worker runs, over the document's own content index.
  No re-upload, no second read of the original; full gauntlet including
  the shared document-AI bucket with charge-at-dispatch honesty; 422
  notIndexed when no stored text exists.
- A manual "Read with AI" / "Read again" now continues into the same
  lab auto-staging the background worker performs; the response reports
  labFactsStaged and the toast names the values waiting for review.
- Unchecked values are rejected and the copy says so; an unverified
  low-confidence fact receives no decision and stays pending rather than
  being silently discarded. Confirmation remains the only write into
  Labs, conditions, and medications; approved facts carry the
  committedRecordId link back to the source document (existing model, no
  schema change).
- The "lab values from this document" link now counts APPROVED facts
  only — it claims values that actually exist in Labs.
- Copy in all six locales; OpenAPI regenerated for the new extract mode
  and the index response field.
This commit is contained in:
Marc-André Bombeck committed 2026-08-13 00:33:14 +02:00
1 parent 8e16df6894
commit fd104dd0ac
20 files changed
+1681 -64

No files matched your search

+45
View File
@@ -9567,6 +9567,7 @@
"errorBudget": "Il tuo budget IA di oggi è esaurito.",
"errorPdfNeedsVision": "La scansione dei PDF richiede un provider di visione Claude.",
"errorFileType": "Questo tipo di file non può essere letto.",
"errorNotIndexed": "Leggi prima il documento, poi estrai.",
"errorLocalOcrDisabled": "Attiva prima l'OCR locale nelle impostazioni IA.",
"errorProvider": "Nessun provider IA è configurato per questo.",
"errorTextImageOnly": "L'OCR locale legge solo immagini, non questo file."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "L’IA ha letto il tuo documento.",
"readStagedOne": "L’IA ha letto il tuo documento. 1 valore di laboratorio attende la tua revisione.",
"readStagedFew": "L’IA ha letto il tuo documento. {count} valori di laboratorio attendono la tua revisione.",
"readStagedOther": "L’IA ha letto il tuo documento. {count} valori di laboratorio attendono la tua revisione.",
"read": "Leggi con l’IA",
"reread": "Leggi di nuovo",
"reading": "Lettura…",
"notReadYet": "Questo documento non è ancora stato letto."
},
"review": {
"title": "Rivedi i valori estratti",
"hint": "Approva ciò che corrisponde al documento. I valori non selezionati vengono scartati; nulla viene salvato senza la tua conferma.",
"openOne": "Rivedi il valore estratto",
"openFew": "Rivedi i valori estratti ({count})",
"openOther": "Rivedi i valori estratti ({count})",
"includeAria": "Includi {value}",
"type": {
"OBSERVATION": "Valore di laboratorio",
"CONDITION": "Condizione",
"MEDICATION_STATEMENT": "Farmaco"
},
"statedRange": "intervallo indicato {range}",
"needsCheck": "Controlla questo valore rispetto al documento, poi salvalo.",
"verify": "Controlla",
"verifySave": "Salva valore",
"verifyInvalid": "Indica un nome e un valore numerico oppure un risultato testuale, non entrambi.",
"verifyFailed": "La correzione non è stata salvata. Riprova.",
"fieldName": "Nome",
"fieldDate": "Data",
"fieldValue": "Valore",
"fieldValueText": "Risultato (testo)",
"fieldUnit": "Unità",
"fieldDose": "Dose",
"unverifiedNoteOne": "1 valore deve ancora essere controllato e resta in sospeso.",
"unverifiedNoteFew": "{count} valori devono ancora essere controllati e restano in sospeso.",
"unverifiedNoteOther": "{count} valori devono ancora essere controllati e restano in sospeso.",
"finish": "Concludi la revisione",
"confirmFailed": "La revisione non è stata salvata. Riprova.",
"savedToastOne": "1 valore salvato.",
"savedToastFew": "{count} valori salvati.",
"savedToastOther": "{count} valori salvati.",
"nothingSavedToast": "Revisione salvata. Nessun valore è stato aggiunto.",
"extract": "Estrai i valori di laboratorio",
"extracting": "Estrazione…",
"extractHint": "Usa il testo già letto da questo documento. I valori estratti attendono la tua revisione; nulla viene salvato automaticamente.",
"extractEmpty": "Non è stato possibile estrarre valori da questo documento.",
"failUnitRequired": "Un valore numerico ha bisogno di un’unità prima di poter essere salvato.",
"failUnitMismatch": "L’unità indicata non corrisponde all’unità salvata per questo marcatore. Correggila e concludi di nuovo la revisione.",
"failGeneric": "Questo valore non è stato salvato."
},
"contentIndex": {
"indexPrompt": "Rendi ricercabile il contenuto dei documenti.",
"indexAll": "Indicizza tutto per la ricerca",