This commit is contained in:
2026-05-26 08:23:10 +02:00
parent 7c29394145
commit 6e7dabeb40
2 changed files with 13 additions and 4 deletions
+2 -1
View File
@@ -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")
+11 -3
View File
@@ -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()