Report_AgendaPozadavky: přidán list Agenda kompletní z medevio_agenda
- Nový sheet "Agenda kompletní" načtený z MySQL tabulky medevio_agenda - Stejný formát a styling jako ostatní listy - 4545 řádků (historická + budoucí agenda) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ Full Medevio Report:
|
|||||||
- Agenda (API, next 30 days)
|
- Agenda (API, next 30 days)
|
||||||
- Otevřené požadavky (MySQL)
|
- Otevřené požadavky (MySQL)
|
||||||
- Merged (Agenda + Open, deduplicated)
|
- Merged (Agenda + Open, deduplicated)
|
||||||
|
- Agenda kompletní (MySQL medevio_agenda, všechny záznamy)
|
||||||
- Vaccine sheets (from merged data)
|
- Vaccine sheets (from merged data)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -196,13 +197,13 @@ df_agenda = pd.DataFrame(rows).sort_values(["Date", "Time"])
|
|||||||
print(f"✅ Loaded {len(df_agenda)} agenda rows.")
|
print(f"✅ Loaded {len(df_agenda)} agenda rows.")
|
||||||
|
|
||||||
|
|
||||||
# ==================== 2️⃣ LOAD OPEN REQUESTS (MySQL) ====================
|
# ==================== 2️⃣ LOAD OPEN REQUESTS + COMPLETE AGENDA (MySQL) ====================
|
||||||
print("📡 Loading open requests from MySQL...")
|
print("📡 Loading open requests and complete agenda from MySQL...")
|
||||||
conn = pymysql.connect(**DB_CONFIG)
|
conn = pymysql.connect(**DB_CONFIG)
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
id AS Request_ID,
|
id AS Request_ID,
|
||||||
displayTitle AS Title,
|
displayTitle AS Title,
|
||||||
pacient_prijmeni AS Pacient_Prijmeni,
|
pacient_prijmeni AS Pacient_Prijmeni,
|
||||||
@@ -215,6 +216,28 @@ with conn.cursor() as cur:
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
|
|
||||||
|
with conn.cursor() as cur:
|
||||||
|
cur.execute(
|
||||||
|
"""
|
||||||
|
SELECT
|
||||||
|
date AS Date,
|
||||||
|
time_interval AS Time,
|
||||||
|
request_title AS Title,
|
||||||
|
patient_surname AS surname,
|
||||||
|
patient_name AS name,
|
||||||
|
patient_dob AS DOB,
|
||||||
|
insurance_short AS Insurance,
|
||||||
|
note AS Note,
|
||||||
|
color AS Color,
|
||||||
|
request_id AS Request_ID,
|
||||||
|
reservation_id AS Reservation_ID
|
||||||
|
FROM medevio_agenda
|
||||||
|
ORDER BY date, time_interval
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
agenda_full_rows = cur.fetchall()
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
df_open = pd.DataFrame(rows)
|
df_open = pd.DataFrame(rows)
|
||||||
@@ -246,6 +269,17 @@ if not df_open.empty:
|
|||||||
]
|
]
|
||||||
print(f"✅ Loaded {len(df_open)} open requests.")
|
print(f"✅ Loaded {len(df_open)} open requests.")
|
||||||
|
|
||||||
|
df_agenda_full = pd.DataFrame(agenda_full_rows)
|
||||||
|
if not df_agenda_full.empty:
|
||||||
|
df_agenda_full["Patient"] = (
|
||||||
|
df_agenda_full["surname"].fillna("") + " " + df_agenda_full["name"].fillna("")
|
||||||
|
).str.strip()
|
||||||
|
df_agenda_full = df_agenda_full[
|
||||||
|
["Date", "Time", "Title", "Patient", "DOB", "Insurance", "Note", "Color", "Request_ID", "Reservation_ID"]
|
||||||
|
].fillna("")
|
||||||
|
df_agenda_full["Date"] = df_agenda_full["Date"].astype(str)
|
||||||
|
print(f"✅ Loaded {len(df_agenda_full)} rows from medevio_agenda.")
|
||||||
|
|
||||||
|
|
||||||
# ==================== 3️⃣ MERGE + DEDUPLICATE ====================
|
# ==================== 3️⃣ MERGE + DEDUPLICATE ====================
|
||||||
print("🟢 Merging and deduplicating (Agenda preferred)...")
|
print("🟢 Merging and deduplicating (Agenda preferred)...")
|
||||||
@@ -276,12 +310,14 @@ with pd.ExcelWriter(xlsx_path, engine="openpyxl") as writer:
|
|||||||
df_agenda.to_excel(writer, sheet_name="Agenda", index=False)
|
df_agenda.to_excel(writer, sheet_name="Agenda", index=False)
|
||||||
df_open.to_excel(writer, sheet_name="Otevřené požadavky", index=False)
|
df_open.to_excel(writer, sheet_name="Otevřené požadavky", index=False)
|
||||||
df_merged.to_excel(writer, sheet_name="Merged", index=False)
|
df_merged.to_excel(writer, sheet_name="Merged", index=False)
|
||||||
|
df_agenda_full.to_excel(writer, sheet_name="Agenda kompletní", index=False)
|
||||||
|
|
||||||
wb = load_workbook(xlsx_path)
|
wb = load_workbook(xlsx_path)
|
||||||
for name, df_ref in [
|
for name, df_ref in [
|
||||||
("Agenda", df_agenda),
|
("Agenda", df_agenda),
|
||||||
("Otevřené požadavky", df_open),
|
("Otevřené požadavky", df_open),
|
||||||
("Merged", df_merged),
|
("Merged", df_merged),
|
||||||
|
("Agenda kompletní", df_agenda_full),
|
||||||
]:
|
]:
|
||||||
ws = wb[name]
|
ws = wb[name]
|
||||||
format_ws(ws, df_ref)
|
format_ws(ws, df_ref)
|
||||||
|
|||||||
Reference in New Issue
Block a user