medicafe 0.250806.14__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
@@ -4,36 +4,53 @@ setlocal enabledelayedexpansion
4
4
 
5
5
  :: Debug mode selection
6
6
  echo ========================================
7
- echo MediBot Launcher
7
+ echo MediCafe Launcher
8
8
  echo ========================================
9
9
  echo.
10
10
  echo Choose your mode:
11
- echo 1. Normal Mode (Production)
12
- echo 2. Debug Mode (Full diagnostics with automated checks)
11
+ echo 1. Normal Mode - Production
12
+ echo 2. Debug Mode - Full diagnostics (Interactive)
13
+ echo 3. Debug Mode - Full diagnostics (Non-Interactive)
13
14
  echo.
14
- set /p debug_choice="Enter your choice (1-2): "
15
+ set /p debug_choice="Enter your choice (1-3): "
15
16
 
16
- if "!debug_choice!"=="2" (
17
- echo.
18
- echo ========================================
19
- echo DEBUG MODE ACTIVATED
20
- echo ========================================
21
- echo [DEBUG] Running full diagnostic suite with automated checks...
22
- echo [DEBUG] This will run all checks without user interaction.
23
- echo [DEBUG] Results will be displayed for review.
24
- echo.
25
- goto full_debug_mode
26
- ) else if "!debug_choice!"=="1" (
27
- echo [INFO] Starting Normal Mode...
28
- goto normal_mode
29
- ) else (
30
- echo [ERROR] Invalid choice. Starting Normal Mode...
31
- goto normal_mode
32
- )
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
33
49
 
34
50
  :normal_mode
35
51
  :: Normal production mode - streamlined without excessive debug output
36
- cls
52
+ if not defined SKIP_CLS_AFTER_DEBUG cls
53
+ set "SKIP_CLS_AFTER_DEBUG="
37
54
  echo ========================================
38
55
  echo MediBot Starting
39
56
  echo ========================================
@@ -127,8 +144,24 @@ if errorlevel 1 (
127
144
  pause
128
145
  exit /b 1
129
146
  )
147
+ )
148
+
149
+ :: Determine installed MediCafe version
150
+ set "package_version="
151
+ set "medicafe_version="
152
+ python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
153
+ set /p package_version=<temp.txt
154
+ if exist temp.txt del temp.txt
155
+ if not defined package_version (
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
160
+ )
161
+ if defined package_version (
162
+ for /f "tokens=2 delims==" %%a in ("%package_version%") do set "medicafe_version=%%a"
130
163
  ) else (
131
- for /f "tokens=2 delims==" %%i in ('python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2^>nul') do set "package_version=%%i"
164
+ set "medicafe_version=unknown"
132
165
  )
133
166
 
134
167
  :: Check for internet connectivity
@@ -137,39 +170,205 @@ if errorlevel 1 (
137
170
  set "internet_available=0"
138
171
  ) else (
139
172
  set "internet_available=1"
173
+ echo Internet connection detected.
174
+ )
175
+
176
+ :: Common pre-menu setup
177
+ echo Setting up the environment...
178
+ if not exist "%config_file%" (
179
+ echo Configuration file missing.
180
+ echo.
181
+ echo Expected configuration file path: %config_file%
182
+ echo.
183
+ echo Would you like to provide an alternate path for the configuration file?
184
+ set /p provide_alt="Enter 'Y' to provide alternate path, or any other key to exit: "
185
+ if /i "!provide_alt!"=="Y" (
186
+ echo.
187
+ echo Please enter the full path to your configuration file.
188
+ echo Example: C:\MediBot\config\config.json
189
+ echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
190
+ echo.
191
+ echo Note: If your path contains spaces, please include quotes around the entire path.
192
+ echo.
193
+ set /p alt_config_path="Enter configuration file path: "
194
+ :: Remove any surrounding quotes from user input and re-add them for consistency
195
+ set "alt_config_path=!alt_config_path:"=!"
196
+ if exist "!alt_config_path!" (
197
+ echo Configuration file found at: !alt_config_path!
198
+ set "config_file=!alt_config_path!"
199
+ goto config_check_complete
200
+ ) else (
201
+ echo Configuration file not found at: !alt_config_path!
202
+ echo.
203
+ set /p retry="Would you like to try another path? (Y/N): "
204
+ if /i "!retry!"=="Y" (
205
+ goto retry_config_path
206
+ ) else (
207
+ goto end_script
208
+ )
209
+ )
210
+ ) else (
211
+ goto end_script
212
+ )
213
+ ) else (
214
+ goto config_check_complete
215
+ )
216
+
217
+ :retry_config_path
218
+ echo.
219
+ echo Please enter the full path to your configuration file.
220
+ echo Example: C:\MediBot\config\config.json
221
+ echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
222
+ echo.
223
+ echo Note: If your path contains spaces, please include quotes around the entire path.
224
+ echo.
225
+ set /p alt_config_path="Enter configuration file path: "
226
+ :: Remove any surrounding quotes from user input and re-add them for consistency
227
+ set "alt_config_path=!alt_config_path:"=!"
228
+ if exist "!alt_config_path!" (
229
+ echo Configuration file found at: !alt_config_path!
230
+ set "config_file=!alt_config_path!"
231
+ ) else (
232
+ echo Configuration file not found at: !alt_config_path!
233
+ echo.
234
+ set /p retry="Would you like to try another path? (Y/N): "
235
+ if /i "!retry!"=="Y" (
236
+ goto retry_config_path
237
+ ) else (
238
+ goto end_script
239
+ )
240
+ )
241
+
242
+ :config_check_complete
243
+
244
+ :: Check if the file exists and attempt to copy it to the local directory
245
+ echo Checking for the update script...
246
+ ping -n 2 127.0.0.1 >nul
247
+
248
+ :: Continue with existing logic but with enhanced error reporting
249
+ :: First check if we already have it locally
250
+ if exist "%upgrade_medicafe_local%" (
251
+ echo Found update_medicafe.py in local directory. No action needed.
252
+ ping -n 2 127.0.0.1 >nul
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...
256
+ ping -n 2 127.0.0.1 >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:\" (
266
+ if not exist "F:\Medibot" (
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
+ )
272
+ )
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
+ )
286
+ )
287
+ ) else (
288
+ echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
289
+ )
290
+ ) else (
291
+ echo File copied to local directory successfully.
292
+ ping -n 2 127.0.0.1 >nul
293
+ )
294
+ ) else (
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
+ )
324
+ )
140
325
  )
141
326
 
142
327
  :: Main menu
143
328
  :main_menu
144
329
  cls
330
+ echo Version: %medicafe_version%
331
+ echo --------------------------------------------------------------
332
+ echo .//* Welcome to MediBot *\\.
333
+ echo --------------------------------------------------------------
334
+ echo.
335
+
336
+ if "!internet_available!"=="0" (
337
+ echo NOTE: No internet detected. Options 1-5 require internet.
338
+ echo.
339
+ )
340
+ echo Please select an option:
145
341
  echo.
146
- echo ========================================
147
- echo MediBot Main Menu
148
- echo ========================================
342
+ echo 1. Update MediCafe
149
343
  echo.
150
- echo 1. Check for MediCafe Updates
151
- echo 2. Download Carol's Emails
152
- echo 3. MediBot Flow
153
- echo 4. MediLink Flow
154
- echo 5. United Claims Status
155
- echo 6. United Deductible
156
- echo 7. Process CSV Files
157
- echo 8. Clear Cache
158
- echo 9. Open Latest Log
159
- echo 0. Exit
344
+ echo 2. Download Email de Carol
160
345
  echo.
161
-
162
- set /p choice="Enter your choice (0-9): "
163
-
164
- if "!choice!"=="1" goto check_updates
346
+ echo 3. MediLink Claims
347
+ echo.
348
+ echo 4. ^[United^] Claims Status
349
+ echo.
350
+ echo 5. ^[United^] Deductible
351
+ echo.
352
+ echo 6. Run MediBot
353
+ echo.
354
+ echo 7. Troubleshooting
355
+ echo.
356
+ echo 9. Toggle Performance Logging (session)
357
+ echo.
358
+ echo 8. Exit
359
+ echo.
360
+ set /p choice=Enter your choice:
361
+
362
+ :: Update option numbers
363
+ if "!choice!"=="8" goto end_script
364
+ if "!choice!"=="7" goto troubleshooting_menu
365
+ if "!choice!"=="6" goto medibot_flow
366
+ if "!choice!"=="5" goto united_deductible
367
+ if "!choice!"=="4" goto united_claims_status
368
+ if "!choice!"=="3" goto medilink_flow
165
369
  if "!choice!"=="2" goto download_emails
166
- if "!choice!"=="3" goto medibot_flow
167
- if "!choice!"=="4" goto medilink_flow
168
- if "!choice!"=="5" goto united_claims_status
169
- if "!choice!"=="6" goto united_deductible
170
- if "!choice!"=="7" goto process_csvs
171
- if "!choice!"=="8" goto clear_cache
172
- if "!choice!"=="9" goto open_latest_log
370
+ if "!choice!"=="1" goto check_updates
371
+ if "!choice!"=="9" goto toggle_perf_logging
173
372
  if "!choice!"=="0" goto end_script
174
373
 
175
374
  echo Invalid choice. Please try again.
@@ -188,11 +387,112 @@ echo Starting MediCafe Update Process
188
387
  echo ========================================
189
388
  echo.
190
389
 
191
- :: Verify update script exists
192
- if not exist "%upgrade_medicafe%" (
193
- echo [ERROR] Update script not found at: %upgrade_medicafe%
194
- echo Please run in Debug Mode to diagnose file issues.
195
- pause
390
+ :: Step 1: Check if update_medicafe.py exists in expected location
391
+ echo.
392
+ echo ========================================
393
+ echo DEBUG STEP 1: Checking for update script
394
+ echo ========================================
395
+ echo.
396
+ echo Checking for update script - priority: local first, then legacy path
397
+ if exist "%upgrade_medicafe_local%" (
398
+ echo [SUCCESS] Found update script at: %upgrade_medicafe_local%
399
+ echo File size:
400
+ dir "%upgrade_medicafe_local%" | find "update_medicafe.py"
401
+ set "upgrade_medicafe=%upgrade_medicafe_local%"
402
+ ) else (
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
418
+ )
419
+ )
420
+ echo.
421
+ echo Press Enter to continue to step 2...
422
+ pause >nul
423
+
424
+ :: Step 2: Verify Python installation and path
425
+ echo.
426
+ echo ========================================
427
+ echo DEBUG STEP 2: Python Environment Check
428
+ echo ========================================
429
+ echo.
430
+ echo Checking Python installation...
431
+ python --version
432
+ if %errorlevel% neq 0 (
433
+ echo [ERROR] Python not found in PATH
434
+ echo Current PATH: %PATH%
435
+ ) else (
436
+ echo [SUCCESS] Python found
437
+ echo Python executable:
438
+ python -c "import sys; print(sys.executable)"
439
+ echo Python version:
440
+ python --version
441
+ )
442
+ echo.
443
+ echo Checking pip installation...
444
+ python -m pip --version
445
+ if %errorlevel% neq 0 (
446
+ echo [ERROR] pip not found
447
+ ) else (
448
+ echo [SUCCESS] pip found
449
+ echo pip version:
450
+ python -m pip --version
451
+ )
452
+ echo.
453
+ echo Press Enter to continue to step 3...
454
+ pause >nul
455
+
456
+ :: Step 3: Check MediCafe package installation
457
+ echo.
458
+ echo ========================================
459
+ echo DEBUG STEP 3: MediCafe Package Check
460
+ echo ========================================
461
+ echo.
462
+ echo Checking MediCafe package installation...
463
+ python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2>nul
464
+ if %errorlevel% neq 0 (
465
+ echo [ERROR] MediCafe package not found or error accessing
466
+ echo.
467
+ echo Checking if MediCafe is importable...
468
+ python -c "import MediCafe; print('MediCafe module found')" 2>nul
469
+ if %errorlevel% neq 0 (
470
+ echo [ERROR] MediCafe module not importable
471
+ ) else (
472
+ echo [SUCCESS] MediCafe module is importable
473
+ )
474
+ ) else (
475
+ echo [SUCCESS] MediCafe package found
476
+ echo Package version: %package_version%
477
+ )
478
+ echo.
479
+ echo Press Enter to continue to step 4...
480
+ pause >nul
481
+
482
+ :: Step 4: Check internet connectivity
483
+ echo.
484
+ echo ========================================
485
+ echo DEBUG STEP 4: Internet Connectivity
486
+ echo ========================================
487
+ echo.
488
+ echo Testing internet connectivity...
489
+ ping -n 1 google.com >nul 2>&1
490
+ if %errorlevel% neq 0 (
491
+ echo [ERROR] No internet connection detected
492
+ echo Cannot proceed with update without internet
493
+ echo.
494
+ echo Press Enter to return to main menu...
495
+ pause >nul
196
496
  goto main_menu
197
497
  )
198
498
 
@@ -200,12 +500,92 @@ echo Starting update process...
200
500
  echo Update script: %upgrade_medicafe%
201
501
  echo.
202
502
 
203
- start "Medicafe Update" cmd /c "python \"%upgrade_medicafe%\" %package_version% & echo. & echo Update process completed. Press any key to close... & pause >nul" && (
204
- echo %DATE% %TIME% Upgrade initiated successfully. >> "%temp_file%"
205
- echo [SUCCESS] Update process started successfully
206
- ) || (
207
- echo %DATE% %TIME% Update failed. >> "%temp_file%"
208
- echo [ERROR] Upgrade failed. Check the update window for details.
503
+ :: Check if update_medicafe.py exists using the new priority system
504
+ if exist "%upgrade_medicafe_local%" (
505
+ echo [INFO] Using local update script at: %upgrade_medicafe_local%
506
+ echo Command: python "%upgrade_medicafe_local%" %package_version%
507
+
508
+ :: Pre-execution diagnostics
509
+ echo.
510
+ echo [DIAGNOSTIC] Pre-execution checks for local script:
511
+ echo [DIAGNOSTIC] File size and permissions:
512
+ dir "%upgrade_medicafe_local%" 2>nul || echo [!] Cannot read file details
513
+ echo [DIAGNOSTIC] Testing Python access to file:
514
+ python -c "import os; print('[OK] Python can access file') if os.path.exists('%upgrade_medicafe_local%') else print('[ERROR] Python cannot access file')" 2>nul || echo [!] Python test failed
515
+
516
+ echo.
517
+ echo Press Enter to execute update command...
518
+ pause >nul
519
+ echo.
520
+ echo Executing update command...
521
+ echo.
522
+ echo The update window will open and show detailed progress.
523
+ echo All output will be displayed on screen.
524
+ echo.
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%"
527
+ echo [SUCCESS] Update process started successfully
528
+ echo All output will be displayed in the update window.
529
+ ) || (
530
+ echo %DATE% %TIME% Update failed - local. >> "%temp_file%"
531
+ echo [ERROR] Upgrade failed. Check the update window for details.
532
+ echo [DIAGNOSTIC] Possible causes for local script failure:
533
+ echo - Python not in PATH
534
+ echo - Script syntax error
535
+ echo - Missing Python dependencies
536
+ echo - File corruption
537
+ )
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%"
564
+ echo [ERROR] Upgrade failed. Check the update window for details.
565
+ echo [DIAGNOSTIC] Possible causes for F: drive script failure:
566
+ echo - F: drive disconnected during execution
567
+ echo - Permission denied accessing F: drive
568
+ echo - F: drive file locked by antivirus
569
+ echo - Network drive timeout
570
+ echo - Python cannot access network paths
571
+ )
572
+ ) else (
573
+ echo [ERROR] update_medicafe.py not found in either location
574
+ echo Expected locations:
575
+ echo - Local: %upgrade_medicafe_local%
576
+ echo - Legacy: %upgrade_medicafe_legacy%
577
+ echo.
578
+ echo Current directory contents:
579
+ dir /b
580
+ echo.
581
+ echo MediBot directory contents:
582
+ dir /b MediBot\ 2>nul || echo MediBot directory not found
583
+ echo.
584
+ echo %DATE% %TIME% Update failed - script not found. >> "%temp_file%"
585
+ echo.
586
+ echo Press Enter to return to main menu...
587
+ pause >nul
588
+ goto main_menu
209
589
  )
210
590
 
211
591
  echo.
@@ -222,7 +602,7 @@ if "!internet_available!"=="0" (
222
602
  goto main_menu
223
603
  )
224
604
 
225
- call :process_csvs
605
+ call "%~dp0process_csvs.bat"
226
606
  cls
227
607
  echo Starting email download via MediCafe...
228
608
  cd /d "%~dp0.."
@@ -263,6 +643,24 @@ if errorlevel 1 (
263
643
  pause
264
644
  goto main_menu
265
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.
661
+ pause
662
+ goto main_menu
663
+
266
664
  :: United Claims Status
267
665
  :united_claims_status
268
666
  cls
@@ -291,174 +689,154 @@ if errorlevel 1 (
291
689
  pause
292
690
  goto main_menu
293
691
 
294
- :: Process CSV Files
692
+ :: Process CSV Files moved to external script
295
693
  :process_csvs
296
- if not exist "%source_folder%" (
297
- echo [ERROR] Source folder not found at: %source_folder%
298
- pause
299
- goto main_menu
300
- )
694
+ call "%~dp0process_csvs.bat"
695
+ goto :eof
301
696
 
302
- if not exist "%target_folder%" (
303
- mkdir "%target_folder%" 2>nul
304
- if errorlevel 1 (
305
- echo [ERROR] Failed to create target folder
306
- pause
307
- goto main_menu
308
- )
309
- )
697
+ REM [removed legacy :clear_cache block in favor of :clear_cache_menu]
310
698
 
311
- copy "%source_folder%\*.csv" "%target_folder%\" >nul 2>&1
312
- if errorlevel 1 (
313
- echo [ERROR] Failed to copy CSV files
314
- pause
315
- goto main_menu
316
- ) else (
317
- echo [SUCCESS] Successfully copied CSV files
318
- )
699
+ REM [removed duplicate :clear_cache quick block; use :clear_cache_menu instead]
700
+
701
+ :: Clear Cache submenu (Quick vs Deep)
702
+ :clear_cache_menu
703
+ cls
704
+ echo ========================================
705
+ echo Clear Python Cache
706
+ echo ========================================
707
+ echo.
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
319
719
 
720
+ :clear_cache_quick
721
+ echo Running quick cache clear...
722
+ call "%~dp0clear_cache.bat" --quick
320
723
  pause
321
- goto main_menu
724
+ goto troubleshooting_menu
322
725
 
323
- :: Clear Cache
324
- :clear_cache
325
- echo Clearing Python cache...
326
- python -Bc "import compileall; compileall.compile_dir('.', force=True)" 2>nul
327
- for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d" 2>nul
328
- echo [SUCCESS] Cache cleared successfully
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
329
733
 
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.
330
750
  pause
331
- goto main_menu
751
+ goto troubleshooting_menu
332
752
 
333
- :: Open Latest Log
753
+ :: Open Latest Log (streamlined)
334
754
  :open_latest_log
335
- for /f "delims=" %%i in ('dir /b /o-d *.log 2^>nul') do (
336
- start notepad "%%i"
337
- goto main_menu
755
+ echo Opening the latest log file...
756
+ set "latest_log="
757
+ for /f "delims=" %%a in ('dir /b /a-d /o-d "%local_storage_path%\*.log" 2^>nul') do (
758
+ set "latest_log=%%a"
759
+ goto open_log_found
338
760
  )
339
- echo [WARNING] No log files found
761
+
762
+ echo No log files found in %local_storage_path%.
340
763
  pause
341
- goto main_menu
764
+ goto troubleshooting_menu
342
765
 
343
766
  :: End Script
344
767
  :end_script
345
768
  echo Exiting MediBot
346
769
  exit /b 0
347
770
 
348
- :: Full Debug Mode - Automated checks with no user interaction
349
- :full_debug_mode
350
- echo [DEBUG] ========================================
351
- echo [DEBUG] FULL DEBUG MODE - AUTOMATED CHECKS
352
- echo [DEBUG] ========================================
353
- echo [DEBUG] Running all diagnostic checks automatically...
354
- echo [DEBUG] No user interaction required - results will be displayed.
355
- echo.
771
+ :: Full Debug Mode moved to external script full_debug_suite.bat
356
772
 
357
- :: Step 1: F: Drive Diagnostic (automated)
358
- echo [DEBUG] Step 1: F: Drive Diagnostic
359
- echo [DEBUG] ========================================
360
- call "f_drive_diagnostic.bat" >nul 2>&1
361
- if errorlevel 1 (
362
- echo [DEBUG] F: Drive Diagnostic completed with issues
363
- ) else (
364
- echo [DEBUG] F: Drive Diagnostic completed successfully
365
- )
366
- echo.
367
-
368
- :: Step 2: Crash Diagnostic (automated)
369
- echo [DEBUG] Step 2: Crash Diagnostic
370
- echo [DEBUG] ========================================
371
- call "crash_diagnostic.bat" >nul 2>&1
372
- if errorlevel 1 (
373
- echo [DEBUG] Crash Diagnostic completed with issues
374
- ) else (
375
- echo [DEBUG] Crash Diagnostic completed successfully
773
+ :: Opened log file handling and helpers
774
+ :open_log_found
775
+ echo Found log file: %latest_log%
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
376
779
  )
377
- echo.
378
-
379
- :: Step 3: Basic Debug (automated)
380
- echo [DEBUG] Step 3: Basic Debug
381
- echo [DEBUG] ========================================
382
- call "MediBot_debug.bat" >nul 2>&1
383
- if errorlevel 1 (
384
- echo [DEBUG] Basic Debug completed with issues
385
- ) else (
386
- echo [DEBUG] Basic Debug completed successfully
780
+ if %errorlevel% neq 0 (
781
+ call :tail "%local_storage_path%\%latest_log%" 50
387
782
  )
388
- echo.
783
+ pause
784
+ goto troubleshooting_menu
389
785
 
390
- :: Step 4: Fixed Version Test (automated)
391
- echo [DEBUG] Step 4: Fixed Version Test
392
- echo [DEBUG] ========================================
393
- call "MediBot_fixed.bat" >nul 2>&1
394
- if errorlevel 1 (
395
- echo [DEBUG] Fixed Version Test completed with issues
396
- ) else (
397
- echo [DEBUG] Fixed Version Test completed successfully
398
- )
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 ========================================
399
792
  echo.
400
-
401
- :: Step 5: Additional automated checks
402
- echo [DEBUG] Step 5: Additional System Checks
403
- echo [DEBUG] ========================================
404
-
405
- :: Check Python installation
406
- echo [DEBUG] Checking Python installation...
407
- python --version >nul 2>&1
408
- if errorlevel 1 (
409
- echo [ERROR] Python not found in PATH
410
- ) else (
411
- echo [OK] Python found and accessible
412
- )
413
-
414
- :: Check MediCafe package
415
- echo [DEBUG] Checking MediCafe package...
416
- python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" >nul 2>&1
417
- if errorlevel 1 (
418
- echo [ERROR] MediCafe package not found
419
- ) else (
420
- echo [OK] MediCafe package found
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
421
798
  )
422
-
423
- :: Check internet connectivity
424
- echo [DEBUG] Checking internet connectivity...
425
- ping -n 1 google.com >nul 2>&1
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%
426
802
  if errorlevel 1 (
427
- echo [ERROR] No internet connection
428
- ) else (
429
- echo [OK] Internet connection available
430
- )
431
-
432
- :: Check local update script
433
- echo [DEBUG] Checking local update script...
434
- if exist "MediBot\update_medicafe.py" (
435
- echo [OK] Local update script found
436
- ) else (
437
- echo [ERROR] Local update script not found
803
+ echo.
804
+ echo [ERROR] Forced rollback failed.
805
+ pause >nul
806
+ goto troubleshooting_menu
438
807
  )
439
808
 
440
- :: Check F: drive accessibility
441
- echo [DEBUG] Checking F: drive accessibility...
442
- if exist "F:\" (
443
- echo [OK] F: drive accessible
444
- if exist "F:\Medibot\update_medicafe.py" (
445
- echo [OK] F: drive update script found
446
- ) else (
447
- echo [WARNING] F: drive update script not found
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"
448
817
  )
449
- ) else (
450
- echo [ERROR] F: drive not accessible
451
818
  )
452
-
453
819
  echo.
454
- echo [DEBUG] ========================================
455
- echo [DEBUG] ALL AUTOMATED CHECKS COMPLETED
456
- echo [DEBUG] ========================================
457
- echo [DEBUG] Review the output above for any issues.
458
- echo [DEBUG] The system will continue to normal mode.
459
- echo.
460
- echo [DEBUG] Press Enter to continue to normal mode...
820
+ echo Rollback complete. Current MediCafe version: %medicafe_version%
461
821
  pause >nul
822
+ goto troubleshooting_menu
823
+
824
+ :: Subroutine to display the last N lines of a file
825
+ :tail
826
+ :: Usage: call :tail filename number_of_lines
827
+ setlocal
828
+ set "file=%~1"
829
+ set /a lines=%~2
462
830
 
463
- :: Continue to normal mode after debug
464
- goto normal_mode
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
834
+
835
+ :: Compute starting line; clamp to 1
836
+ set /a start=count-lines+1
837
+ if !start! lss 1 set start=1
838
+
839
+ for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
840
+ if %%a geq !start! echo %%b
841
+ )
842
+ endlocal & goto :eof