Files
reporty/55 Dekurz show decoded.py
2025-10-24 18:55:29 +02:00

37 lines
805 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
from Functions import get_medicus_connection
# ===== connection =====
con = get_medicus_connection()
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()