diff --git a/Knihovny/medicus_db.py b/Knihovny/medicus_db.py index f0978ac..f992165 100644 --- a/Knihovny/medicus_db.py +++ b/Knihovny/medicus_db.py @@ -20,7 +20,8 @@ def get_medicus_connection(): "Z230": r"reporter:c:\medicus\medicus.fdb", } dsn = dsn_map.get(computer_name, r"localhost:c:\medicus 3\data\medicus.fdb") - print(f"[medicus_db] Připojuji se jako {computer_name} → {dsn}") + import sys + print(f"[medicus_db] Pripojuji se jako {computer_name} -> {dsn}", file=sys.stderr, flush=True) return fdb.connect(dsn=dsn, user="SYSDBA", password="masterkey", charset="win1250") diff --git a/mcp_firebird.py b/mcp_firebird.py index b578ad4..29694d3 100644 --- a/mcp_firebird.py +++ b/mcp_firebird.py @@ -429,18 +429,26 @@ def get_patient_prescriptions(idpac: int, months: int = 6) -> dict: return {'error': f'Pacient IDPAC={idpac} nenalezen'} cur.execute(""" - SELECT DATUM, LEK, DSIG + SELECT DATUM, LEK, DSIG, TEXT FROM RECEPT WHERE IDPAC = ? - AND DATUM >= DATEADD(-? MONTH TO CURRENT_DATE) + AND DATUM >= DATEADD(? MONTH TO CURRENT_DATE) ORDER BY DATUM DESC, ID DESC - """, [idpac, months]) + """, [idpac, -months]) import datetime + def parse_baleni(text): + """Z TEXT sloupce vytáhne druhý řádek s info o balení (dávka, forma, počet).""" + if not text: + return '' + parts = text.replace('\r\n', '\n').split('\n') + return parts[1].strip() if len(parts) > 1 else '' + recepty = [ { 'datum': r[0].isoformat() if isinstance(r[0], datetime.date) else r[0], 'lek': r[1], + 'baleni': parse_baleni(r[3]), 'dsig': r[2] or '', } for r in cur.fetchall()