diff --git a/eb_dashboard.py b/eb_dashboard.py index 2e5bd7d..525911c 100644 --- a/eb_dashboard.py +++ b/eb_dashboard.py @@ -119,6 +119,7 @@ refresh_token = "" threads_list = [] _token_refresh_lock = threading.Lock() on_retry_exhausted = "ask" # "ask" | "ignore" | "abort" — set at startup +fetch_six_month_visit = False # Whether to fetch 6-month visit data (slow, ~5s per patient) _stored_username = "" # Credentials stored at login for automatic re-login _stored_password = "" _threads_list_lock = threading.Lock() @@ -354,6 +355,19 @@ def ask_on_retry_exhausted(): on_retry_exhausted = "abort" +def ask_fetch_six_month_visit(): + """Asks the user whether to fetch 6-month visit data (slow API call, ~5s per patient).""" + global fetch_six_month_visit + choice = questionary.select( + "Fetch 6-month visit progress data? (slow, ~5s per patient) :", + choices=[ + "No (skip, faster execution)", + "Yes (fetch 6-month visit data)" + ] + ).ask() + fetch_six_month_visit = (choice == "Yes (fetch 6-month visit data)") + + def wait_for_scheduled_launch(): """Asks the user when to start the processing and waits if needed. Options: Immediately / In X minutes / At HH:MM @@ -1238,9 +1252,12 @@ def _process_inclusion_data(inclusion, organization): output_inclusion = {} # --- Prepare all data sources --- - # 1. Launch Visit Search asynchronously (it's slow, ~5s) + # 1. Launch Visit Search asynchronously (it's slow, ~5s) — only if enabled by user # We use run_with_context to pass the patient identity to the new thread - visit_future = subtasks_thread_pool.submit(run_with_context, search_visit_by_pseudo_and_order, ctx, pseudo, 2) + if fetch_six_month_visit: + visit_future = subtasks_thread_pool.submit(run_with_context, search_visit_by_pseudo_and_order, ctx, pseudo, 2) + else: + visit_future = None # 2. Prepare inclusion_data: enrich inclusion with organization info inclusion_data = dict(inclusion) @@ -1265,7 +1282,7 @@ def _process_inclusion_data(inclusion, organization): request_data = None try: - six_month_visit_data = visit_future.result() + six_month_visit_data = visit_future.result() if visit_future is not None else {} except Exception as e: logging.error(f"Error searching 6-month visit for patient {pseudo}: {e}") six_month_visit_data = None @@ -1335,6 +1352,9 @@ def main(): if login_status == "Exit": return + print() + ask_fetch_six_month_visit() + print() number_of_threads = int((questionary.text("Number of threads :", default="12", validate=lambda x: x.isdigit() and 0 < int(x) <= MAX_THREADS).ask())) diff --git a/eb_org_center_mapping.xlsx b/eb_org_center_mapping.xlsx index 3e9213b..83b0032 100644 Binary files a/eb_org_center_mapping.xlsx and b/eb_org_center_mapping.xlsx differ