41 lines
871 B
Python
41 lines
871 B
Python
#!/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()
|