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": "Dein KI-Budget für heute ist aufgebraucht.",
"errorPdfNeedsVision": "Zum Scannen von PDFs wird ein Claude-Vision-Anbieter benötigt.",
"errorFileType": "Dieser Dateityp kann nicht gelesen werden.",
"errorNotIndexed": "Lies das Dokument zuerst aus, dann extrahiere.",
"errorLocalOcrDisabled": "Aktiviere zuerst die lokale Texterkennung in den KI-Einstellungen.",
"errorProvider": "Dafür ist kein KI-Anbieter eingerichtet.",
"errorTextImageOnly": "Lokale Texterkennung liest nur Bilder — nicht diese Datei."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "Die KI hat dein Dokument gelesen.",
"readStagedOne": "Die KI hat dein Dokument gelesen. 1 Laborwert wartet auf deine Prüfung.",
"readStagedFew": "Die KI hat dein Dokument gelesen. {count} Laborwerte warten auf deine Prüfung.",
"readStagedOther": "Die KI hat dein Dokument gelesen. {count} Laborwerte warten auf deine Prüfung.",
"read": "Mit KI auslesen",
"reread": "Erneut lesen",
"reading": "Liest…",
"notReadYet": "Dieses Dokument wurde noch nicht gelesen."
},
"review": {
"title": "Ausgelesene Werte prüfen",
"hint": "Bestätige, was mit dem Dokument übereinstimmt. Nicht angehakte Werte werden verworfen; ohne deine Bestätigung wird nichts gespeichert.",
"openOne": "Ausgelesenen Wert prüfen",
"openFew": "Ausgelesene Werte prüfen ({count})",
"openOther": "Ausgelesene Werte prüfen ({count})",
"includeAria": "{value} übernehmen",
"type": {
"OBSERVATION": "Laborwert",
"CONDITION": "Erkrankung",
"MEDICATION_STATEMENT": "Medikament"
},
"statedRange": "angegebener Bereich {range}",
"needsCheck": "Prüfe diesen Wert gegen das Dokument und speichere ihn dann.",
"verify": "Prüfen",
"verifySave": "Wert speichern",
"verifyInvalid": "Gib einen Namen und entweder einen Zahlenwert oder ein Textergebnis an, nicht beides.",
"verifyFailed": "Die Korrektur konnte nicht gespeichert werden. Versuche es erneut.",
"fieldName": "Name",
"fieldDate": "Datum",
"fieldValue": "Wert",
"fieldValueText": "Ergebnis (Text)",
"fieldUnit": "Einheit",
"fieldDose": "Dosis",
"unverifiedNoteOne": "1 Wert muss noch geprüft werden und bleibt offen.",
"unverifiedNoteFew": "{count} Werte müssen noch geprüft werden und bleiben offen.",
"unverifiedNoteOther": "{count} Werte müssen noch geprüft werden und bleiben offen.",
"finish": "Prüfung abschließen",
"confirmFailed": "Die Prüfung konnte nicht gespeichert werden. Versuche es erneut.",
"savedToastOne": "1 Wert gespeichert.",
"savedToastFew": "{count} Werte gespeichert.",
"savedToastOther": "{count} Werte gespeichert.",
"nothingSavedToast": "Prüfung gespeichert. Es wurden keine Werte übernommen.",
"extract": "Laborwerte auslesen",
"extracting": "Liest aus…",
"extractHint": "Nutzt den bereits ausgelesenen Text dieses Dokuments. Ausgelesene Werte warten auf deine Prüfung; nichts wird automatisch gespeichert.",
"extractEmpty": "Aus diesem Dokument konnten keine Werte ausgelesen werden.",
"failUnitRequired": "Ein Zahlenwert braucht eine Einheit, bevor er gespeichert werden kann.",
"failUnitMismatch": "Die angegebene Einheit passt nicht zur gespeicherten Einheit dieses Markers. Passe sie an und schließe die Prüfung erneut ab.",
"failGeneric": "Dieser Wert konnte nicht gespeichert werden."
},
"contentIndex": {
"indexPrompt": "Dokumentinhalte durchsuchbar machen.",
"indexAll": "Alle für Suche indizieren",
+45
View File
@@ -9567,6 +9567,7 @@
"errorBudget": "Your AI budget for today is used up.",
"errorPdfNeedsVision": "Scanning PDFs needs a Claude vision provider.",
"errorFileType": "This file type can't be read.",
"errorNotIndexed": "Read the document first, then extract.",
"errorLocalOcrDisabled": "Turn on local OCR in the AI settings first.",
"errorProvider": "No AI provider is set up for this.",
"errorTextImageOnly": "Local OCR reads images only — not this file."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "The AI read your document.",
"readStagedOne": "The AI read your document. 1 lab value is ready to review.",
"readStagedFew": "The AI read your document. {count} lab values are ready to review.",
"readStagedOther": "The AI read your document. {count} lab values are ready to review.",
"read": "Read with AI",
"reread": "Read again",
"reading": "Reading…",
"notReadYet": "This document has not been read yet."
},
"review": {
"title": "Review extracted values",
"hint": "Approve what matches the document. Unchecked values are discarded; nothing is saved without your confirmation.",
"openOne": "Review extracted value",
"openFew": "Review extracted values ({count})",
"openOther": "Review extracted values ({count})",
"includeAria": "Include {value}",
"type": {
"OBSERVATION": "Lab value",
"CONDITION": "Condition",
"MEDICATION_STATEMENT": "Medication"
},
"statedRange": "stated range {range}",
"needsCheck": "Check this value against the document, then save it.",
"verify": "Check",
"verifySave": "Save value",
"verifyInvalid": "Enter a name and either a numeric value or a text result, not both.",
"verifyFailed": "The correction couldn't be saved. Try again.",
"fieldName": "Name",
"fieldDate": "Date",
"fieldValue": "Value",
"fieldValueText": "Result (text)",
"fieldUnit": "Unit",
"fieldDose": "Dose",
"unverifiedNoteOne": "1 value still needs checking and stays pending.",
"unverifiedNoteFew": "{count} values still need checking and stay pending.",
"unverifiedNoteOther": "{count} values still need checking and stay pending.",
"finish": "Finish review",
"confirmFailed": "The review couldn't be saved. Try again.",
"savedToastOne": "1 value saved.",
"savedToastFew": "{count} values saved.",
"savedToastOther": "{count} values saved.",
"nothingSavedToast": "Review saved. No values were added.",
"extract": "Extract lab values",
"extracting": "Extracting…",
"extractHint": "Uses the text already read from this document. Extracted values wait for your review; nothing is saved automatically.",
"extractEmpty": "No values could be extracted from this document.",
"failUnitRequired": "A numeric value needs a unit before it can be saved.",
"failUnitMismatch": "The stated unit does not match the saved unit for this marker. Adjust it, then finish the review again.",
"failGeneric": "This value could not be saved."
},
"contentIndex": {
"indexPrompt": "Make document contents searchable.",
"indexAll": "Index all for search",
+45
View File
@@ -9567,6 +9567,7 @@
"errorBudget": "Tu presupuesto de IA de hoy se ha agotado.",
"errorPdfNeedsVision": "Escanear PDF requiere un proveedor de visión Claude.",
"errorFileType": "Este tipo de archivo no se puede leer.",
"errorNotIndexed": "Primero lee el documento y luego extrae.",
"errorLocalOcrDisabled": "Activa primero el OCR local en los ajustes de IA.",
"errorProvider": "No hay ningún proveedor de IA configurado para esto.",
"errorTextImageOnly": "El OCR local solo lee imágenes, no este archivo."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "La IA leyó tu documento.",
"readStagedOne": "La IA leyó tu documento. 1 valor de laboratorio espera tu revisión.",
"readStagedFew": "La IA leyó tu documento. {count} valores de laboratorio esperan tu revisión.",
"readStagedOther": "La IA leyó tu documento. {count} valores de laboratorio esperan tu revisión.",
"read": "Leer con IA",
"reread": "Leer de nuevo",
"reading": "Leyendo…",
"notReadYet": "Este documento aún no se ha leído."
},
"review": {
"title": "Revisar valores extraídos",
"hint": "Aprueba lo que coincida con el documento. Los valores sin marcar se descartan; nada se guarda sin tu confirmación.",
"openOne": "Revisar valor extraído",
"openFew": "Revisar valores extraídos ({count})",
"openOther": "Revisar valores extraídos ({count})",
"includeAria": "Incluir {value}",
"type": {
"OBSERVATION": "Valor de laboratorio",
"CONDITION": "Afección",
"MEDICATION_STATEMENT": "Medicamento"
},
"statedRange": "rango indicado {range}",
"needsCheck": "Comprueba este valor contra el documento y luego guárdalo.",
"verify": "Comprobar",
"verifySave": "Guardar valor",
"verifyInvalid": "Indica un nombre y un valor numérico o un resultado en texto, no ambos.",
"verifyFailed": "No se pudo guardar la corrección. Inténtalo de nuevo.",
"fieldName": "Nombre",
"fieldDate": "Fecha",
"fieldValue": "Valor",
"fieldValueText": "Resultado (texto)",
"fieldUnit": "Unidad",
"fieldDose": "Dosis",
"unverifiedNoteOne": "1 valor aún necesita comprobación y queda pendiente.",
"unverifiedNoteFew": "{count} valores aún necesitan comprobación y quedan pendientes.",
"unverifiedNoteOther": "{count} valores aún necesitan comprobación y quedan pendientes.",
"finish": "Terminar revisión",
"confirmFailed": "No se pudo guardar la revisión. Inténtalo de nuevo.",
"savedToastOne": "1 valor guardado.",
"savedToastFew": "{count} valores guardados.",
"savedToastOther": "{count} valores guardados.",
"nothingSavedToast": "Revisión guardada. No se añadió ningún valor.",
"extract": "Extraer valores de laboratorio",
"extracting": "Extrayendo…",
"extractHint": "Usa el texto ya leído de este documento. Los valores extraídos esperan tu revisión; nada se guarda automáticamente.",
"extractEmpty": "No se pudieron extraer valores de este documento.",
"failUnitRequired": "Un valor numérico necesita una unidad antes de poder guardarse.",
"failUnitMismatch": "La unidad indicada no coincide con la unidad guardada de este marcador. Ajústala y termina la revisión de nuevo.",
"failGeneric": "Este valor no se pudo guardar."
},
"contentIndex": {
"indexPrompt": "Haz que el contenido de los documentos sea buscable.",
"indexAll": "Indexar todo para búsqueda",
+45
View File
@@ -9567,6 +9567,7 @@
"errorBudget": "Votre budget IA du jour est épuisé.",
"errorPdfNeedsVision": "La lecture des PDF nécessite un fournisseur de vision Claude.",
"errorFileType": "Ce type de fichier ne peut pas être lu.",
"errorNotIndexed": "Lisez d’abord le document, puis extrayez.",
"errorLocalOcrDisabled": "Activez d'abord l'OCR local dans les paramètres d'IA.",
"errorProvider": "Aucun fournisseur d'IA n'est configuré pour cela.",
"errorTextImageOnly": "L'OCR local ne lit que les images, pas ce fichier."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "L’IA a lu votre document.",
"readStagedOne": "L’IA a lu votre document. 1 valeur de laboratoire attend votre vérification.",
"readStagedFew": "L’IA a lu votre document. {count} valeurs de laboratoire attendent votre vérification.",
"readStagedOther": "L’IA a lu votre document. {count} valeurs de laboratoire attendent votre vérification.",
"read": "Lire avec l’IA",
"reread": "Relire",
"reading": "Lecture…",
"notReadYet": "Ce document n’a pas encore été lu."
},
"review": {
"title": "Vérifier les valeurs extraites",
"hint": "Approuvez ce qui correspond au document. Les valeurs non cochées sont écartées ; rien n’est enregistré sans votre confirmation.",
"openOne": "Vérifier la valeur extraite",
"openFew": "Vérifier les valeurs extraites ({count})",
"openOther": "Vérifier les valeurs extraites ({count})",
"includeAria": "Inclure {value}",
"type": {
"OBSERVATION": "Valeur de laboratoire",
"CONDITION": "Affection",
"MEDICATION_STATEMENT": "Médicament"
},
"statedRange": "plage indiquée {range}",
"needsCheck": "Vérifiez cette valeur par rapport au document, puis enregistrez-la.",
"verify": "Vérifier",
"verifySave": "Enregistrer la valeur",
"verifyInvalid": "Indiquez un nom et soit une valeur numérique, soit un résultat en texte, pas les deux.",
"verifyFailed": "La correction n’a pas pu être enregistrée. Réessayez.",
"fieldName": "Nom",
"fieldDate": "Date",
"fieldValue": "Valeur",
"fieldValueText": "Résultat (texte)",
"fieldUnit": "Unité",
"fieldDose": "Dose",
"unverifiedNoteOne": "1 valeur reste à vérifier et demeure en attente.",
"unverifiedNoteFew": "{count} valeurs restent à vérifier et demeurent en attente.",
"unverifiedNoteOther": "{count} valeurs restent à vérifier et demeurent en attente.",
"finish": "Terminer la vérification",
"confirmFailed": "La vérification n’a pas pu être enregistrée. Réessayez.",
"savedToastOne": "1 valeur enregistrée.",
"savedToastFew": "{count} valeurs enregistrées.",
"savedToastOther": "{count} valeurs enregistrées.",
"nothingSavedToast": "Vérification enregistrée. Aucune valeur n’a été ajoutée.",
"extract": "Extraire les valeurs de laboratoire",
"extracting": "Extraction…",
"extractHint": "Utilise le texte déjà lu de ce document. Les valeurs extraites attendent votre vérification ; rien n’est enregistré automatiquement.",
"extractEmpty": "Aucune valeur n’a pu être extraite de ce document.",
"failUnitRequired": "Une valeur numérique a besoin d’une unité avant de pouvoir être enregistrée.",
"failUnitMismatch": "L’unité indiquée ne correspond pas à l’unité enregistrée pour ce marqueur. Ajustez-la, puis terminez à nouveau la vérification.",
"failGeneric": "Cette valeur n’a pas pu être enregistrée."
},
"contentIndex": {
"indexPrompt": "Rendre le contenu des documents consultable.",
"indexAll": "Tout indexer pour la recherche",
+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",
+45
View File
@@ -9567,6 +9567,7 @@
"errorBudget": "Twój dzisiejszy budżet AI został wyczerpany.",
"errorPdfNeedsVision": "Skanowanie plików PDF wymaga dostawcy wizji Claude.",
"errorFileType": "Tego typu pliku nie można odczytać.",
"errorNotIndexed": "Najpierw odczytaj dokument, potem wyodrębnij.",
"errorLocalOcrDisabled": "Najpierw włącz lokalne OCR w ustawieniach AI.",
"errorProvider": "Nie skonfigurowano dostawcy AI do tego celu.",
"errorTextImageOnly": "Lokalne OCR odczytuje tylko obrazy, nie ten plik."
@@ -9580,11 +9581,55 @@
},
"ai": {
"readDone": "AI odczytało Twój dokument.",
"readStagedOne": "AI odczytało Twój dokument. 1 wynik laboratoryjny czeka na Twoją weryfikację.",
"readStagedFew": "AI odczytało Twój dokument. {count} wyniki laboratoryjne czekają na Twoją weryfikację.",
"readStagedOther": "AI odczytało Twój dokument. {count} wyników laboratoryjnych czeka na Twoją weryfikację.",
"read": "Odczytaj z AI",
"reread": "Odczytaj ponownie",
"reading": "Odczytywanie…",
"notReadYet": "Ten dokument nie został jeszcze odczytany."
},
"review": {
"title": "Przejrzyj odczytane wartości",
"hint": "Zatwierdź to, co zgadza się z dokumentem. Niezaznaczone wartości zostaną odrzucone; nic nie zapisuje się bez Twojego potwierdzenia.",
"openOne": "Przejrzyj odczytaną wartość",
"openFew": "Przejrzyj odczytane wartości ({count})",
"openOther": "Przejrzyj odczytane wartości ({count})",
"includeAria": "Uwzględnij {value}",
"type": {
"OBSERVATION": "Wynik laboratoryjny",
"CONDITION": "Schorzenie",
"MEDICATION_STATEMENT": "Lek"
},
"statedRange": "podany zakres {range}",
"needsCheck": "Sprawdź tę wartość z dokumentem, a potem ją zapisz.",
"verify": "Sprawdź",
"verifySave": "Zapisz wartość",
"verifyInvalid": "Podaj nazwę oraz wartość liczbową albo wynik tekstowy, nie oba naraz.",
"verifyFailed": "Nie udało się zapisać poprawki. Spróbuj ponownie.",
"fieldName": "Nazwa",
"fieldDate": "Data",
"fieldValue": "Wartość",
"fieldValueText": "Wynik (tekst)",
"fieldUnit": "Jednostka",
"fieldDose": "Dawka",
"unverifiedNoteOne": "1 wartość wymaga jeszcze sprawdzenia i pozostaje w oczekiwaniu.",
"unverifiedNoteFew": "{count} wartości wymagają jeszcze sprawdzenia i pozostają w oczekiwaniu.",
"unverifiedNoteOther": "{count} wartości wymaga jeszcze sprawdzenia i pozostaje w oczekiwaniu.",
"finish": "Zakończ przegląd",
"confirmFailed": "Nie udało się zapisać przeglądu. Spróbuj ponownie.",
"savedToastOne": "Zapisano 1 wartość.",
"savedToastFew": "Zapisano {count} wartości.",
"savedToastOther": "Zapisano {count} wartości.",
"nothingSavedToast": "Przegląd zapisany. Nie dodano żadnych wartości.",
"extract": "Odczytaj wyniki laboratoryjne",
"extracting": "Odczytywanie…",
"extractHint": "Korzysta z tekstu już odczytanego z tego dokumentu. Odczytane wartości czekają na Twoją weryfikację; nic nie zapisuje się automatycznie.",
"extractEmpty": "Z tego dokumentu nie udało się odczytać żadnych wartości.",
"failUnitRequired": "Wartość liczbowa potrzebuje jednostki, zanim będzie można ją zapisać.",
"failUnitMismatch": "Podana jednostka nie zgadza się z zapisaną jednostką tego wskaźnika. Popraw ją i zakończ przegląd ponownie.",
"failGeneric": "Nie udało się zapisać tej wartości."
},
"contentIndex": {
"indexPrompt": "Udostępnij treść dokumentów do wyszukiwania.",
"indexAll": "Zindeksuj wszystko do wyszukiwania",