This commit is contained in:
2025-10-21 12:43:32 +02:00
parent 1f0b3a5d31
commit ea43e53949
3 changed files with 259 additions and 0 deletions

40
55 Dekurz show decoded.py Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Show decoded physician notes (RTF → plain text) directly in console.
"""
import fdb
from striprtf.striprtf import rtf_to_text
# ===== connection =====
con = fdb.connect(
dsn='localhost:z:\\Medicus 3\\data\\medicus.fdb',
user='sysdba',
password='masterkey',
charset='WIN1250'
)
cur = con.cursor()
# ===== pick a few recent records =====
cur.execute('SELECT ID, DATUM, "DEKURS" FROM DEKURS ORDER BY DATUM DESC ROWS 5')
for id_, datum, rtf in cur.fetchall():
print("=" * 80)
print(f"ID: {id_} | Datum: {datum}")
if not rtf:
print("(empty)")
continue
try:
plain = rtf_to_text(rtf)
except Exception as e:
plain = f"[decode error: {e}]"
print(plain.strip()[:1500]) # show first 1500 chars of decoded text
print()
cur.close()
con.close()