Optional 6 month visit completeness
This commit is contained in:
@@ -119,6 +119,7 @@ refresh_token = ""
|
|||||||
threads_list = []
|
threads_list = []
|
||||||
_token_refresh_lock = threading.Lock()
|
_token_refresh_lock = threading.Lock()
|
||||||
on_retry_exhausted = "ask" # "ask" | "ignore" | "abort" — set at startup
|
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_username = "" # Credentials stored at login for automatic re-login
|
||||||
_stored_password = ""
|
_stored_password = ""
|
||||||
_threads_list_lock = threading.Lock()
|
_threads_list_lock = threading.Lock()
|
||||||
@@ -354,6 +355,19 @@ def ask_on_retry_exhausted():
|
|||||||
on_retry_exhausted = "abort"
|
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():
|
def wait_for_scheduled_launch():
|
||||||
"""Asks the user when to start the processing and waits if needed.
|
"""Asks the user when to start the processing and waits if needed.
|
||||||
Options: Immediately / In X minutes / At HH:MM
|
Options: Immediately / In X minutes / At HH:MM
|
||||||
@@ -1238,9 +1252,12 @@ def _process_inclusion_data(inclusion, organization):
|
|||||||
output_inclusion = {}
|
output_inclusion = {}
|
||||||
|
|
||||||
# --- Prepare all data sources ---
|
# --- 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
|
# 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
|
# 2. Prepare inclusion_data: enrich inclusion with organization info
|
||||||
inclusion_data = dict(inclusion)
|
inclusion_data = dict(inclusion)
|
||||||
@@ -1265,7 +1282,7 @@ def _process_inclusion_data(inclusion, organization):
|
|||||||
request_data = None
|
request_data = None
|
||||||
|
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
logging.error(f"Error searching 6-month visit for patient {pseudo}: {e}")
|
logging.error(f"Error searching 6-month visit for patient {pseudo}: {e}")
|
||||||
six_month_visit_data = None
|
six_month_visit_data = None
|
||||||
@@ -1335,6 +1352,9 @@ def main():
|
|||||||
if login_status == "Exit":
|
if login_status == "Exit":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print()
|
||||||
|
ask_fetch_six_month_visit()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
number_of_threads = int((questionary.text("Number of threads :", default="12",
|
number_of_threads = int((questionary.text("Number of threads :", default="12",
|
||||||
validate=lambda x: x.isdigit() and 0 < int(x) <= MAX_THREADS).ask()))
|
validate=lambda x: x.isdigit() and 0 < int(x) <= MAX_THREADS).ask()))
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user