#!/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()