import fdb
import datetime

conn = fdb.connect(
    dsn=r'localhost:c:\medicus 3\data\medicus.fdb',
    user='SYSDBA', password='masterkey', charset='win1250'
)
cur = conn.cursor()

cur.execute('SELECT MAX(ID) FROM DEKURS')
next_id = cur.fetchone()[0] + 1
print('Next ID:', next_id)

text = r'{\rtf1\ansi\ansicpg1250\uc1\deff0\deflang1029{\fonttbl{\f0\fnil\fcharset238 Arial;}}{\colortbl ;\red0\green0\blue255;\red0\green128\blue0;\red0\green0\blue0;}' + '\n' + r'\pard\plain\f0\fs20 Test Claude AI - automaticky vlo\u382en\'fd z\'e1znam 13.03.2026\par' + '\n}'

cur.execute("""
    INSERT INTO DEKURS (ID, IDPAC, IDODD, IDPRAC, IDUZI, DATUM, CAS, DEKURS, DGN1)
    VALUES (?, 9742, 2, 2, 6, ?, ?, ?, 'Z000 ')
""", (next_id, datetime.date(2026, 3, 13), datetime.time(12, 0, 0), text))

conn.commit()
print('Vloženo OK, ID:', next_id)
conn.close()
