4f586f4b57
- faktury_report.py: nový list ED_PODANI (ED_BOOKOFSUBMISSIONS) s přehledem podání pojišťovnám - faktury_report.py: nový list ED_PODANI_DATA s dekódovaným obsahem dávek (KDAVKA, REQUEST XML, odpovědi pojišťoven) - Opraveno kódování: KDAVKA=cp1250, REQUEST detekce BOM (utf-16/utf-8), SERVERRESPONSE/PROTOCOL=iso-8859-2 - Hyperlinky ED_PODANI ↔ ED_PODANI_DATA a Faktura → FAK - FakturaceADavky.md: dokumentace ED_* tabulek, portálů pojišťoven, formátů REQUEST XML - Průzkumné skripty: find_edavky_table, explore_hpn, explore_ed_bookofsubmissions, parse_trace_edavky aj. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
107 lines
3.2 KiB
Python
107 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys, io
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
import fdb
|
|
|
|
conn = fdb.connect(
|
|
dsn=r'localhost:c:\medicus 3\data\medicus.fdb',
|
|
user='SYSDBA', password='masterkey', charset='win1250'
|
|
)
|
|
cur = conn.cursor()
|
|
|
|
print("=" * 60)
|
|
print("1. Sloupce HPN_PODANI")
|
|
print("=" * 60)
|
|
cur.execute("""
|
|
SELECT rf.RDB$FIELD_NAME, rf.RDB$FIELD_POSITION
|
|
FROM RDB$RELATION_FIELDS rf
|
|
WHERE rf.RDB$RELATION_NAME = 'HPN_PODANI'
|
|
ORDER BY rf.RDB$FIELD_POSITION
|
|
""")
|
|
col_names = [r[0].strip() for r in cur.fetchall()]
|
|
print(f" Sloupce: {col_names}")
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print("2. Ukazka HPN_PODANI (bez BLOB ODPOVED)")
|
|
print("=" * 60)
|
|
safe_cols = [c for c in col_names if c != 'ODPOVED']
|
|
cur.execute(f"SELECT FIRST 10 {', '.join(safe_cols)} FROM HPN_PODANI ORDER BY ODESLANO DESC")
|
|
rows = cur.fetchall()
|
|
for row in rows:
|
|
print(dict(zip(safe_cols, row)))
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print("3. Hledej tabulky s POJ nebo ZP sloupcem + data od 2026-02")
|
|
print("=" * 60)
|
|
|
|
# Najdi vsechny tabulky ktere maji sloupec POJ nebo ZP
|
|
cur.execute("""
|
|
SELECT DISTINCT rf.RDB$RELATION_NAME
|
|
FROM RDB$RELATION_FIELDS rf
|
|
JOIN RDB$RELATIONS r ON r.RDB$RELATION_NAME = rf.RDB$RELATION_NAME
|
|
WHERE r.RDB$SYSTEM_FLAG = 0
|
|
AND (TRIM(rf.RDB$FIELD_NAME) = 'POJ' OR TRIM(rf.RDB$FIELD_NAME) = 'ZP')
|
|
ORDER BY rf.RDB$RELATION_NAME
|
|
""")
|
|
poj_tables = [r[0].strip() for r in cur.fetchall()]
|
|
print(f" Tabulky s POJ/ZP: {len(poj_tables)}")
|
|
|
|
# Z techto tabulek vyber ty ktere maji ODESLANO nebo DATUM a data od 2026-02
|
|
hits = []
|
|
for table in poj_tables:
|
|
cur.execute(f"""
|
|
SELECT rf.RDB$FIELD_NAME
|
|
FROM RDB$RELATION_FIELDS rf
|
|
WHERE rf.RDB$RELATION_NAME = '{table}'
|
|
AND (TRIM(rf.RDB$FIELD_NAME) LIKE '%ODESLAN%'
|
|
OR TRIM(rf.RDB$FIELD_NAME) LIKE '%VYTVOR%'
|
|
OR TRIM(rf.RDB$FIELD_NAME) = 'DATUM')
|
|
""")
|
|
date_cols = [r[0].strip() for r in cur.fetchall()]
|
|
for dc in date_cols:
|
|
try:
|
|
cur.execute(f"SELECT COUNT(*) FROM {table} WHERE {dc} >= '2026-02-01'")
|
|
cnt = cur.fetchone()[0]
|
|
if cnt > 0:
|
|
hits.append((table, dc, cnt))
|
|
except Exception:
|
|
pass
|
|
|
|
hits.sort(key=lambda x: -x[2])
|
|
for table, dc, cnt in hits:
|
|
print(f" {table:<40} {dc}: {cnt} od 2026-02")
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print("4. Hledej tabulky s PODACI_CISLO nebo PODAC nebo ID_PODANI")
|
|
print("=" * 60)
|
|
cur.execute("""
|
|
SELECT DISTINCT rf.RDB$RELATION_NAME, rf.RDB$FIELD_NAME
|
|
FROM RDB$RELATION_FIELDS rf
|
|
JOIN RDB$RELATIONS r ON r.RDB$RELATION_NAME = rf.RDB$RELATION_NAME
|
|
WHERE r.RDB$SYSTEM_FLAG = 0
|
|
AND (TRIM(rf.RDB$FIELD_NAME) LIKE '%PODACI%'
|
|
OR TRIM(rf.RDB$FIELD_NAME) = 'ID_PODANI'
|
|
OR TRIM(rf.RDB$FIELD_NAME) LIKE '%PODANI%')
|
|
ORDER BY rf.RDB$RELATION_NAME
|
|
""")
|
|
for r in cur.fetchall():
|
|
print(f" {r[0].strip():<40} sloupec: {r[1].strip()}")
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print("5. PORTAL - co tam chybi od 2026-02?")
|
|
print("=" * 60)
|
|
cur.execute("""
|
|
SELECT FIRST 5 ID, IDFAK, ODESLANO, STAV, ID_PODANI, DAVKA_ROK, BB_DAVKA, BB_FAKTURA
|
|
FROM PORTAL
|
|
ORDER BY ODESLANO DESC
|
|
""")
|
|
for row in cur.fetchall():
|
|
print(f" {row}")
|
|
|
|
conn.close()
|
|
print("\nHotovo.")
|