medicafe 0.250806.13__py3-none-any.whl → 0.250809.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
MediBot/MediBot.bat CHANGED
@@ -1,7 +1,61 @@
1
- ::MediBot.bat - Updated to use MediCafe entry point
1
+ ::MediBot.bat - Streamlined version with coordinated debug system
2
2
  @echo off
3
3
  setlocal enabledelayedexpansion
4
4
 
5
+ :: Debug mode selection
6
+ echo ========================================
7
+ echo MediCafe Launcher
8
+ echo ========================================
9
+ echo.
10
+ echo Choose your mode:
11
+ echo 1. Normal Mode - Production
12
+ echo 2. Debug Mode - Full diagnostics (Interactive)
13
+ echo 3. Debug Mode - Full diagnostics (Non-Interactive)
14
+ echo.
15
+ set /p debug_choice="Enter your choice (1-3): "
16
+
17
+ if "!debug_choice!"=="1" goto start_normal_mode
18
+ if "!debug_choice!"=="2" goto start_debug_interactive
19
+ if "!debug_choice!"=="3" goto start_debug_noninteractive
20
+ goto start_normal_mode
21
+
22
+ :start_debug_interactive
23
+ echo.
24
+ echo ========================================
25
+ echo DEBUG MODE (INTERACTIVE)
26
+ echo ========================================
27
+ echo Running full diagnostic suite...
28
+ echo.
29
+ set "SKIP_CLS_AFTER_DEBUG=1"
30
+ call "%~dp0full_debug_suite.bat" /interactive
31
+ echo.
32
+ goto normal_mode
33
+
34
+ :start_debug_noninteractive
35
+ echo.
36
+ echo ========================================
37
+ echo DEBUG MODE (NON-INTERACTIVE)
38
+ echo ========================================
39
+ echo Running full diagnostic suite...
40
+ echo.
41
+ set "SKIP_CLS_AFTER_DEBUG=1"
42
+ call "%~dp0full_debug_suite.bat"
43
+ echo.
44
+ goto normal_mode
45
+
46
+ :start_normal_mode
47
+ echo Starting Normal Mode...
48
+ goto normal_mode
49
+
50
+ :normal_mode
51
+ :: Normal production mode - streamlined without excessive debug output
52
+ if not defined SKIP_CLS_AFTER_DEBUG cls
53
+ set "SKIP_CLS_AFTER_DEBUG="
54
+ echo ========================================
55
+ echo MediBot Starting
56
+ echo ========================================
57
+ echo.
58
+
5
59
  :: Define paths with local fallbacks for F: drive dependencies
6
60
  set "source_folder=C:\MEDIANSI\MediCare"
7
61
  set "target_folder=C:\MEDIANSI\MediCare\CSV"
@@ -21,11 +75,26 @@ set "config_file_local=MediBot\json\config.json"
21
75
  set "temp_file_legacy=F:\Medibot\last_update_timestamp.txt"
22
76
  set "temp_file_local=MediBot\last_update_timestamp.txt"
23
77
 
78
+ :: FIXED: Always prioritize local file if it exists
79
+ if exist "%upgrade_medicafe_local%" (
80
+ set "upgrade_medicafe=%upgrade_medicafe_local%"
81
+ set "use_local_update=1"
82
+ ) else (
83
+ set "use_local_update=0"
84
+ )
85
+
24
86
  :: Determine which paths to use based on availability
25
87
  if exist "F:\Medibot" (
26
88
  set "local_storage_path=%local_storage_legacy%"
27
89
  set "config_file=%config_file_legacy%"
28
90
  set "temp_file=%temp_file_legacy%"
91
+
92
+ :: Only use F: drive update script if local doesn't exist
93
+ if "!use_local_update!"=="0" (
94
+ if exist "%upgrade_medicafe_legacy%" (
95
+ set "upgrade_medicafe=%upgrade_medicafe_legacy%"
96
+ )
97
+ )
29
98
  ) else (
30
99
  set "local_storage_path=%local_storage_local%"
31
100
  set "config_file=%config_file_local%"
@@ -34,135 +103,71 @@ if exist "F:\Medibot" (
34
103
  if not exist "MediBot\json" mkdir "MediBot\json" 2>nul
35
104
  if not exist "MediBot\DOWNLOADS" mkdir "MediBot\DOWNLOADS" 2>nul
36
105
  )
106
+
37
107
  set "firefox_path=C:\Program Files\Mozilla Firefox\firefox.exe"
38
108
  set "claims_status_script=..\MediLink\MediLink_ClaimStatus.py"
39
109
  set "deductible_script=..\MediLink\MediLink_Deductible.py"
40
110
  set "package_version="
41
111
  set PYTHONWARNINGS=ignore
42
112
 
43
- :: Check if Python is installed and the path is correctly set
113
+ :: Check if Python is installed
44
114
  python --version >nul 2>&1
45
115
  if %errorlevel% neq 0 (
46
- echo Python is not installed or not added to PATH.
47
- exit /b
116
+ echo [ERROR] Python is not installed or not added to PATH.
117
+ echo Please run in Debug Mode to diagnose Python issues.
118
+ pause
119
+ exit /b 1
48
120
  )
49
121
 
50
122
  :: Check if critical directories exist
51
123
  if not exist "%source_folder%" (
52
- echo.
53
- echo Warning: Source folder not found at: %source_folder%
54
- echo.
55
- echo Would you like to provide an alternate path for the source folder?
124
+ echo [WARNING] Source folder not found at: %source_folder%
56
125
  set /p provide_alt_source="Enter 'Y' to provide alternate path, or any other key to continue: "
57
126
  if /i "!provide_alt_source!"=="Y" (
58
- echo.
59
- echo Please enter the full path to your source folder.
60
- echo Example: C:\MediCare\Data
61
- echo Example with spaces: "G:\My Drive\MediCare\Data"
62
- echo.
63
- echo Note: If your path contains spaces, please include quotes around the entire path.
64
- echo.
65
- set /p alt_source_path="Enter source folder path: "
66
- :: Remove any surrounding quotes from user input and re-add them for consistency
67
- set "alt_source_path=!alt_source_path:"=!"
68
- if exist "!alt_source_path!" (
69
- echo Source folder found at: !alt_source_path!
70
- set "source_folder=!alt_source_path!"
71
- ) else (
72
- echo Source folder not found at: !alt_source_path!
73
- echo Continuing with default path...
74
- )
75
- ) else (
76
- echo Continuing with default path...
127
+ set /p alt_source_folder="Enter the alternate source folder path: "
128
+ if not "!alt_source_folder!"=="" set "source_folder=!alt_source_folder!"
77
129
  )
78
130
  )
79
131
 
80
- if not exist "%local_storage_path%" (
81
- echo.
82
- echo Warning: Local storage path not found at: %local_storage_path%
83
- echo.
84
- echo Would you like to provide an alternate path for the local storage?
85
- set /p provide_alt_storage="Enter 'Y' to provide alternate path, or any other key to continue: "
86
- if /i "!provide_alt_storage!"=="Y" (
87
- echo.
88
- echo Please enter the full path to your local storage folder.
89
- echo Example: C:\MediBot\Downloads
90
- echo Example with spaces: "G:\My Drive\MediBot\Downloads"
91
- echo.
92
- echo Note: If your path contains spaces, please include quotes around the entire path.
93
- echo.
94
- set /p alt_storage_path="Enter local storage path: "
95
- :: Remove any surrounding quotes from user input and re-add them for consistency
96
- set "alt_storage_path=!alt_storage_path:"=!"
97
- if exist "!alt_storage_path!" (
98
- echo Local storage folder found at: !alt_storage_path!
99
- set "local_storage_path=!alt_storage_path!"
100
- ) else (
101
- echo Local storage folder not found at: !alt_storage_path!
102
- echo Continuing with default path...
103
- )
104
- ) else (
105
- echo Continuing with default path...
106
- )
132
+ if not exist "%target_folder%" (
133
+ mkdir "%target_folder%" 2>nul
107
134
  )
108
135
 
109
- if not exist "%target_folder%" (
110
- echo.
111
- echo Warning: Target folder not found at: %target_folder%
112
- echo.
113
- echo Would you like to provide an alternate path for the target folder?
114
- set /p provide_alt_target="Enter 'Y' to provide alternate path, or any other key to continue: "
115
- if /i "!provide_alt_target!"=="Y" (
116
- echo.
117
- echo Please enter the full path to your target folder.
118
- echo Example: C:\MediCare\CSV
119
- echo Example with spaces: "G:\My Drive\MediCare\CSV"
120
- echo.
121
- echo Note: If your path contains spaces, please include quotes around the entire path.
122
- echo.
123
- set /p alt_target_path="Enter target folder path: "
124
- :: Remove any surrounding quotes from user input and re-add them for consistency
125
- set "alt_target_path=!alt_target_path:"=!"
126
- if exist "!alt_target_path!" (
127
- echo Target folder found at: !alt_target_path!
128
- set "target_folder=!alt_target_path!"
129
- ) else (
130
- echo Target folder not found at: !alt_target_path!
131
- echo Continuing with default path...
132
- )
133
- ) else (
134
- echo Continuing with default path...
136
+ :: Check if the MediCafe package is installed
137
+ python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2>nul
138
+ if errorlevel 1 (
139
+ echo [WARNING] MediCafe package not found. Attempting to install...
140
+ python -m pip install medicafe --upgrade
141
+ if errorlevel 1 (
142
+ echo [ERROR] Failed to install MediCafe package.
143
+ echo Please run in Debug Mode to diagnose package issues.
144
+ pause
145
+ exit /b 1
135
146
  )
136
147
  )
137
148
 
138
- :: Check if the MediCafe package is installed and retrieve its version
139
- echo Checking for installed MediCafe package version...
149
+ :: Determine installed MediCafe version
150
+ set "package_version="
151
+ set "medicafe_version="
140
152
  python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
141
153
  set /p package_version=<temp.txt
142
- del temp.txt
143
-
154
+ if exist temp.txt del temp.txt
144
155
  if not defined package_version (
145
- echo MediCafe package version not detected or MediCafe not installed. Consider manual re-install.
146
- exit /b
147
- )
148
-
149
- :: Extract version number and display it
150
- for /f "tokens=2 delims==" %%a in ("%package_version%") do (
151
- set "medicafe_version=%%a"
156
+ rem Fallback: try importing MediCafe and reading __version__
157
+ python -c "import sys;\ntry:\n import MediCafe;\n print('MediCafe=='+getattr(MediCafe, '__version__','unknown'))\nexcept Exception as e:\n print('')" > temp.txt 2>nul
158
+ set /p package_version=<temp.txt
159
+ if exist temp.txt del temp.txt
152
160
  )
153
-
154
- if not defined medicafe_version (
155
- echo Failed to detect MediCafe version.
161
+ if defined package_version (
162
+ for /f "tokens=2 delims==" %%a in ("%package_version%") do set "medicafe_version=%%a"
156
163
  ) else (
157
- echo Detected MediCafe version: %medicafe_version%
158
- ping -n 2 127.0.0.1 >nul
164
+ set "medicafe_version=unknown"
159
165
  )
160
166
 
161
167
  :: Check for internet connectivity
162
- ping -n 1 google.com > nul 2>&1
163
- if %ERRORLEVEL% neq 0 (
168
+ ping -n 1 google.com >nul 2>&1
169
+ if errorlevel 1 (
164
170
  set "internet_available=0"
165
- echo No internet connection detected.
166
171
  ) else (
167
172
  set "internet_available=1"
168
173
  echo Internet connection detected.
@@ -240,171 +245,83 @@ if exist "!alt_config_path!" (
240
245
  echo Checking for the update script...
241
246
  ping -n 2 127.0.0.1 >nul
242
247
 
243
- :: DIAGNOSTIC SECTION - Analyze F: drive accessibility
244
- echo.
245
- echo ==========================================
246
- echo F: DRIVE ACCESSIBILITY DIAGNOSTICS
247
- echo ==========================================
248
- echo.
249
-
250
- :: Check if F: drive exists at all
251
- echo [DIAGNOSTIC] Checking F: drive existence...
252
- if exist "F:\" (
253
- echo [OK] F: drive is accessible
254
-
255
- :: Check F: drive properties
256
- echo [DIAGNOSTIC] F: drive properties:
257
- dir F:\ | find "Directory of" 2>nul || echo [!] Cannot read F: drive directory listing
258
-
259
- :: Check available space
260
- echo [DIAGNOSTIC] F: drive free space:
261
- dir F:\ | find "bytes free" 2>nul || echo [!] Cannot determine free space
262
-
263
- :: Check if F:\Medibot directory exists
264
- echo [DIAGNOSTIC] Checking F:\Medibot directory...
265
- if exist "F:\Medibot" (
266
- echo [OK] F:\Medibot directory exists
267
-
268
- :: Check directory permissions by attempting to create a test file
269
- echo [DIAGNOSTIC] Testing write permissions to F:\Medibot...
270
- echo test > "F:\Medibot\permission_test.tmp" 2>nul
271
- if exist "F:\Medibot\permission_test.tmp" (
272
- echo [OK] Write permissions confirmed
273
- del "F:\Medibot\permission_test.tmp" >nul 2>&1
274
- ) else (
275
- echo [ERROR] PERMISSION DENIED - Cannot write to F:\Medibot
276
- echo [ERROR] This is likely the cause of the path error!
277
- )
278
-
279
- :: List contents of F:\Medibot
280
- echo [DIAGNOSTIC] F:\Medibot directory contents:
281
- dir /b "F:\Medibot" 2>nul || echo [!] Cannot list directory contents (permission issue?)
282
-
283
- :: Check if update_medicafe.py specifically exists
284
- echo [DIAGNOSTIC] Checking for update_medicafe.py...
285
- if exist "F:\Medibot\update_medicafe.py" (
286
- echo [OK] update_medicafe.py found at F:\Medibot\update_medicafe.py
287
- echo [DIAGNOSTIC] File details:
288
- dir "F:\Medibot\update_medicafe.py" 2>nul || echo [!] Cannot read file details
289
-
290
- :: Test file accessibility by attempting to read it
291
- echo [DIAGNOSTIC] Testing file read permissions...
292
- type "F:\Medibot\update_medicafe.py" | find "#update_medicafe.py" >nul 2>&1
293
- if %errorlevel% equ 0 (
294
- echo [OK] File is readable
295
- ) else (
296
- echo [ERROR] FILE READ ERROR - Cannot read update_medicafe.py
297
- echo [ERROR] File exists but is not accessible (permission/lock issue?)
298
- )
299
- ) else (
300
- echo [ERROR] update_medicafe.py NOT FOUND at F:\Medibot\update_medicafe.py
301
- )
302
-
303
- ) else (
304
- echo [ERROR] F:\Medibot directory does NOT exist
305
- echo [DIAGNOSTIC] Attempting to create F:\Medibot...
306
- mkdir "F:\Medibot" 2>nul
307
- if exist "F:\Medibot" (
308
- echo [OK] Successfully created F:\Medibot directory
309
- ) else (
310
- echo [ERROR] FAILED to create F:\Medibot directory
311
- echo [ERROR] Permission denied or F: drive is read-only
312
- )
313
- )
314
-
315
- ) else (
316
- echo [ERROR] F: drive is NOT accessible
317
- echo [ERROR] F: drive may be:
318
- echo - Disconnected network drive
319
- echo - Unmounted USB/external drive
320
- echo - Mapped drive that's no longer available
321
- echo - Security policy blocking access
322
-
323
- :: Check what drives are actually available
324
- echo [DIAGNOSTIC] Available drives on this system:
325
- wmic logicaldisk get size,freespace,caption 2>nul || echo [!] Cannot enumerate drives
326
- )
327
-
328
- echo.
329
- echo ==========================================
330
- echo END F: DRIVE DIAGNOSTICS
331
- echo ==========================================
332
- echo.
333
-
334
248
  :: Continue with existing logic but with enhanced error reporting
335
249
  :: First check if we already have it locally
336
250
  if exist "%upgrade_medicafe_local%" (
337
251
  echo Found update_medicafe.py in local directory. No action needed.
338
252
  ping -n 2 127.0.0.1 >nul
339
- ) else if exist "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" (
340
- echo Found update_medicafe.py in site-packages. Copying to local directory...
341
- ping -n 2 127.0.0.1 >nul
342
- :: Ensure MediBot directory exists
343
- if not exist "MediBot" mkdir "MediBot"
344
- copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_local%" >nul 2>&1
345
- if %errorlevel% neq 0 (
346
- echo Copy to local directory failed. Error code: %errorlevel%
347
- echo [DIAGNOSTIC] Attempting copy to F: drive (with detailed error reporting)...
253
+ ) else (
254
+ if exist "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" (
255
+ echo Found update_medicafe.py in site-packages. Copying to local directory...
348
256
  ping -n 2 127.0.0.1 >nul
349
- :: Ensure F:\Medibot directory exists (only if F: drive is accessible)
350
- if exist "F:\" (
351
- if not exist "F:\Medibot" (
352
- echo [DIAGNOSTIC] Creating F:\Medibot directory...
353
- mkdir "F:\Medibot" 2>nul
257
+ :: Ensure MediBot directory exists
258
+ if not exist "MediBot" mkdir "MediBot"
259
+ copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_local%" >nul 2>&1
260
+ if %errorlevel% neq 0 (
261
+ echo Copy to local directory failed. Error code: %errorlevel%
262
+ echo [DIAGNOSTIC] Attempting copy to F: drive - detailed error reporting
263
+ ping -n 2 127.0.0.1 >nul
264
+ :: Ensure F:\Medibot directory exists (only if F: drive is accessible)
265
+ if exist "F:\" (
354
266
  if not exist "F:\Medibot" (
355
- echo [ERROR] Failed to create F:\Medibot - Permission denied or read-only drive
267
+ echo [DIAGNOSTIC] Creating F:\Medibot directory...
268
+ mkdir "F:\Medibot" 2>nul
269
+ if not exist "F:\Medibot" (
270
+ echo [ERROR] Failed to create F:\Medibot - Permission denied or read-only drive
271
+ )
356
272
  )
357
- )
358
- if exist "F:\Medibot" (
359
- echo [DIAGNOSTIC] Attempting file copy to F:\Medibot...
360
- copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_legacy%" 2>nul
361
- if %errorlevel% neq 0 (
362
- echo [ERROR] Copy to F:\Medibot failed with error code: %errorlevel%
363
- echo [ERROR] Possible causes:
364
- echo - Permission denied (insufficient write access)
365
- echo - Disk full
366
- echo - File locked by another process
367
- echo - Antivirus blocking the operation
368
- ) else (
369
- echo [SUCCESS] File copied to F:\Medibot successfully
273
+ if exist "F:\Medibot" (
274
+ echo [DIAGNOSTIC] Attempting file copy to F:\Medibot...
275
+ copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_legacy%" 2>nul
276
+ if %errorlevel% neq 0 (
277
+ echo [ERROR] Copy to F:\Medibot failed with error code: %errorlevel%
278
+ echo [ERROR] Possible causes:
279
+ echo - Permission denied [insufficient write access]
280
+ echo - Disk full
281
+ echo - File locked by another process
282
+ echo - Antivirus blocking the operation
283
+ ) else (
284
+ echo [SUCCESS] File copied to F:\Medibot successfully
285
+ )
370
286
  )
287
+ ) else (
288
+ echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
371
289
  )
372
290
  ) else (
373
- echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
291
+ echo File copied to local directory successfully.
292
+ ping -n 2 127.0.0.1 >nul
374
293
  )
375
294
  ) else (
376
- echo File copied to local directory successfully.
377
- ping -n 2 127.0.0.1 >nul
378
- )
379
- ) else if exist "%upgrade_medicafe_legacy%" (
380
- echo Found update_medicafe.py in legacy F: drive location.
381
- echo [DIAGNOSTIC] Verifying F: drive file accessibility...
382
- type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1
383
- if %errorlevel% equ 0 (
384
- echo [OK] F: drive file is accessible and readable
385
- ) else (
386
- echo [ERROR] F: drive file exists but cannot be read (permission/lock issue)
295
+ if exist "%upgrade_medicafe_legacy%" (
296
+ echo Found update_medicafe.py in legacy F: drive location.
297
+ echo [DIAGNOSTIC] Verifying F: drive file accessibility...
298
+ type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1
299
+ if %errorlevel% equ 0 (
300
+ echo [OK] F: drive file is accessible and readable
301
+ ) else (
302
+ echo [ERROR] F: drive file exists but cannot be read [permission/lock issue]
303
+ )
304
+ ping -n 2 127.0.0.1 >nul
305
+ ) else (
306
+ echo update_medicafe.py not detected in any known location.
307
+ echo.
308
+ echo Checked locations:
309
+ echo - Site-packages: C:\Python34\Lib\site-packages\MediBot\update_medicafe.py
310
+ echo - Local: %upgrade_medicafe_local%
311
+ echo - Legacy: %upgrade_medicafe_legacy%
312
+ echo.
313
+ echo [DIAGNOSTIC] Current working directory:
314
+ cd
315
+ echo [DIAGNOSTIC] Current directory contents:
316
+ dir /b
317
+ echo.
318
+ echo [DIAGNOSTIC] MediBot directory contents:
319
+ dir /b MediBot\ 2>nul || echo MediBot directory not found
320
+ echo.
321
+ echo Continuing without update script...
322
+ ping -n 2 127.0.0.1 >nul
323
+ )
387
324
  )
388
- ping -n 2 127.0.0.1 >nul
389
- ) else (
390
- echo update_medicafe.py not detected in any known location.
391
- echo.
392
- echo Checked locations:
393
- echo - Site-packages: C:\Python34\Lib\site-packages\MediBot\update_medicafe.py
394
- echo - Local: %upgrade_medicafe_local%
395
- echo - Legacy: %upgrade_medicafe_legacy%
396
- echo.
397
- echo [DIAGNOSTIC] Current working directory:
398
- cd
399
- echo [DIAGNOSTIC] Current directory contents:
400
- dir /b
401
- echo.
402
- echo [DIAGNOSTIC] MediBot directory contents:
403
- dir /b MediBot\ 2>nul || echo MediBot directory not found
404
- echo.
405
- echo Continuing without update script...
406
- ping -n 2 127.0.0.1 >nul
407
- )
408
325
  )
409
326
 
410
327
  :: Main menu
@@ -412,46 +329,48 @@ if exist "%upgrade_medicafe_local%" (
412
329
  cls
413
330
  echo Version: %medicafe_version%
414
331
  echo --------------------------------------------------------------
415
- echo .//* Welcome to MediCafe *\\.
332
+ echo .//* Welcome to MediBot *\\.
416
333
  echo --------------------------------------------------------------
417
334
  echo.
418
335
 
419
- echo Please select an option:
420
- echo.
421
- if "!internet_available!"=="1" (
422
- echo 1. Update MediCafe
423
- echo.
424
- echo 2. Download Email de Carol
425
- echo.
426
- echo 3. MediLink Claims
427
- echo.
428
- echo 4. ^[United^] Claims Status
429
- echo.
430
- echo 5. ^[United^] Deductible
336
+ if "!internet_available!"=="0" (
337
+ echo NOTE: No internet detected. Options 1-5 require internet.
431
338
  echo.
432
339
  )
340
+ echo Please select an option:
341
+ echo.
342
+ echo 1. Update MediCafe
343
+ echo.
344
+ echo 2. Download Email de Carol
345
+ echo.
346
+ echo 3. MediLink Claims
347
+ echo.
348
+ echo 4. ^[United^] Claims Status
349
+ echo.
350
+ echo 5. ^[United^] Deductible
351
+ echo.
433
352
  echo 6. Run MediBot
434
353
  echo.
435
- echo 7. Troubleshooting: Open Log File
354
+ echo 7. Troubleshooting
436
355
  echo.
437
- echo 8. Troubleshooting: Clear Python Cache
356
+ echo 9. Toggle Performance Logging (session)
438
357
  echo.
439
- echo 9. Exit
358
+ echo 8. Exit
440
359
  echo.
441
360
  set /p choice=Enter your choice:
442
361
 
443
362
  :: Update option numbers
444
- if "!choice!"=="9" goto end_script
445
- if "!choice!"=="8" goto clear_cache
446
- if "!choice!"=="7" goto open_latest_log
363
+ if "!choice!"=="8" goto end_script
364
+ if "!choice!"=="7" goto troubleshooting_menu
447
365
  if "!choice!"=="6" goto medibot_flow
448
366
  if "!choice!"=="5" goto united_deductible
449
367
  if "!choice!"=="4" goto united_claims_status
450
368
  if "!choice!"=="3" goto medilink_flow
451
369
  if "!choice!"=="2" goto download_emails
452
370
  if "!choice!"=="1" goto check_updates
371
+ if "!choice!"=="9" goto toggle_perf_logging
372
+ if "!choice!"=="0" goto end_script
453
373
 
454
- :: Invalid choice - return to menu
455
374
  echo Invalid choice. Please try again.
456
375
  pause
457
376
  goto main_menu
@@ -459,20 +378,14 @@ goto main_menu
459
378
  :: Medicafe Update
460
379
  :check_updates
461
380
  if "!internet_available!"=="0" (
462
- echo No internet connection available.
381
+ echo [WARNING] No internet connection available.
463
382
  goto main_menu
464
383
  )
465
384
 
466
385
  echo ========================================
467
- echo DEBUG: Starting MediCafe Update Process
386
+ echo Starting MediCafe Update Process
468
387
  echo ========================================
469
388
  echo.
470
- echo Current working directory: %CD%
471
- echo Package version: %package_version%
472
- echo Update script path: %upgrade_medicafe%
473
- echo.
474
- echo Press Enter to continue to step 1...
475
- pause >nul
476
389
 
477
390
  :: Step 1: Check if update_medicafe.py exists in expected location
478
391
  echo.
@@ -480,27 +393,28 @@ echo ========================================
480
393
  echo DEBUG STEP 1: Checking for update script
481
394
  echo ========================================
482
395
  echo.
483
- echo Checking for update script (priority: local first, then legacy path)...
396
+ echo Checking for update script - priority: local first, then legacy path
484
397
  if exist "%upgrade_medicafe_local%" (
485
398
  echo [SUCCESS] Found update script at: %upgrade_medicafe_local%
486
399
  echo File size:
487
400
  dir "%upgrade_medicafe_local%" | find "update_medicafe.py"
488
401
  set "upgrade_medicafe=%upgrade_medicafe_local%"
489
- ) else if exist "%upgrade_medicafe_legacy%" (
490
- echo [SUCCESS] Found update script at legacy location: %upgrade_medicafe_legacy%
491
- echo File size:
492
- dir "%upgrade_medicafe_legacy%" | find "update_medicafe.py"
493
- set "upgrade_medicafe=%upgrade_medicafe_legacy%"
494
402
  ) else (
495
- echo [FAILED] Update script not found in either location:
496
- echo - Local: %upgrade_medicafe_local%
497
- echo - Legacy: %upgrade_medicafe_legacy%
498
- echo.
499
- echo Available files in current directory:
500
- dir /b
501
- echo.
502
- echo Available files in MediBot directory:
503
- dir /b MediBot\ 2>nul || echo MediBot directory not found
403
+ if exist "%upgrade_medicafe_legacy%" (
404
+ echo [SUCCESS] Found update script at legacy location: %upgrade_medicafe_legacy%
405
+ echo File size:
406
+ dir "%upgrade_medicafe_legacy%" | find "update_medicafe.py"
407
+ set "upgrade_medicafe=%upgrade_medicafe_legacy%"
408
+ ) else (
409
+ echo [FAILED] Update script not found in either location:
410
+ echo - Local: %upgrade_medicafe_local%
411
+ echo - Legacy: %upgrade_medicafe_legacy%
412
+ echo.
413
+ echo Available files in current directory:
414
+ dir /b
415
+ echo.
416
+ echo Available files in MediBot directory:
417
+ dir /b MediBot\ 2>nul || echo MediBot directory not found
504
418
  )
505
419
  )
506
420
  echo.
@@ -520,7 +434,8 @@ if %errorlevel% neq 0 (
520
434
  echo Current PATH: %PATH%
521
435
  ) else (
522
436
  echo [SUCCESS] Python found
523
- echo Python executable: %PYTHONPATH%
437
+ echo Python executable:
438
+ python -c "import sys; print(sys.executable)"
524
439
  echo Python version:
525
440
  python --version
526
441
  )
@@ -579,27 +494,10 @@ if %errorlevel% neq 0 (
579
494
  echo Press Enter to return to main menu...
580
495
  pause >nul
581
496
  goto main_menu
582
- ) else (
583
- echo [SUCCESS] Internet connection detected
584
- echo Testing PyPI connectivity...
585
- python -c "import requests; print('PyPI accessible:', requests.get('https://pypi.org/pypi/medicafe/json', timeout=5).status_code)" 2>nul
586
- if %errorlevel% neq 0 (
587
- echo [WARNING] PyPI connectivity test failed
588
- ) else (
589
- echo [SUCCESS] PyPI connectivity confirmed
590
- )
591
497
  )
592
- echo.
593
- echo Press Enter to continue to step 5...
594
- pause >nul
595
498
 
596
- :: Step 5: Attempt update with detailed logging
597
- echo.
598
- echo ========================================
599
- echo DEBUG STEP 5: Starting Update Process
600
- echo ========================================
601
- echo.
602
499
  echo Starting update process...
500
+ echo Update script: %upgrade_medicafe%
603
501
  echo.
604
502
 
605
503
  :: Check if update_medicafe.py exists using the new priority system
@@ -624,12 +522,12 @@ if exist "%upgrade_medicafe_local%" (
624
522
  echo The update window will open and show detailed progress.
625
523
  echo All output will be displayed on screen.
626
524
  echo.
627
- start "Medicafe Update" cmd /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_local%\" %package_version% & echo. & python \"%upgrade_medicafe_local%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: %ERRORLEVEL% & echo Update process completed. Press any key to close... & pause >nul" && (
628
- echo %DATE% %TIME% Upgrade initiated successfully (local). >> "%temp_file%"
525
+ start "Medicafe Update" cmd /v:on /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_local%\" %package_version% & echo. & python \"%upgrade_medicafe_local%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: !ERRORLEVEL! & echo Update process completed. Press any key to close... & pause >nul" && (
526
+ echo %DATE% %TIME% Upgrade initiated successfully - local. >> "%temp_file%"
629
527
  echo [SUCCESS] Update process started successfully
630
528
  echo All output will be displayed in the update window.
631
529
  ) || (
632
- echo %DATE% %TIME% Update failed (local). >> "%temp_file%"
530
+ echo %DATE% %TIME% Update failed - local. >> "%temp_file%"
633
531
  echo [ERROR] Upgrade failed. Check the update window for details.
634
532
  echo [DIAGNOSTIC] Possible causes for local script failure:
635
533
  echo - Python not in PATH
@@ -637,31 +535,32 @@ if exist "%upgrade_medicafe_local%" (
637
535
  echo - Missing Python dependencies
638
536
  echo - File corruption
639
537
  )
640
- ) else if exist "%upgrade_medicafe_legacy%" (
641
- echo [INFO] Using legacy update script at: %upgrade_medicafe_legacy%
642
- echo Command: python "%upgrade_medicafe_legacy%" %package_version%
643
-
644
- :: Pre-execution diagnostics for F: drive
645
- echo.
646
- echo [DIAGNOSTIC] Pre-execution checks for F: drive script:
647
- echo [DIAGNOSTIC] File size and permissions:
648
- dir "%upgrade_medicafe_legacy%" 2>nul || echo [!] Cannot read file details
649
- echo [DIAGNOSTIC] Testing Python access to F: drive file:
650
- python -c "import os; print('[OK] Python can access F: drive file') if os.path.exists('%upgrade_medicafe_legacy%') else print('[ERROR] Python cannot access F: drive file')" 2>nul || echo [!] Python F: drive test failed
651
- echo [DIAGNOSTIC] Testing file read permissions:
652
- type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1 && echo [OK] File content readable || echo [ERROR] Cannot read file content
653
-
654
- echo.
655
- echo Press Enter to execute update command...
656
- pause >nul
657
- echo.
658
- echo Executing update command...
659
- start "Medicafe Update" cmd /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_legacy%\" %package_version% & echo [DIAGNOSTIC] F: drive accessibility test... & dir F:\ ^| find \"Directory of\" ^>nul 2^>^&1 ^&^& echo [OK] F: drive accessible ^|^| echo [ERROR] F: drive access lost & echo. & python \"%upgrade_medicafe_legacy%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: %ERRORLEVEL% & echo Update process completed. Press any key to close... & pause >nul" && (
660
- echo %DATE% %TIME% Upgrade initiated successfully (legacy). >> "%temp_file%"
661
- echo [SUCCESS] Update process started successfully
662
- echo All output will be displayed in the update window.
663
- ) || (
664
- echo %DATE% %TIME% Update failed (legacy). >> "%temp_file%"
538
+ ) else (
539
+ if exist "%upgrade_medicafe_legacy%" (
540
+ echo [INFO] Using legacy update script at: %upgrade_medicafe_legacy%
541
+ echo Command: python "%upgrade_medicafe_legacy%" %package_version%
542
+
543
+ :: Pre-execution diagnostics for F: drive
544
+ echo.
545
+ echo [DIAGNOSTIC] Pre-execution checks for F: drive script:
546
+ echo [DIAGNOSTIC] File size and permissions:
547
+ dir "%upgrade_medicafe_legacy%" 2>nul || echo [!] Cannot read file details
548
+ echo [DIAGNOSTIC] Testing Python access to F: drive file:
549
+ python -c "import os; print('[OK] Python can access F: drive file') if os.path.exists('%upgrade_medicafe_legacy%') else print('[ERROR] Python cannot access F: drive file')" 2>nul || echo [!] Python F: drive test failed
550
+ echo [DIAGNOSTIC] Testing file read permissions:
551
+ type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1 && echo [OK] File content readable || echo [ERROR] Cannot read file content
552
+
553
+ echo.
554
+ echo Press Enter to execute update command...
555
+ pause >nul
556
+ echo.
557
+ echo Executing update command...
558
+ start "Medicafe Update" cmd /v:on /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_legacy%\" %package_version% & echo [DIAGNOSTIC] F: drive accessibility test... & dir F:\ ^| find \"Directory of\" ^>nul 2^>^&1 ^&^& echo [OK] F: drive accessible ^|^| echo [ERROR] F: drive access lost & echo. & python \"%upgrade_medicafe_legacy%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: !ERRORLEVEL! & echo Update process completed. Press any key to close... & pause >nul" && (
559
+ echo %DATE% %TIME% Upgrade initiated successfully - legacy. >> "%temp_file%"
560
+ echo [SUCCESS] Update process started successfully
561
+ echo All output will be displayed in the update window.
562
+ ) || (
563
+ echo %DATE% %TIME% Update failed - legacy. >> "%temp_file%"
665
564
  echo [ERROR] Upgrade failed. Check the update window for details.
666
565
  echo [DIAGNOSTIC] Possible causes for F: drive script failure:
667
566
  echo - F: drive disconnected during execution
@@ -689,381 +588,255 @@ if exist "%upgrade_medicafe_local%" (
689
588
  goto main_menu
690
589
  )
691
590
 
692
- echo.
693
- echo ========================================
694
- echo DEBUG: Update Process Complete
695
- echo ========================================
696
591
  echo.
697
592
  echo Update process has been initiated.
698
593
  echo All output will be displayed in the update window.
699
594
  echo.
700
- echo Press Enter to return to main menu...
701
- pause >nul
595
+ pause
702
596
  goto main_menu
703
597
 
704
- :: Download Carol's Emails - Using MediCafe entry point
598
+ :: Download Carol's Emails
705
599
  :download_emails
706
600
  if "!internet_available!"=="0" (
707
- echo No internet connection available.
601
+ echo [WARNING] No internet connection available.
708
602
  goto main_menu
709
603
  )
710
- call :process_csvs
604
+
605
+ call "%~dp0process_csvs.bat"
711
606
  cls
712
607
  echo Starting email download via MediCafe...
713
608
  cd /d "%~dp0.."
714
609
  python -m MediCafe download_emails
715
610
  if errorlevel 1 (
716
- echo Failed to download emails.
611
+ echo [ERROR] Failed to download emails.
717
612
  pause
718
613
  )
614
+
615
+ pause
719
616
  goto main_menu
720
617
 
721
- :: Run MediBot Flow
618
+ :: MediBot Flow
722
619
  :medibot_flow
723
- call :process_csvs
724
620
  cls
725
- echo Starting MediBot via MediCafe...
621
+ echo Starting MediBot flow...
726
622
  cd /d "%~dp0.."
727
- python -m MediCafe medibot "%config_file%"
728
- if errorlevel 1 echo Failed to run MediBot.
623
+ python -m MediCafe medibot
624
+ if errorlevel 1 (
625
+ echo [ERROR] Failed to start MediBot flow.
626
+ pause
627
+ )
628
+
729
629
  pause
730
630
  goto main_menu
731
631
 
732
- :: Continue to MediLink
632
+ :: MediLink Flow
733
633
  :medilink_flow
734
- if "!internet_available!"=="0" (
735
- echo No internet connection available.
736
- goto main_menu
737
- )
738
- call :process_csvs
739
634
  cls
740
- :: move this path.
635
+ echo Starting MediLink flow...
741
636
  cd /d "%~dp0.."
742
637
  python -m MediCafe medilink
743
- if errorlevel 1 echo MediLink failed to execute.
638
+ if errorlevel 1 (
639
+ echo [ERROR] Failed to start MediLink flow.
640
+ pause
641
+ )
642
+
643
+ pause
644
+ goto main_menu
645
+
646
+ :toggle_perf_logging
647
+ cls
648
+ echo ========================================
649
+ echo Performance Logging (session toggle)
650
+ echo ========================================
651
+ echo.
652
+ if /I "%MEDICAFE_PERFORMANCE_LOGGING%"=="1" (
653
+ set "MEDICAFE_PERFORMANCE_LOGGING=0"
654
+ echo Turned OFF performance logging for this session.
655
+ ) else (
656
+ set "MEDICAFE_PERFORMANCE_LOGGING=1"
657
+ echo Turned ON performance logging for this session.
658
+ )
659
+ echo.
660
+ echo Note: This affects current session only. To persist, set in config.json.
744
661
  pause
745
662
  goto main_menu
746
663
 
747
664
  :: United Claims Status
748
665
  :united_claims_status
749
- if "!internet_available!"=="0" (
750
- echo No internet connection available.
751
- goto main_menu
752
- )
753
666
  cls
754
- echo Loading United Claims Status...
667
+ echo Starting United Claims Status...
755
668
  cd /d "%~dp0.."
756
669
  python -m MediCafe claims_status
757
- if errorlevel 1 echo Failed to check United Claims Status.
670
+ if errorlevel 1 (
671
+ echo [ERROR] Failed to start United Claims Status.
672
+ pause
673
+ )
674
+
758
675
  pause
759
676
  goto main_menu
760
677
 
761
678
  :: United Deductible
762
679
  :united_deductible
763
- if "!internet_available!"=="0" (
764
- echo No internet connection available.
765
- goto main_menu
766
- )
767
680
  cls
768
- echo Loading United Deductible...
681
+ echo Starting United Deductible...
769
682
  cd /d "%~dp0.."
770
683
  python -m MediCafe deductible
771
- if errorlevel 1 echo Failed to check United Deductible.
684
+ if errorlevel 1 (
685
+ echo [ERROR] Failed to start United Deductible.
686
+ pause
687
+ )
688
+
772
689
  pause
773
690
  goto main_menu
774
691
 
775
- :: Process CSV Files and Validate Against Config
692
+ :: Process CSV Files moved to external script
776
693
  :process_csvs
777
-
778
- :: Check if the Python script for JSON updates exists
779
- if not exist "%python_script%" (
780
- echo.
781
- echo Warning: Python script for JSON updates not found at: %python_script%
782
- echo.
783
- echo Would you like to provide an alternate path for the JSON update script?
784
- set /p provide_alt_json="Enter 'Y' to provide alternate path, or any other key to continue: "
785
- if /i "!provide_alt_json!"=="Y" (
786
- echo.
787
- echo Please enter the full path to your update_json.py file.
788
- echo Example: C:\MediBot\scripts\update_json.py
789
- echo Example with spaces: "G:\My Drive\MediBot\scripts\update_json.py"
790
- echo.
791
- echo Note: If your path contains spaces, please include quotes around the entire path.
792
- echo.
793
- set /p alt_json_path="Enter JSON update script path: "
794
- :: Remove any surrounding quotes from user input and re-add them for consistency
795
- set "alt_json_path=!alt_json_path:"=!"
796
- if exist "!alt_json_path!" (
797
- echo JSON update script found at: !alt_json_path!
798
- set "python_script=!alt_json_path!"
799
- ) else (
800
- echo JSON update script not found at: !alt_json_path!
801
- echo Continuing without JSON update script...
802
- )
803
- ) else (
804
- echo Continuing without JSON update script...
805
- )
806
- )
807
-
808
- :: Move CSV files from local_storage_path to source_folder in case AK sends it unencrypted by accident.
809
- echo Checking for new CSV files in local storage...
810
- for %%f in ("%local_storage_path%\*.csv") do (
811
- echo WARNING: Found CSV files!
812
- echo Moving %%f to %source_folder%...
813
- move "%%f" "%source_folder%" >nul 2>&1
814
- if errorlevel 1 (
815
- echo Failed to move %%f. Check permissions or path.
816
- ) else (
817
- echo Moved %%f successfully.
818
- )
819
- )
820
-
821
- :: Retrieve the current time and date to create a timestamp
822
- for /f "tokens=1-5 delims=/: " %%a in ('echo %time%') do (
823
- set "hour=%%a"
824
- set "minute=%%b"
825
- set "second=%%c"
826
- )
827
- for /f "tokens=2-4 delims=/ " %%a in ('echo %date%') do (
828
- set "day=%%a"
829
- set "month=%%b"
830
- set "year=%%c"
831
- )
832
- set "timestamp=!year!!month!!day!_!hour!!minute!"
833
-
834
- :: Search for the most recent CSV file in source folder
835
- set "latest_csv="
836
- for /f "delims=" %%a in ('dir /b /a-d /o-d "%source_folder%\*.csv" 2^>nul') do (
837
- set "latest_csv=%%a"
838
- echo Found New CSV Files...
839
- goto process_found_csv
840
- )
694
+ call "%~dp0process_csvs.bat"
841
695
  goto :eof
842
696
 
843
- :process_found_csv
844
- echo Validating latest CSV with config file...
845
- :: Run Python script to get current CSV path from JSON
846
- for /f "delims=" %%a in ('python "%python_script%" "%config_file%"') do (
847
- set "current_csv=%%a"
848
- )
697
+ REM [removed legacy :clear_cache block in favor of :clear_cache_menu]
849
698
 
850
- :: Extract filenames from paths
851
- for %%f in ("!current_csv!") do set "current_csv_name=%%~nxf"
852
- for %%f in ("%target_folder%\!latest_csv!") do set "latest_csv_name=%%~nxf"
699
+ REM [removed duplicate :clear_cache quick block; use :clear_cache_menu instead]
853
700
 
854
- :: Compare the paths and prompt user if necessary
855
- if not "!current_csv_name!"=="!latest_csv_name!" (
856
- echo.
857
- echo ALERT: Config file CSV path differs from the latest CSV. This can happen if a new CSV is downloaded.
858
- echo Current CSV: !current_csv_name!
859
- echo Latest CSV: !latest_csv_name!
860
- echo.
861
- set /p update_choice="Do you want to update to the latest CSV? (Y/N): "
862
- if /i "!update_choice!"=="Y" (
863
- echo Updating config file with latest CSV...
864
- py "%python_script%" "%config_file%" "%target_folder%\!latest_csv!"
865
- echo Config file updated.
866
- ) else (
867
- echo Using existing CSV path from config.
868
- )
869
- ) else (
870
- echo CSV path in config matches the latest CSV.
871
- )
872
-
873
- move "%source_folder%\!latest_csv!" "%target_folder%\SX_CSV_!timestamp!.csv"
874
- set "new_csv_path=%target_folder%\SX_CSV_!timestamp!.csv"
875
- echo Processing CSV...
876
- py "%python_script%" "%config_file%" "!new_csv_path!"
877
- echo CSV Processor Complete...
878
- goto :eof
879
-
880
- :: Clear Python Cache
881
- :clear_cache
701
+ :: Clear Cache submenu (Quick vs Deep)
702
+ :clear_cache_menu
882
703
  cls
883
- echo Clearing Python cache for MediCafe...
704
+ echo ========================================
705
+ echo Clear Python Cache
706
+ echo ========================================
884
707
  echo.
885
- cd /d "%~dp0.."
708
+ echo 1. Quick clear - compileall + delete __pycache__
709
+ echo 2. Deep clear via update_medicafe.py
710
+ echo 3. Back
711
+ echo.
712
+ set /p cc_choice=Enter your choice:
713
+ if "%cc_choice%"=="1" goto clear_cache_quick
714
+ if "%cc_choice%"=="2" goto clear_cache_deep
715
+ if "%cc_choice%"=="3" goto troubleshooting_menu
716
+ echo Invalid choice. Press any key to continue...
717
+ pause >nul
718
+ goto clear_cache_menu
886
719
 
887
- :: Check if update_medicafe.py exists using priority system (local first)
888
- if exist "%upgrade_medicafe_local%" (
889
- echo Found update_medicafe.py in local location - using relative path
890
- echo [DIAGNOSTIC] Cache clearing with local script:
891
- echo [DIAGNOSTIC] Command: python "%upgrade_medicafe_local%" --clear-cache
892
- python "%upgrade_medicafe_local%" --clear-cache
893
- if %errorlevel% neq 0 (
894
- echo [ERROR] Cache clearing failed with local script, error code: %errorlevel%
895
- echo [DIAGNOSTIC] Possible causes:
896
- echo - Python not in PATH
897
- echo - Script syntax error
898
- echo - Missing dependencies
899
- )
900
- ) else if exist "%upgrade_medicafe_legacy%" (
901
- echo Found update_medicafe.py in legacy location - using F: drive path
902
- echo [DIAGNOSTIC] Cache clearing with F: drive script:
903
- echo [DIAGNOSTIC] Command: python "%upgrade_medicafe_legacy%" --clear-cache
904
- echo [DIAGNOSTIC] Testing F: drive access before execution:
905
- dir "F:\Medibot" >nul 2>&1 && echo [OK] F: drive accessible || echo [ERROR] F: drive access issue
906
- python "%upgrade_medicafe_legacy%" --clear-cache
907
- if %errorlevel% neq 0 (
908
- echo [ERROR] Cache clearing failed with F: drive script, error code: %errorlevel%
909
- echo [DIAGNOSTIC] Possible causes:
910
- echo - F: drive disconnected during execution
911
- echo - Permission denied accessing F: drive file
912
- echo - F: drive file locked
913
- echo - Python cannot access network paths
914
- )
915
- ) else (
916
- echo ERROR: update_medicafe.py not found in either location
917
- echo Expected locations:
918
- echo - Local: %upgrade_medicafe_local%
919
- echo - Legacy: %upgrade_medicafe_legacy%
920
- pause
921
- goto main_menu
922
- )
720
+ :clear_cache_quick
721
+ echo Running quick cache clear...
722
+ call "%~dp0clear_cache.bat" --quick
723
+ pause
724
+ goto troubleshooting_menu
923
725
 
924
- if errorlevel 1 (
925
- echo Cache clearing failed.
926
- pause
927
- ) else (
928
- echo Cache clearing completed successfully.
929
- pause
930
- )
931
- goto main_menu
726
+ :clear_cache_deep
727
+ cls
728
+ echo Deep cache clear using update_medicafe.py...
729
+ echo.
730
+ call "%~dp0clear_cache.bat" --deep
731
+ pause
732
+ goto troubleshooting_menu
932
733
 
933
- :: Exit Script
934
- :end_script
935
- echo Exiting MediCafe.
734
+ :: Troubleshooting Submenu
735
+ :troubleshooting_menu
736
+ cls
737
+ echo Troubleshooting Options:
738
+ echo.
739
+ echo 1. Open Latest Log File
740
+ echo 2. Clear Python Cache
741
+ echo 3. Forced MediCafe version rollback - no dependencies
742
+ echo 4. Back to Main Menu
743
+ echo.
744
+ set /p tchoice=Enter your choice:
745
+ if "%tchoice%"=="1" goto open_latest_log
746
+ if "%tchoice%"=="2" goto clear_cache_menu
747
+ if "%tchoice%"=="3" goto forced_version_rollback
748
+ if "%tchoice%"=="4" goto main_menu
749
+ echo Invalid choice. Please try again.
936
750
  pause
937
- exit /b
751
+ goto troubleshooting_menu
938
752
 
939
- :: Open Latest Log
753
+ :: Open Latest Log (streamlined)
940
754
  :open_latest_log
941
755
  echo Opening the latest log file...
942
756
  set "latest_log="
943
-
944
- :: Attempt to find any files in the directory
945
- echo Attempting to locate files in %local_storage_path%...
946
-
947
- :: Method 1: Check for any files
948
- echo Attempt #1: Checking for any files...
949
- dir "%local_storage_path%\*" >nul 2>&1
950
- if %errorlevel% == 0 (
951
- echo Files found in %local_storage_path%.
952
- ) else (
953
- echo No files found in %local_storage_path%.
954
- pause
955
- goto main_menu
956
- )
957
-
958
- :: Method 2: Check for .log files specifically
959
- echo Attempt #2: Checking for .log files...
960
- dir "%local_storage_path%\*.log" >nul 2>&1
961
- if %errorlevel% == 0 (
962
- echo .log files found in %local_storage_path%.
963
- ) else (
964
- echo No .log files found in %local_storage_path%.
965
- )
966
-
967
- :: Method 3: Check for .txt files as a fallback
968
- echo Attempt #3: Checking for .txt files...
969
- dir "%local_storage_path%\*.txt" >nul 2>&1
970
- if %errorlevel% == 0 (
971
- echo .txt files found in %local_storage_path%. This indicates that files are present.
972
- ) else (
973
- echo No .txt files found in %local_storage_path%.
974
- )
975
-
976
- :: Method 4: List all files with detailed output
977
- echo Attempt #4: Listing all files in %local_storage_path%...
978
- dir "%local_storage_path%"
979
- pause
980
-
981
- :: Now attempt to find the latest .log file
982
- echo Attempting to find the latest .log file...
983
- set "latest_log="
984
757
  for /f "delims=" %%a in ('dir /b /a-d /o-d "%local_storage_path%\*.log" 2^>nul') do (
985
758
  set "latest_log=%%a"
986
759
  goto open_log_found
987
760
  )
988
761
 
989
- echo No log files found in %local_storage_path%. Please ensure that log files are present.
762
+ echo No log files found in %local_storage_path%.
990
763
  pause
991
- goto main_menu
764
+ goto troubleshooting_menu
765
+
766
+ :: End Script
767
+ :end_script
768
+ echo Exiting MediBot
769
+ exit /b 0
992
770
 
771
+ :: Full Debug Mode moved to external script full_debug_suite.bat
772
+
773
+ :: Opened log file handling and helpers
993
774
  :open_log_found
994
775
  echo Found log file: %latest_log%
995
- pause
996
-
997
- :: Method 1: Attempt to open with Notepad
998
- echo Attempt #1: Opening with Notepad...
999
- notepad "%local_storage_path%\%latest_log%"
1000
- if %errorlevel% == 0 (
1001
- echo Successfully opened the log file with Notepad.
1002
- pause
1003
- goto main_menu
1004
- ) else (
1005
- echo Attempt #1 Failed: Could not open with Notepad.
1006
- pause
776
+ start notepad "%local_storage_path%\%latest_log%" >nul 2>&1
777
+ if %errorlevel% neq 0 (
778
+ start write "%local_storage_path%\%latest_log%" >nul 2>&1
1007
779
  )
1008
-
1009
- :: Method 2: Attempt to open with WordPad
1010
- echo Attempt #2: Opening with WordPad...
1011
- write "%local_storage_path%\%latest_log%"
1012
- if %errorlevel% == 0 (
1013
- echo Successfully opened the log file with WordPad.
1014
- pause
1015
- goto main_menu
1016
- ) else (
1017
- echo Attempt #2 Failed: Could not open with WordPad.
1018
- pause
780
+ if %errorlevel% neq 0 (
781
+ call :tail "%local_storage_path%\%latest_log%" 50
1019
782
  )
783
+ pause
784
+ goto troubleshooting_menu
1020
785
 
1021
- :: Method 3: Display contents using the TYPE command
1022
- echo Attempt #3: Displaying log file contents with TYPE command...
1023
- type "%local_storage_path%\%latest_log%"
1024
- if %errorlevel% == 0 (
1025
- echo Successfully displayed the log file contents.
1026
- pause
1027
- goto main_menu
1028
- ) else (
1029
- echo Attempt #3 Failed: Could not display contents with TYPE.
1030
- pause
786
+ :: Forced version rollback for MediCafe (hardcoded version placeholder)
787
+ :forced_version_rollback
788
+ cls
789
+ echo ========================================
790
+ echo Forced MediCafe Version Rollback
791
+ echo ========================================
792
+ echo.
793
+ if "!internet_available!"=="0" (
794
+ echo No internet connection available.
795
+ echo Cannot proceed with rollback without internet.
796
+ pause >nul
797
+ goto troubleshooting_menu
798
+ )
799
+ set "rollback_version=0.250529.2"
800
+ echo Forcing reinstall of %medicafe_package%==%rollback_version% with no dependencies...
801
+ python -m pip install --no-deps --force-reinstall %medicafe_package%==%rollback_version%
802
+ if errorlevel 1 (
803
+ echo.
804
+ echo [ERROR] Forced rollback failed.
805
+ pause >nul
806
+ goto troubleshooting_menu
1031
807
  )
1032
808
 
1033
- :: Method 4: Display the last 30 lines of the log file
1034
- echo Attempt #4: Displaying the last 30 lines of the log file...
1035
- call :tail "%local_storage_path%\%latest_log%" 30
1036
- if %errorlevel% == 0 (
1037
- echo Successfully displayed the last 30 lines of the log file.
1038
- ) else (
1039
- echo Attempt #4 Failed: Could not display the last 30 lines.
809
+ :: Refresh displayed MediCafe version
810
+ set "package_version="
811
+ python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
812
+ set /p package_version=<temp.txt
813
+ if exist temp.txt del temp.txt
814
+ if defined package_version (
815
+ for /f "tokens=2 delims==" %%a in ("%package_version%") do (
816
+ set "medicafe_version=%%a"
817
+ )
1040
818
  )
1041
- pause
1042
- goto main_menu
819
+ echo.
820
+ echo Rollback complete. Current MediCafe version: %medicafe_version%
821
+ pause >nul
822
+ goto troubleshooting_menu
1043
823
 
1044
824
  :: Subroutine to display the last N lines of a file
1045
825
  :tail
1046
826
  :: Usage: call :tail filename number_of_lines
1047
- setlocal enabledelayedexpansion
827
+ setlocal
1048
828
  set "file=%~1"
1049
829
  set /a lines=%~2
1050
- set "count=0"
1051
- set "output="
1052
830
 
1053
- for /f "usebackq delims=" %%x in ("%file%") do (
1054
- set /a count+=1
1055
- set "line[!count!]=%%x"
1056
- )
831
+ :: Get total line count robustly (avoid prefixed output)
832
+ set "count=0"
833
+ for /f %%a in ('type "%file%" ^| find /v /c ""') do set count=%%a
1057
834
 
1058
- if %count% LSS %lines% (
1059
- set "start=1"
1060
- ) else (
1061
- set /a start=%count% - %lines% + 1
1062
- )
835
+ :: Compute starting line; clamp to 1
836
+ set /a start=count-lines+1
837
+ if !start! lss 1 set start=1
1063
838
 
1064
- for /l %%i in (%start%,1,%count%) do (
1065
- echo !line[%%i]!
839
+ for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
840
+ if %%a geq !start! echo %%b
1066
841
  )
1067
-
1068
- endlocal
1069
- goto :eof
842
+ endlocal & goto :eof