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",