medicafe 0.250820.6__py3-none-any.whl → 0.250820.7__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 +834 -834
- MediBot/__init__.py +1 -1
- MediBot/process_csvs.bat +6 -2
- MediCafe/__init__.py +1 -1
- MediLink/__init__.py +1 -1
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/METADATA +1 -1
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/RECORD +11 -11
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/LICENSE +0 -0
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/WHEEL +0 -0
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/entry_points.txt +0 -0
- {medicafe-0.250820.6.dist-info → medicafe-0.250820.7.dist-info}/top_level.txt +0 -0
MediBot/MediBot.bat
CHANGED
@@ -1,835 +1,835 @@
|
|
1
|
-
::MediBot.bat - Streamlined version with coordinated debug system
|
2
|
-
@echo off
|
3
|
-
setlocal enabledelayedexpansion
|
4
|
-
|
5
|
-
:: Clear screen before launcher header
|
6
|
-
cls
|
7
|
-
|
8
|
-
:: Launcher header
|
9
|
-
echo ========================================
|
10
|
-
echo MediCafe Launcher
|
11
|
-
echo ========================================
|
12
|
-
echo.
|
13
|
-
|
14
|
-
:: Hidden debug access: 1-second Enter-to-open gate; otherwise start normal mode
|
15
|
-
echo Press Enter within 1 second to open Debug Options... (otherwise starting Normal Mode)
|
16
|
-
rem Prefer timeout for key-break; fall back to ping if unavailable
|
17
|
-
where timeout >nul 2>&1
|
18
|
-
if errorlevel 1 (
|
19
|
-
rem Fallback: simple 1-second delay (no key detection on XP fallback)
|
20
|
-
ping -n 2 127.0.0.1 >nul
|
21
|
-
goto start_normal_mode
|
22
|
-
) else (
|
23
|
-
timeout /t 1 >nul 2>nul
|
24
|
-
if errorlevel 1 goto show_debug_menu
|
25
|
-
goto start_normal_mode
|
26
|
-
)
|
27
|
-
|
28
|
-
:show_debug_menu
|
29
|
-
echo.
|
30
|
-
echo Choose your mode:
|
31
|
-
echo 1. Normal Mode - Production
|
32
|
-
echo 2. Debug Mode - Full diagnostics (Interactive)
|
33
|
-
echo 3. Debug Mode - Full diagnostics (Non-Interactive)
|
34
|
-
echo.
|
35
|
-
set /p debug_choice="Enter your choice (1-3): "
|
36
|
-
|
37
|
-
if "!debug_choice!"=="1" goto start_normal_mode
|
38
|
-
if "!debug_choice!"=="2" goto start_debug_interactive
|
39
|
-
if "!debug_choice!"=="3" goto start_debug_noninteractive
|
40
|
-
goto start_normal_mode
|
41
|
-
|
42
|
-
:start_debug_interactive
|
43
|
-
echo.
|
44
|
-
echo ========================================
|
45
|
-
echo DEBUG MODE (INTERACTIVE)
|
46
|
-
echo ========================================
|
47
|
-
echo Running full diagnostic suite...
|
48
|
-
set "MEDICAFE_IMPORT_DEBUG=1"
|
49
|
-
set "MEDICAFE_IMPORT_STRICT=0"
|
50
|
-
echo.
|
51
|
-
set "SKIP_CLS_AFTER_DEBUG=1"
|
52
|
-
call "%~dp0full_debug_suite.bat" /interactive
|
53
|
-
echo.
|
54
|
-
goto normal_mode
|
55
|
-
|
56
|
-
:start_debug_noninteractive
|
57
|
-
echo.
|
58
|
-
echo ========================================
|
59
|
-
echo DEBUG MODE (NON-INTERACTIVE)
|
60
|
-
echo ========================================
|
61
|
-
echo Running full diagnostic suite...
|
62
|
-
set "MEDICAFE_IMPORT_DEBUG=1"
|
63
|
-
set "MEDICAFE_IMPORT_STRICT=0"
|
64
|
-
echo.
|
65
|
-
set "SKIP_CLS_AFTER_DEBUG=1"
|
66
|
-
call "%~dp0full_debug_suite.bat"
|
67
|
-
echo.
|
68
|
-
goto normal_mode
|
69
|
-
|
70
|
-
:start_normal_mode
|
71
|
-
echo Starting Normal Mode...
|
72
|
-
set "MEDICAFE_IMPORT_DEBUG=0"
|
73
|
-
set "MEDICAFE_IMPORT_STRICT=1"
|
74
|
-
goto normal_mode
|
75
|
-
|
76
|
-
:normal_mode
|
77
|
-
:: Normal production mode - streamlined without excessive debug output
|
78
|
-
if not defined SKIP_CLS_AFTER_DEBUG cls
|
79
|
-
set "SKIP_CLS_AFTER_DEBUG="
|
80
|
-
echo ========================================
|
81
|
-
echo
|
82
|
-
echo ========================================
|
83
|
-
echo.
|
84
|
-
|
85
|
-
:: Define paths with local fallbacks for F: drive dependencies
|
86
|
-
set "source_folder=C:\MEDIANSI\MediCare"
|
87
|
-
set "target_folder=C:\MEDIANSI\MediCare\CSV"
|
88
|
-
set "python_script=C:\Python34\Lib\site-packages\MediBot\update_json.py"
|
89
|
-
set "python_script2=C:\Python34\Lib\site-packages\MediBot\Medibot.py"
|
90
|
-
set "medicafe_package=medicafe"
|
91
|
-
|
92
|
-
:: Absolute paths for updater scripts
|
93
|
-
set "script_dir=%~dp0"
|
94
|
-
set "upgrade_medicafe_local=%script_dir%update_medicafe.py"
|
95
|
-
set "upgrade_medicafe_legacy=F:\Medibot\update_medicafe.py"
|
96
|
-
|
97
|
-
:: Storage and config paths with local fallbacks
|
98
|
-
set "local_storage_legacy=F:\Medibot\DOWNLOADS"
|
99
|
-
set "local_storage_local=MediBot\DOWNLOADS"
|
100
|
-
set "config_file_legacy=F:\Medibot\json\config.json"
|
101
|
-
set "config_file_local=MediBot\json\config.json"
|
102
|
-
set "temp_file_legacy=F:\Medibot\last_update_timestamp.txt"
|
103
|
-
set "temp_file_local=MediBot\last_update_timestamp.txt"
|
104
|
-
|
105
|
-
:: Ensure F: has the latest updater when available; prefer F: when present
|
106
|
-
if exist "F:\" (
|
107
|
-
if not exist "F:\Medibot" mkdir "F:\Medibot" 2>nul
|
108
|
-
if exist "%upgrade_medicafe_local%" (
|
109
|
-
copy /Y "%upgrade_medicafe_local%" "%upgrade_medicafe_legacy%" >nul 2>&1
|
110
|
-
)
|
111
|
-
)
|
112
|
-
|
113
|
-
:: Preference order: 1) F: drive updater, 2) Local updater
|
114
|
-
if exist "%upgrade_medicafe_legacy%" (
|
115
|
-
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
116
|
-
set "use_local_update=0"
|
117
|
-
) else if exist "%upgrade_medicafe_local%" (
|
118
|
-
set "upgrade_medicafe=%upgrade_medicafe_local%"
|
119
|
-
set "use_local_update=1"
|
120
|
-
) else (
|
121
|
-
set "upgrade_medicafe="
|
122
|
-
)
|
123
|
-
|
124
|
-
:: Determine which paths to use based on availability
|
125
|
-
if exist "F:\Medibot" (
|
126
|
-
set "local_storage_path=%local_storage_legacy%"
|
127
|
-
set "config_file=%config_file_legacy%"
|
128
|
-
set "temp_file=%temp_file_legacy%"
|
129
|
-
|
130
|
-
:: Only use F: drive update script if local doesn't exist
|
131
|
-
if "!use_local_update!"=="0" (
|
132
|
-
if exist "%upgrade_medicafe_legacy%" (
|
133
|
-
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
134
|
-
)
|
135
|
-
)
|
136
|
-
) else (
|
137
|
-
set "local_storage_path=%local_storage_local%"
|
138
|
-
set "config_file=%config_file_local%"
|
139
|
-
set "temp_file=%temp_file_local%"
|
140
|
-
:: Ensure local directories exist
|
141
|
-
if not exist "MediBot\json" mkdir "MediBot\json" 2>nul
|
142
|
-
if not exist "MediBot\DOWNLOADS" mkdir "MediBot\DOWNLOADS" 2>nul
|
143
|
-
)
|
144
|
-
|
145
|
-
set "firefox_path=C:\Program Files\Mozilla Firefox\firefox.exe"
|
146
|
-
set "claims_status_script=..\MediLink\MediLink_ClaimStatus.py"
|
147
|
-
set "deductible_script=..\MediLink\MediLink_Deductible.py"
|
148
|
-
set "package_version="
|
149
|
-
set PYTHONWARNINGS=ignore
|
150
|
-
set "PRES_WARN_UPDATE_SCRIPT=0"
|
151
|
-
set "PRES_WARN_NO_INTERNET=0"
|
152
|
-
|
153
|
-
:: Check if Python is installed
|
154
|
-
python --version >nul 2>&1
|
155
|
-
if %errorlevel% neq 0 (
|
156
|
-
echo [ERROR] Python is not installed or not added to PATH.
|
157
|
-
echo Please run in Debug Mode to diagnose Python issues.
|
158
|
-
pause
|
159
|
-
exit /b 1
|
160
|
-
)
|
161
|
-
|
162
|
-
:: Check if critical directories exist
|
163
|
-
if not exist "%source_folder%" (
|
164
|
-
echo [WARNING] Source folder not found at: %source_folder%
|
165
|
-
set /p provide_alt_source="Enter 'Y' to provide alternate path, or any other key to continue: "
|
166
|
-
if /i "!provide_alt_source!"=="Y" (
|
167
|
-
set /p alt_source_folder="Enter the alternate source folder path: "
|
168
|
-
if not "!alt_source_folder!"=="" set "source_folder=!alt_source_folder!"
|
169
|
-
)
|
170
|
-
)
|
171
|
-
|
172
|
-
if not exist "%target_folder%" (
|
173
|
-
mkdir "%target_folder%" 2>nul
|
174
|
-
)
|
175
|
-
|
176
|
-
:: Check if the MediCafe package is installed
|
177
|
-
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2>nul
|
178
|
-
if errorlevel 1 (
|
179
|
-
echo [WARNING] MediCafe package not found. Attempting to install...
|
180
|
-
python -m pip install medicafe --upgrade
|
181
|
-
if errorlevel 1 (
|
182
|
-
echo [ERROR] Failed to install MediCafe package.
|
183
|
-
echo Please run in Debug Mode to diagnose package issues.
|
184
|
-
pause
|
185
|
-
exit /b 1
|
186
|
-
)
|
187
|
-
)
|
188
|
-
|
189
|
-
:: Determine installed MediCafe version
|
190
|
-
set "package_version="
|
191
|
-
set "medicafe_version="
|
192
|
-
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
|
193
|
-
set /p package_version=<temp.txt
|
194
|
-
if exist temp.txt del temp.txt
|
195
|
-
if not defined package_version (
|
196
|
-
rem Fallback: try importing MediCafe and reading __version__
|
197
|
-
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
|
198
|
-
set /p package_version=<temp.txt
|
199
|
-
if exist temp.txt del temp.txt
|
200
|
-
)
|
201
|
-
if defined package_version (
|
202
|
-
for /f "tokens=2 delims==" %%a in ("%package_version%") do set "medicafe_version=%%a"
|
203
|
-
) else (
|
204
|
-
set "medicafe_version=unknown"
|
205
|
-
)
|
206
|
-
|
207
|
-
:: Check for internet connectivity
|
208
|
-
ping -n 1 google.com >nul 2>&1
|
209
|
-
if errorlevel 1 (
|
210
|
-
set "internet_available=0"
|
211
|
-
set "PRES_WARN_NO_INTERNET=1"
|
212
|
-
) else (
|
213
|
-
set "internet_available=1"
|
214
|
-
echo Internet connection detected.
|
215
|
-
)
|
216
|
-
|
217
|
-
:: Common pre-menu setup
|
218
|
-
echo Setting up the environment...
|
219
|
-
if not exist "%config_file%" (
|
220
|
-
echo Configuration file missing.
|
221
|
-
echo.
|
222
|
-
echo Expected configuration file path: %config_file%
|
223
|
-
echo.
|
224
|
-
echo Would you like to provide an alternate path for the configuration file?
|
225
|
-
set /p provide_alt="Enter 'Y' to provide alternate path, or any other key to exit: "
|
226
|
-
if /i "!provide_alt!"=="Y" (
|
227
|
-
echo.
|
228
|
-
echo Please enter the full path to your configuration file.
|
229
|
-
echo Example: C:\MediBot\config\config.json
|
230
|
-
echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
|
231
|
-
echo.
|
232
|
-
echo Note: If your path contains spaces, please include quotes around the entire path.
|
233
|
-
echo.
|
234
|
-
set /p alt_config_path="Enter configuration file path: "
|
235
|
-
:: Remove any surrounding quotes from user input and re-add them for consistency
|
236
|
-
set "alt_config_path=!alt_config_path:"=!"
|
237
|
-
if exist "!alt_config_path!" (
|
238
|
-
echo Configuration file found at: !alt_config_path!
|
239
|
-
set "config_file=!alt_config_path!"
|
240
|
-
goto config_check_complete
|
241
|
-
) else (
|
242
|
-
echo Configuration file not found at: !alt_config_path!
|
243
|
-
echo.
|
244
|
-
set /p retry="Would you like to try another path? (Y/N): "
|
245
|
-
if /i "!retry!"=="Y" (
|
246
|
-
goto retry_config_path
|
247
|
-
) else (
|
248
|
-
goto end_script
|
249
|
-
)
|
250
|
-
)
|
251
|
-
) else (
|
252
|
-
goto end_script
|
253
|
-
)
|
254
|
-
) else (
|
255
|
-
goto config_check_complete
|
256
|
-
)
|
257
|
-
|
258
|
-
:retry_config_path
|
259
|
-
echo.
|
260
|
-
echo Please enter the full path to your configuration file.
|
261
|
-
echo Example: C:\MediBot\config\config.json
|
262
|
-
echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
|
263
|
-
echo.
|
264
|
-
echo Note: If your path contains spaces, please include quotes around the entire path.
|
265
|
-
echo.
|
266
|
-
set /p alt_config_path="Enter configuration file path: "
|
267
|
-
:: Remove any surrounding quotes from user input and re-add them for consistency
|
268
|
-
set "alt_config_path=!alt_config_path:"=!"
|
269
|
-
if exist "!alt_config_path!" (
|
270
|
-
echo Configuration file found at: !alt_config_path!
|
271
|
-
set "config_file=!alt_config_path!"
|
272
|
-
) else (
|
273
|
-
echo Configuration file not found at: !alt_config_path!
|
274
|
-
echo.
|
275
|
-
set /p retry="Would you like to try another path? (Y/N): "
|
276
|
-
if /i "!retry!"=="Y" (
|
277
|
-
goto retry_config_path
|
278
|
-
) else (
|
279
|
-
goto end_script
|
280
|
-
)
|
281
|
-
)
|
282
|
-
|
283
|
-
:config_check_complete
|
284
|
-
|
285
|
-
:: Check if the file exists and attempt to copy it to the local directory
|
286
|
-
echo Checking for the update script...
|
287
|
-
ping -n 2 127.0.0.1 >nul
|
288
|
-
|
289
|
-
:: Continue with existing logic but with enhanced error reporting
|
290
|
-
:: First check if we already have it locally
|
291
|
-
if exist "%upgrade_medicafe_local%" (
|
292
|
-
echo Found update_medicafe.py in local directory. No action needed.
|
293
|
-
ping -n 2 127.0.0.1 >nul
|
294
|
-
) else (
|
295
|
-
if exist "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" (
|
296
|
-
echo Found update_medicafe.py in site-packages. Copying to local directory...
|
297
|
-
ping -n 2 127.0.0.1 >nul
|
298
|
-
:: Ensure MediBot directory exists
|
299
|
-
if not exist "MediBot" mkdir "MediBot"
|
300
|
-
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_local%" >nul 2>&1
|
301
|
-
if %errorlevel% neq 0 (
|
302
|
-
echo Copy to local directory failed. Error code: %errorlevel%
|
303
|
-
echo [DIAGNOSTIC] Attempting copy to F: drive - detailed error reporting
|
304
|
-
ping -n 2 127.0.0.1 >nul
|
305
|
-
:: Ensure F:\Medibot directory exists (only if F: drive is accessible)
|
306
|
-
if exist "F:\" (
|
307
|
-
if not exist "F:\Medibot" (
|
308
|
-
echo [DIAGNOSTIC] Creating F:\Medibot directory...
|
309
|
-
mkdir "F:\Medibot" 2>nul
|
310
|
-
if not exist "F:\Medibot" (
|
311
|
-
echo [ERROR] Failed to create F:\Medibot - Permission denied or read-only drive
|
312
|
-
)
|
313
|
-
)
|
314
|
-
if exist "F:\Medibot" (
|
315
|
-
echo [DIAGNOSTIC] Attempting file copy to F:\Medibot...
|
316
|
-
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_legacy%" 2>nul
|
317
|
-
if %errorlevel% neq 0 (
|
318
|
-
echo [ERROR] Copy to F:\Medibot failed with error code: %errorlevel%
|
319
|
-
echo [ERROR] Possible causes:
|
320
|
-
echo - Permission denied [insufficient write access]
|
321
|
-
echo - Disk full
|
322
|
-
echo - File locked by another process
|
323
|
-
echo - Antivirus blocking the operation
|
324
|
-
) else (
|
325
|
-
echo [SUCCESS] File copied to F:\Medibot successfully
|
326
|
-
)
|
327
|
-
)
|
328
|
-
) else (
|
329
|
-
echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
|
330
|
-
)
|
331
|
-
) else (
|
332
|
-
echo File copied to local directory successfully.
|
333
|
-
ping -n 2 127.0.0.1 >nul
|
334
|
-
)
|
335
|
-
) else (
|
336
|
-
if exist "%upgrade_medicafe_legacy%" (
|
337
|
-
echo Found update_medicafe.py in legacy F: drive location.
|
338
|
-
echo [DIAGNOSTIC] Verifying F: drive file accessibility...
|
339
|
-
type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1
|
340
|
-
if %errorlevel% equ 0 (
|
341
|
-
echo [OK] F: drive file is accessible and readable
|
342
|
-
) else (
|
343
|
-
echo [ERROR] F: drive file exists but cannot be read [permission/lock issue]
|
344
|
-
)
|
345
|
-
ping -n 2 127.0.0.1 >nul
|
346
|
-
) else (
|
347
|
-
echo update_medicafe.py not detected in any known location.
|
348
|
-
set "PRES_WARN_UPDATE_SCRIPT=1"
|
349
|
-
echo.
|
350
|
-
echo Checked locations:
|
351
|
-
echo - Site-packages: C:\Python34\Lib\site-packages\MediBot\update_medicafe.py
|
352
|
-
echo - Local: %upgrade_medicafe_local%
|
353
|
-
echo - Legacy: %upgrade_medicafe_legacy%
|
354
|
-
echo.
|
355
|
-
echo [DIAGNOSTIC] Current working directory:
|
356
|
-
cd
|
357
|
-
echo [DIAGNOSTIC] Current directory contents:
|
358
|
-
dir /b
|
359
|
-
echo.
|
360
|
-
echo [DIAGNOSTIC] MediBot directory contents:
|
361
|
-
dir /b MediBot\ 2>nul || echo MediBot directory not found
|
362
|
-
echo.
|
363
|
-
echo Continuing without update script...
|
364
|
-
ping -n 2 127.0.0.1 >nul
|
365
|
-
)
|
366
|
-
)
|
367
|
-
)
|
368
|
-
|
369
|
-
:: Auto-run CSV processing on startup
|
370
|
-
echo.
|
371
|
-
echo Running startup CSV processing...
|
372
|
-
call "%~dp0process_csvs.bat"
|
373
|
-
echo Startup CSV processing complete.
|
374
|
-
echo.
|
375
|
-
|
376
|
-
:: Main menu
|
377
|
-
:main_menu
|
378
|
-
cls
|
379
|
-
echo Version: %medicafe_version%
|
380
|
-
echo --------------------------------------------------------------
|
381
|
-
echo .//* Welcome to MediCafe *\\.
|
382
|
-
echo --------------------------------------------------------------
|
383
|
-
echo.
|
384
|
-
|
385
|
-
:: Preserve important warnings/errors from boot sequence
|
386
|
-
if "%PRES_WARN_UPDATE_SCRIPT%"=="1" (
|
387
|
-
echo [WARNING] Update helper script not detected during startup. Update features may be limited.
|
388
|
-
echo.
|
389
|
-
)
|
390
|
-
if "%PRES_WARN_NO_INTERNET%"=="1" (
|
391
|
-
echo [WARNING] No internet connectivity detected during startup.
|
392
|
-
echo.
|
393
|
-
)
|
394
|
-
|
395
|
-
if "!internet_available!"=="0" (
|
396
|
-
echo NOTE: No internet detected. Options 1-5 require internet.
|
397
|
-
echo.
|
398
|
-
)
|
399
|
-
echo Please select an option:
|
400
|
-
echo.
|
401
|
-
echo 1. Update MediCafe
|
402
|
-
echo.
|
403
|
-
echo 2. Download Email de Carol
|
404
|
-
echo.
|
405
|
-
echo 3. MediLink Claims
|
406
|
-
echo.
|
407
|
-
echo 4. ^[United^] Claims Status
|
408
|
-
echo.
|
409
|
-
echo 5. ^[United^] Deductible
|
410
|
-
echo.
|
411
|
-
echo 6. Run MediBot
|
412
|
-
echo.
|
413
|
-
echo 7. Troubleshooting
|
414
|
-
echo.
|
415
|
-
echo 8. Exit
|
416
|
-
echo.
|
417
|
-
set /p choice=Enter your choice:
|
418
|
-
|
419
|
-
:: Update option numbers
|
420
|
-
if "!choice!"=="8" goto end_script
|
421
|
-
if "!choice!"=="7" goto troubleshooting_menu
|
422
|
-
if "!choice!"=="6" goto medibot_flow
|
423
|
-
if "!choice!"=="5" goto united_deductible
|
424
|
-
if "!choice!"=="4" goto united_claims_status
|
425
|
-
if "!choice!"=="3" goto medilink_flow
|
426
|
-
if "!choice!"=="2" goto download_emails
|
427
|
-
if "!choice!"=="1" goto check_updates
|
428
|
-
if "!choice!"=="0" goto end_script
|
429
|
-
|
430
|
-
echo Invalid choice. Please try again.
|
431
|
-
pause
|
432
|
-
goto main_menu
|
433
|
-
|
434
|
-
:: Medicafe Update
|
435
|
-
:check_updates
|
436
|
-
if "!internet_available!"=="0" (
|
437
|
-
echo ========================================
|
438
|
-
echo UPDATE ERROR
|
439
|
-
echo ========================================
|
440
|
-
echo.
|
441
|
-
echo [ERROR] No internet connection available.
|
442
|
-
echo.
|
443
|
-
echo MediCafe updates require an internet connection.
|
444
|
-
echo Please check your network connection and try again.
|
445
|
-
echo.
|
446
|
-
echo Press Enter to return to main menu...
|
447
|
-
pause >nul
|
448
|
-
goto main_menu
|
449
|
-
)
|
450
|
-
|
451
|
-
echo ========================================
|
452
|
-
echo MediCafe Update Process
|
453
|
-
echo ========================================
|
454
|
-
echo.
|
455
|
-
echo Checking system requirements...
|
456
|
-
echo.
|
457
|
-
|
458
|
-
:: Step 1: Verify Python installation
|
459
|
-
echo [1/5] Checking Python installation...
|
460
|
-
python --version >nul 2>&1
|
461
|
-
if %errorlevel% neq 0 (
|
462
|
-
echo [ERROR] Python is not installed or not in PATH.
|
463
|
-
echo Please install Python 3.4 or later and try again.
|
464
|
-
echo.
|
465
|
-
echo Press Enter to return to main menu...
|
466
|
-
pause >nul
|
467
|
-
goto main_menu
|
468
|
-
)
|
469
|
-
echo [OK] Python found
|
470
|
-
echo.
|
471
|
-
|
472
|
-
:: Step 2: Check if update script exists
|
473
|
-
echo [2/5] Locating update script...
|
474
|
-
if exist "%upgrade_medicafe_local%" (
|
475
|
-
set "upgrade_medicafe=%upgrade_medicafe_local%"
|
476
|
-
echo [OK] Found local update script
|
477
|
-
) else (
|
478
|
-
if exist "%upgrade_medicafe_legacy%" (
|
479
|
-
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
480
|
-
echo [OK] Found legacy update script
|
481
|
-
) else (
|
482
|
-
echo [ERROR] Update script not found
|
483
|
-
echo.
|
484
|
-
echo Expected locations:
|
485
|
-
echo - Local: %upgrade_medicafe_local%
|
486
|
-
echo - Legacy: %upgrade_medicafe_legacy%
|
487
|
-
echo.
|
488
|
-
echo Please ensure the update script is available.
|
489
|
-
echo.
|
490
|
-
echo Press Enter to return to main menu...
|
491
|
-
pause >nul
|
492
|
-
goto main_menu
|
493
|
-
)
|
494
|
-
)
|
495
|
-
echo.
|
496
|
-
|
497
|
-
:: Step 3: Check MediCafe package
|
498
|
-
echo [3/5] Checking MediCafe installation...
|
499
|
-
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" >nul 2>&1
|
500
|
-
if %errorlevel% neq 0 (
|
501
|
-
echo [WARNING] MediCafe package not found
|
502
|
-
echo Will attempt to install during update process
|
503
|
-
) else (
|
504
|
-
echo [OK] MediCafe package found
|
505
|
-
)
|
506
|
-
echo.
|
507
|
-
|
508
|
-
:: Step 4: Verify internet connectivity
|
509
|
-
echo [4/5] Testing internet connection...
|
510
|
-
ping -n 1 google.com >nul 2>&1
|
511
|
-
if %errorlevel% neq 0 (
|
512
|
-
echo [ERROR] Internet connection test failed
|
513
|
-
echo Please check your network connection and try again.
|
514
|
-
echo.
|
515
|
-
echo Press Enter to return to main menu...
|
516
|
-
pause >nul
|
517
|
-
goto main_menu
|
518
|
-
)
|
519
|
-
echo [OK] Internet connection available
|
520
|
-
echo.
|
521
|
-
|
522
|
-
:: Step 5: Start update process (self-update orchestrator)
|
523
|
-
echo [5/5] Preparing self-update...
|
524
|
-
echo.
|
525
|
-
echo ========================================
|
526
|
-
echo UPDATE PREPARATION
|
527
|
-
echo ========================================
|
528
|
-
echo The application will close to allow safe replacement of files.
|
529
|
-
echo A separate updater will run and reopen MediBot when finished.
|
530
|
-
echo.
|
531
|
-
echo Update script: %upgrade_medicafe%
|
532
|
-
echo.
|
533
|
-
|
534
|
-
:: Build a temporary updater to run after this window exits
|
535
|
-
set "_MEDIBOT_PATH=%~f0"
|
536
|
-
|
537
|
-
:: Choose a writable temp directory with XP-safe fallback
|
538
|
-
if not defined TEMP set "TEMP=%~dp0"
|
539
|
-
if not exist "%TEMP%" mkdir "%TEMP%" 2>nul
|
540
|
-
set "_UPD_RUNNER=%TEMP%\medicafe_update_runner_%RANDOM%.cmd"
|
541
|
-
|
542
|
-
:: Create updater script line-by-line to avoid XP parsing issues with grouped redirection
|
543
|
-
echo @echo off> "%_UPD_RUNNER%"
|
544
|
-
echo setlocal enabledelayedexpansion>> "%_UPD_RUNNER%"
|
545
|
-
echo set "MEDIBOT_PATH=%_MEDIBOT_PATH%" >> "%_UPD_RUNNER%"
|
546
|
-
echo rem Wait briefly to ensure the main window has exited and released file locks>> "%_UPD_RUNNER%"
|
547
|
-
echo ping 127.0.0.1 -n 3 ^>nul>> "%_UPD_RUNNER%"
|
548
|
-
echo echo Starting MediCafe updater...>> "%_UPD_RUNNER%"
|
549
|
-
:: XP-compatible Python presence check
|
550
|
-
echo python --version ^>nul 2^>nul>> "%_UPD_RUNNER%"
|
551
|
-
echo if errorlevel 1 (>> "%_UPD_RUNNER%"
|
552
|
-
echo echo [ERROR] Python not found in PATH. Aborting update.>> "%_UPD_RUNNER%"
|
553
|
-
echo goto :eof>> "%_UPD_RUNNER%"
|
554
|
-
echo )>> "%_UPD_RUNNER%"
|
555
|
-
:: Run the updater directly with fully-resolved path to avoid nested %% var expansion issues
|
556
|
-
echo python "%upgrade_medicafe%" >> "%_UPD_RUNNER%"
|
557
|
-
echo set "RET=%%ERRORLEVEL%%" >> "%_UPD_RUNNER%"
|
558
|
-
echo echo Update process exited with code %%RET%%>> "%_UPD_RUNNER%"
|
559
|
-
echo if %%RET%% neq 0 (>> "%_UPD_RUNNER%"
|
560
|
-
echo echo Update failed. Press any key to close...>> "%_UPD_RUNNER%"
|
561
|
-
echo pause ^>nul>> "%_UPD_RUNNER%"
|
562
|
-
echo exit %%RET%%>> "%_UPD_RUNNER%"
|
563
|
-
echo ) else (>> "%_UPD_RUNNER%"
|
564
|
-
echo rem Relaunch MediBot on success>> "%_UPD_RUNNER%"
|
565
|
-
echo if exist "%%MEDIBOT_PATH%%" start "MediBot" "%%MEDIBOT_PATH%%" >> "%_UPD_RUNNER%"
|
566
|
-
echo exit>> "%_UPD_RUNNER%"
|
567
|
-
echo )>> "%_UPD_RUNNER%"
|
568
|
-
|
569
|
-
if not exist "%_UPD_RUNNER%" (
|
570
|
-
echo [ERROR] Failed to create updater script at %_UPD_RUNNER%
|
571
|
-
echo Press Enter to return to main menu...
|
572
|
-
pause >nul
|
573
|
-
goto main_menu
|
574
|
-
)
|
575
|
-
|
576
|
-
echo.
|
577
|
-
echo Launching updater and closing this window...
|
578
|
-
start "MediCafe Update" "%_UPD_RUNNER%"
|
579
|
-
exit 0
|
580
|
-
|
581
|
-
:: Download Carol's Emails
|
582
|
-
:download_emails
|
583
|
-
if "!internet_available!"=="0" (
|
584
|
-
echo [WARNING] No internet connection available.
|
585
|
-
goto main_menu
|
586
|
-
)
|
587
|
-
|
588
|
-
cls
|
589
|
-
echo Starting email download via MediCafe...
|
590
|
-
cd /d "%~dp0.."
|
591
|
-
python -m MediCafe download_emails
|
592
|
-
if errorlevel 1 (
|
593
|
-
echo [ERROR] Failed to download emails.
|
594
|
-
pause
|
595
|
-
goto main_menu
|
596
|
-
)
|
597
|
-
|
598
|
-
echo.
|
599
|
-
echo Processing CSV files after email download...
|
600
|
-
call "%~dp0process_csvs.bat"
|
601
|
-
|
602
|
-
pause
|
603
|
-
goto main_menu
|
604
|
-
|
605
|
-
:: MediBot Flow
|
606
|
-
:medibot_flow
|
607
|
-
cls
|
608
|
-
echo Starting MediBot flow...
|
609
|
-
cd /d "%~dp0.."
|
610
|
-
python -m MediCafe medibot
|
611
|
-
if errorlevel 1 (
|
612
|
-
echo [ERROR] Failed to start MediBot flow.
|
613
|
-
pause
|
614
|
-
)
|
615
|
-
|
616
|
-
goto main_menu
|
617
|
-
|
618
|
-
:: MediLink Flow
|
619
|
-
:medilink_flow
|
620
|
-
cls
|
621
|
-
echo Starting MediLink flow...
|
622
|
-
cd /d "%~dp0.."
|
623
|
-
python -m MediCafe medilink
|
624
|
-
if errorlevel 1 (
|
625
|
-
echo [ERROR] Failed to start MediLink flow.
|
626
|
-
pause
|
627
|
-
)
|
628
|
-
|
629
|
-
goto main_menu
|
630
|
-
|
631
|
-
:toggle_perf_logging
|
632
|
-
cls
|
633
|
-
echo ========================================
|
634
|
-
echo Performance Logging (session toggle)
|
635
|
-
echo ========================================
|
636
|
-
echo.
|
637
|
-
if /I "%MEDICAFE_PERFORMANCE_LOGGING%"=="1" (
|
638
|
-
set "MEDICAFE_PERFORMANCE_LOGGING=0"
|
639
|
-
echo Turned OFF performance logging for this session.
|
640
|
-
) else (
|
641
|
-
set "MEDICAFE_PERFORMANCE_LOGGING=1"
|
642
|
-
echo Turned ON performance logging for this session.
|
643
|
-
)
|
644
|
-
echo.
|
645
|
-
echo Note: This affects current session only. To persist, set in config.json.
|
646
|
-
pause
|
647
|
-
goto troubleshooting_menu
|
648
|
-
|
649
|
-
:: United Claims Status
|
650
|
-
:united_claims_status
|
651
|
-
cls
|
652
|
-
echo Starting United Claims Status...
|
653
|
-
cd /d "%~dp0.."
|
654
|
-
python -m MediCafe claims_status
|
655
|
-
if errorlevel 1 (
|
656
|
-
echo [ERROR] Failed to start United Claims Status.
|
657
|
-
pause
|
658
|
-
)
|
659
|
-
|
660
|
-
pause
|
661
|
-
goto main_menu
|
662
|
-
|
663
|
-
:: United Deductible
|
664
|
-
:united_deductible
|
665
|
-
cls
|
666
|
-
echo Starting United Deductible...
|
667
|
-
cd /d "%~dp0.."
|
668
|
-
python -m MediCafe deductible
|
669
|
-
if errorlevel 1 (
|
670
|
-
echo [ERROR] Failed to start United Deductible.
|
671
|
-
pause
|
672
|
-
)
|
673
|
-
|
674
|
-
pause
|
675
|
-
goto main_menu
|
676
|
-
|
677
|
-
:: Process CSV Files moved to external script
|
678
|
-
:process_csvs
|
679
|
-
echo Processing CSV files...
|
680
|
-
call "%~dp0process_csvs.bat"
|
681
|
-
echo.
|
682
|
-
echo Press any key to return to Troubleshooting menu...
|
683
|
-
pause >nul
|
684
|
-
goto troubleshooting_menu
|
685
|
-
|
686
|
-
REM [removed legacy :clear_cache block in favor of :clear_cache_menu]
|
687
|
-
|
688
|
-
REM [removed duplicate :clear_cache quick block; use :clear_cache_menu instead]
|
689
|
-
|
690
|
-
:: Clear Cache submenu (Quick vs Deep)
|
691
|
-
:clear_cache_menu
|
692
|
-
cls
|
693
|
-
echo ========================================
|
694
|
-
echo Clear Python Cache
|
695
|
-
echo ========================================
|
696
|
-
echo.
|
697
|
-
echo 1. Quick clear - compileall + delete __pycache__
|
698
|
-
echo 2. Deep clear via update_medicafe.py
|
699
|
-
echo 3. Back
|
700
|
-
echo.
|
701
|
-
set /p cc_choice=Enter your choice:
|
702
|
-
if "%cc_choice%"=="1" goto clear_cache_quick
|
703
|
-
if "%cc_choice%"=="2" goto clear_cache_deep
|
704
|
-
if "%cc_choice%"=="3" goto troubleshooting_menu
|
705
|
-
echo Invalid choice. Press any key to continue...
|
706
|
-
pause >nul
|
707
|
-
goto clear_cache_menu
|
708
|
-
|
709
|
-
:clear_cache_quick
|
710
|
-
echo Running quick cache clear...
|
711
|
-
call "%~dp0clear_cache.bat" --quick
|
712
|
-
pause
|
713
|
-
goto troubleshooting_menu
|
714
|
-
|
715
|
-
:clear_cache_deep
|
716
|
-
cls
|
717
|
-
echo Deep cache clear using update_medicafe.py...
|
718
|
-
echo.
|
719
|
-
call "%~dp0clear_cache.bat" --deep
|
720
|
-
pause
|
721
|
-
goto troubleshooting_menu
|
722
|
-
|
723
|
-
:: Troubleshooting Submenu
|
724
|
-
:troubleshooting_menu
|
725
|
-
cls
|
726
|
-
echo Troubleshooting Options:
|
727
|
-
echo.
|
728
|
-
echo 1. Open Latest Log File
|
729
|
-
echo 2. Clear Python Cache
|
730
|
-
echo 3. Toggle Performance Logging ^(session^)
|
731
|
-
echo 4. Forced MediCafe version rollback
|
732
|
-
echo 5. Process CSV Files
|
733
|
-
echo 6. Back to Main Menu
|
734
|
-
echo.
|
735
|
-
set /p tchoice=Enter your choice:
|
736
|
-
if "%tchoice%"=="1" goto open_latest_log
|
737
|
-
if "%tchoice%"=="2" goto clear_cache_menu
|
738
|
-
if "%tchoice%"=="3" goto toggle_perf_logging
|
739
|
-
if "%tchoice%"=="4" goto forced_version_rollback
|
740
|
-
if "%tchoice%"=="5" goto process_csvs
|
741
|
-
if "%tchoice%"=="6" goto main_menu
|
742
|
-
echo Invalid choice. Please try again.
|
743
|
-
pause
|
744
|
-
goto troubleshooting_menu
|
745
|
-
|
746
|
-
:: Open Latest Log (streamlined)
|
747
|
-
:open_latest_log
|
748
|
-
echo Opening the latest log file...
|
749
|
-
set "latest_log="
|
750
|
-
for /f "delims=" %%a in ('dir /b /a-d /o-d "%local_storage_path%\*.log" 2^>nul') do (
|
751
|
-
set "latest_log=%%a"
|
752
|
-
goto open_log_found
|
753
|
-
)
|
754
|
-
|
755
|
-
echo No log files found in %local_storage_path%.
|
756
|
-
pause
|
757
|
-
goto troubleshooting_menu
|
758
|
-
|
759
|
-
:: End Script
|
760
|
-
:end_script
|
761
|
-
echo Exiting MediBot
|
762
|
-
exit 0
|
763
|
-
|
764
|
-
:: Full Debug Mode moved to external script full_debug_suite.bat
|
765
|
-
|
766
|
-
:: Opened log file handling and helpers
|
767
|
-
:open_log_found
|
768
|
-
echo Found log file: %latest_log%
|
769
|
-
start notepad "%local_storage_path%\%latest_log%" >nul 2>&1
|
770
|
-
if %errorlevel% neq 0 (
|
771
|
-
start write "%local_storage_path%\%latest_log%" >nul 2>&1
|
772
|
-
)
|
773
|
-
if %errorlevel% neq 0 (
|
774
|
-
call :tail "%local_storage_path%\%latest_log%" 50
|
775
|
-
)
|
776
|
-
pause
|
777
|
-
goto troubleshooting_menu
|
778
|
-
|
779
|
-
:: Forced version rollback for MediCafe (hardcoded version placeholder)
|
780
|
-
:forced_version_rollback
|
781
|
-
cls
|
782
|
-
echo ========================================
|
783
|
-
echo Forced MediCafe Version Rollback
|
784
|
-
echo ========================================
|
785
|
-
echo.
|
786
|
-
if "!internet_available!"=="0" (
|
787
|
-
echo No internet connection available.
|
788
|
-
echo Cannot proceed with rollback without internet.
|
789
|
-
pause >nul
|
790
|
-
goto troubleshooting_menu
|
791
|
-
)
|
792
|
-
set "rollback_version=0.250813.1"
|
793
|
-
echo Forcing reinstall of %medicafe_package%==%rollback_version% with no dependencies...
|
794
|
-
python -m pip install --no-deps --force-reinstall %medicafe_package%==%rollback_version%
|
795
|
-
if errorlevel 1 (
|
796
|
-
echo.
|
797
|
-
echo [ERROR] Forced rollback failed.
|
798
|
-
pause >nul
|
799
|
-
goto troubleshooting_menu
|
800
|
-
)
|
801
|
-
|
802
|
-
:: Refresh displayed MediCafe version
|
803
|
-
set "package_version="
|
804
|
-
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
|
805
|
-
set /p package_version=<temp.txt
|
806
|
-
if exist temp.txt del temp.txt
|
807
|
-
if defined package_version (
|
808
|
-
for /f "tokens=2 delims==" %%a in ("%package_version%") do (
|
809
|
-
set "medicafe_version=%%a"
|
810
|
-
)
|
811
|
-
)
|
812
|
-
echo.
|
813
|
-
echo Rollback complete. Current MediCafe version: %medicafe_version%
|
814
|
-
pause >nul
|
815
|
-
goto troubleshooting_menu
|
816
|
-
|
817
|
-
:: Subroutine to display the last N lines of a file
|
818
|
-
:tail
|
819
|
-
:: Usage: call :tail filename number_of_lines
|
820
|
-
setlocal
|
821
|
-
set "file=%~1"
|
822
|
-
set /a lines=%~2
|
823
|
-
|
824
|
-
:: Get total line count robustly (avoid prefixed output)
|
825
|
-
set "count=0"
|
826
|
-
for /f %%a in ('type "%file%" ^| find /v /c ""') do set count=%%a
|
827
|
-
|
828
|
-
:: Compute starting line; clamp to 1
|
829
|
-
set /a start=count-lines+1
|
830
|
-
if !start! lss 1 set start=1
|
831
|
-
|
832
|
-
for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
|
833
|
-
if %%a geq !start! echo %%b
|
834
|
-
)
|
1
|
+
::MediBot.bat - Streamlined version with coordinated debug system
|
2
|
+
@echo off
|
3
|
+
setlocal enabledelayedexpansion
|
4
|
+
|
5
|
+
:: Clear screen before launcher header
|
6
|
+
cls
|
7
|
+
|
8
|
+
:: Launcher header
|
9
|
+
echo ========================================
|
10
|
+
echo MediCafe Launcher
|
11
|
+
echo ========================================
|
12
|
+
echo.
|
13
|
+
|
14
|
+
:: Hidden debug access: 1-second Enter-to-open gate; otherwise start normal mode
|
15
|
+
echo Press Enter within 1 second to open Debug Options... (otherwise starting Normal Mode)
|
16
|
+
rem Prefer timeout for key-break; fall back to ping if unavailable
|
17
|
+
where timeout >nul 2>&1
|
18
|
+
if errorlevel 1 (
|
19
|
+
rem Fallback: simple 1-second delay (no key detection on XP fallback)
|
20
|
+
ping -n 2 127.0.0.1 >nul
|
21
|
+
goto start_normal_mode
|
22
|
+
) else (
|
23
|
+
timeout /t 1 >nul 2>nul
|
24
|
+
if errorlevel 1 goto show_debug_menu
|
25
|
+
goto start_normal_mode
|
26
|
+
)
|
27
|
+
|
28
|
+
:show_debug_menu
|
29
|
+
echo.
|
30
|
+
echo Choose your mode:
|
31
|
+
echo 1. Normal Mode - Production
|
32
|
+
echo 2. Debug Mode - Full diagnostics (Interactive)
|
33
|
+
echo 3. Debug Mode - Full diagnostics (Non-Interactive)
|
34
|
+
echo.
|
35
|
+
set /p debug_choice="Enter your choice (1-3): "
|
36
|
+
|
37
|
+
if "!debug_choice!"=="1" goto start_normal_mode
|
38
|
+
if "!debug_choice!"=="2" goto start_debug_interactive
|
39
|
+
if "!debug_choice!"=="3" goto start_debug_noninteractive
|
40
|
+
goto start_normal_mode
|
41
|
+
|
42
|
+
:start_debug_interactive
|
43
|
+
echo.
|
44
|
+
echo ========================================
|
45
|
+
echo DEBUG MODE (INTERACTIVE)
|
46
|
+
echo ========================================
|
47
|
+
echo Running full diagnostic suite...
|
48
|
+
set "MEDICAFE_IMPORT_DEBUG=1"
|
49
|
+
set "MEDICAFE_IMPORT_STRICT=0"
|
50
|
+
echo.
|
51
|
+
set "SKIP_CLS_AFTER_DEBUG=1"
|
52
|
+
call "%~dp0full_debug_suite.bat" /interactive
|
53
|
+
echo.
|
54
|
+
goto normal_mode
|
55
|
+
|
56
|
+
:start_debug_noninteractive
|
57
|
+
echo.
|
58
|
+
echo ========================================
|
59
|
+
echo DEBUG MODE (NON-INTERACTIVE)
|
60
|
+
echo ========================================
|
61
|
+
echo Running full diagnostic suite...
|
62
|
+
set "MEDICAFE_IMPORT_DEBUG=1"
|
63
|
+
set "MEDICAFE_IMPORT_STRICT=0"
|
64
|
+
echo.
|
65
|
+
set "SKIP_CLS_AFTER_DEBUG=1"
|
66
|
+
call "%~dp0full_debug_suite.bat"
|
67
|
+
echo.
|
68
|
+
goto normal_mode
|
69
|
+
|
70
|
+
:start_normal_mode
|
71
|
+
echo Starting Normal Mode...
|
72
|
+
set "MEDICAFE_IMPORT_DEBUG=0"
|
73
|
+
set "MEDICAFE_IMPORT_STRICT=1"
|
74
|
+
goto normal_mode
|
75
|
+
|
76
|
+
:normal_mode
|
77
|
+
:: Normal production mode - streamlined without excessive debug output
|
78
|
+
if not defined SKIP_CLS_AFTER_DEBUG cls
|
79
|
+
set "SKIP_CLS_AFTER_DEBUG="
|
80
|
+
echo ========================================
|
81
|
+
echo MediCafe Starting...
|
82
|
+
echo ========================================
|
83
|
+
echo.
|
84
|
+
|
85
|
+
:: Define paths with local fallbacks for F: drive dependencies
|
86
|
+
set "source_folder=C:\MEDIANSI\MediCare"
|
87
|
+
set "target_folder=C:\MEDIANSI\MediCare\CSV"
|
88
|
+
set "python_script=C:\Python34\Lib\site-packages\MediBot\update_json.py"
|
89
|
+
set "python_script2=C:\Python34\Lib\site-packages\MediBot\Medibot.py"
|
90
|
+
set "medicafe_package=medicafe"
|
91
|
+
|
92
|
+
:: Absolute paths for updater scripts
|
93
|
+
set "script_dir=%~dp0"
|
94
|
+
set "upgrade_medicafe_local=%script_dir%update_medicafe.py"
|
95
|
+
set "upgrade_medicafe_legacy=F:\Medibot\update_medicafe.py"
|
96
|
+
|
97
|
+
:: Storage and config paths with local fallbacks
|
98
|
+
set "local_storage_legacy=F:\Medibot\DOWNLOADS"
|
99
|
+
set "local_storage_local=MediBot\DOWNLOADS"
|
100
|
+
set "config_file_legacy=F:\Medibot\json\config.json"
|
101
|
+
set "config_file_local=MediBot\json\config.json"
|
102
|
+
set "temp_file_legacy=F:\Medibot\last_update_timestamp.txt"
|
103
|
+
set "temp_file_local=MediBot\last_update_timestamp.txt"
|
104
|
+
|
105
|
+
:: Ensure F: has the latest updater when available; prefer F: when present
|
106
|
+
if exist "F:\" (
|
107
|
+
if not exist "F:\Medibot" mkdir "F:\Medibot" 2>nul
|
108
|
+
if exist "%upgrade_medicafe_local%" (
|
109
|
+
copy /Y "%upgrade_medicafe_local%" "%upgrade_medicafe_legacy%" >nul 2>&1
|
110
|
+
)
|
111
|
+
)
|
112
|
+
|
113
|
+
:: Preference order: 1) F: drive updater, 2) Local updater
|
114
|
+
if exist "%upgrade_medicafe_legacy%" (
|
115
|
+
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
116
|
+
set "use_local_update=0"
|
117
|
+
) else if exist "%upgrade_medicafe_local%" (
|
118
|
+
set "upgrade_medicafe=%upgrade_medicafe_local%"
|
119
|
+
set "use_local_update=1"
|
120
|
+
) else (
|
121
|
+
set "upgrade_medicafe="
|
122
|
+
)
|
123
|
+
|
124
|
+
:: Determine which paths to use based on availability
|
125
|
+
if exist "F:\Medibot" (
|
126
|
+
set "local_storage_path=%local_storage_legacy%"
|
127
|
+
set "config_file=%config_file_legacy%"
|
128
|
+
set "temp_file=%temp_file_legacy%"
|
129
|
+
|
130
|
+
:: Only use F: drive update script if local doesn't exist
|
131
|
+
if "!use_local_update!"=="0" (
|
132
|
+
if exist "%upgrade_medicafe_legacy%" (
|
133
|
+
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
134
|
+
)
|
135
|
+
)
|
136
|
+
) else (
|
137
|
+
set "local_storage_path=%local_storage_local%"
|
138
|
+
set "config_file=%config_file_local%"
|
139
|
+
set "temp_file=%temp_file_local%"
|
140
|
+
:: Ensure local directories exist
|
141
|
+
if not exist "MediBot\json" mkdir "MediBot\json" 2>nul
|
142
|
+
if not exist "MediBot\DOWNLOADS" mkdir "MediBot\DOWNLOADS" 2>nul
|
143
|
+
)
|
144
|
+
|
145
|
+
set "firefox_path=C:\Program Files\Mozilla Firefox\firefox.exe"
|
146
|
+
set "claims_status_script=..\MediLink\MediLink_ClaimStatus.py"
|
147
|
+
set "deductible_script=..\MediLink\MediLink_Deductible.py"
|
148
|
+
set "package_version="
|
149
|
+
set PYTHONWARNINGS=ignore
|
150
|
+
set "PRES_WARN_UPDATE_SCRIPT=0"
|
151
|
+
set "PRES_WARN_NO_INTERNET=0"
|
152
|
+
|
153
|
+
:: Check if Python is installed
|
154
|
+
python --version >nul 2>&1
|
155
|
+
if %errorlevel% neq 0 (
|
156
|
+
echo [ERROR] Python is not installed or not added to PATH.
|
157
|
+
echo Please run in Debug Mode to diagnose Python issues.
|
158
|
+
pause
|
159
|
+
exit /b 1
|
160
|
+
)
|
161
|
+
|
162
|
+
:: Check if critical directories exist
|
163
|
+
if not exist "%source_folder%" (
|
164
|
+
echo [WARNING] Source folder not found at: %source_folder%
|
165
|
+
set /p provide_alt_source="Enter 'Y' to provide alternate path, or any other key to continue: "
|
166
|
+
if /i "!provide_alt_source!"=="Y" (
|
167
|
+
set /p alt_source_folder="Enter the alternate source folder path: "
|
168
|
+
if not "!alt_source_folder!"=="" set "source_folder=!alt_source_folder!"
|
169
|
+
)
|
170
|
+
)
|
171
|
+
|
172
|
+
if not exist "%target_folder%" (
|
173
|
+
mkdir "%target_folder%" 2>nul
|
174
|
+
)
|
175
|
+
|
176
|
+
:: Check if the MediCafe package is installed
|
177
|
+
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2>nul
|
178
|
+
if errorlevel 1 (
|
179
|
+
echo [WARNING] MediCafe package not found. Attempting to install...
|
180
|
+
python -m pip install medicafe --upgrade
|
181
|
+
if errorlevel 1 (
|
182
|
+
echo [ERROR] Failed to install MediCafe package.
|
183
|
+
echo Please run in Debug Mode to diagnose package issues.
|
184
|
+
pause
|
185
|
+
exit /b 1
|
186
|
+
)
|
187
|
+
)
|
188
|
+
|
189
|
+
:: Determine installed MediCafe version
|
190
|
+
set "package_version="
|
191
|
+
set "medicafe_version="
|
192
|
+
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
|
193
|
+
set /p package_version=<temp.txt
|
194
|
+
if exist temp.txt del temp.txt
|
195
|
+
if not defined package_version (
|
196
|
+
rem Fallback: try importing MediCafe and reading __version__
|
197
|
+
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
|
198
|
+
set /p package_version=<temp.txt
|
199
|
+
if exist temp.txt del temp.txt
|
200
|
+
)
|
201
|
+
if defined package_version (
|
202
|
+
for /f "tokens=2 delims==" %%a in ("%package_version%") do set "medicafe_version=%%a"
|
203
|
+
) else (
|
204
|
+
set "medicafe_version=unknown"
|
205
|
+
)
|
206
|
+
|
207
|
+
:: Check for internet connectivity
|
208
|
+
ping -n 1 google.com >nul 2>&1
|
209
|
+
if errorlevel 1 (
|
210
|
+
set "internet_available=0"
|
211
|
+
set "PRES_WARN_NO_INTERNET=1"
|
212
|
+
) else (
|
213
|
+
set "internet_available=1"
|
214
|
+
echo Internet connection detected.
|
215
|
+
)
|
216
|
+
|
217
|
+
:: Common pre-menu setup
|
218
|
+
echo Setting up the environment...
|
219
|
+
if not exist "%config_file%" (
|
220
|
+
echo Configuration file missing.
|
221
|
+
echo.
|
222
|
+
echo Expected configuration file path: %config_file%
|
223
|
+
echo.
|
224
|
+
echo Would you like to provide an alternate path for the configuration file?
|
225
|
+
set /p provide_alt="Enter 'Y' to provide alternate path, or any other key to exit: "
|
226
|
+
if /i "!provide_alt!"=="Y" (
|
227
|
+
echo.
|
228
|
+
echo Please enter the full path to your configuration file.
|
229
|
+
echo Example: C:\MediBot\config\config.json
|
230
|
+
echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
|
231
|
+
echo.
|
232
|
+
echo Note: If your path contains spaces, please include quotes around the entire path.
|
233
|
+
echo.
|
234
|
+
set /p alt_config_path="Enter configuration file path: "
|
235
|
+
:: Remove any surrounding quotes from user input and re-add them for consistency
|
236
|
+
set "alt_config_path=!alt_config_path:"=!"
|
237
|
+
if exist "!alt_config_path!" (
|
238
|
+
echo Configuration file found at: !alt_config_path!
|
239
|
+
set "config_file=!alt_config_path!"
|
240
|
+
goto config_check_complete
|
241
|
+
) else (
|
242
|
+
echo Configuration file not found at: !alt_config_path!
|
243
|
+
echo.
|
244
|
+
set /p retry="Would you like to try another path? (Y/N): "
|
245
|
+
if /i "!retry!"=="Y" (
|
246
|
+
goto retry_config_path
|
247
|
+
) else (
|
248
|
+
goto end_script
|
249
|
+
)
|
250
|
+
)
|
251
|
+
) else (
|
252
|
+
goto end_script
|
253
|
+
)
|
254
|
+
) else (
|
255
|
+
goto config_check_complete
|
256
|
+
)
|
257
|
+
|
258
|
+
:retry_config_path
|
259
|
+
echo.
|
260
|
+
echo Please enter the full path to your configuration file.
|
261
|
+
echo Example: C:\MediBot\config\config.json
|
262
|
+
echo Example with spaces: "G:\My Drive\MediBot\config\config.json"
|
263
|
+
echo.
|
264
|
+
echo Note: If your path contains spaces, please include quotes around the entire path.
|
265
|
+
echo.
|
266
|
+
set /p alt_config_path="Enter configuration file path: "
|
267
|
+
:: Remove any surrounding quotes from user input and re-add them for consistency
|
268
|
+
set "alt_config_path=!alt_config_path:"=!"
|
269
|
+
if exist "!alt_config_path!" (
|
270
|
+
echo Configuration file found at: !alt_config_path!
|
271
|
+
set "config_file=!alt_config_path!"
|
272
|
+
) else (
|
273
|
+
echo Configuration file not found at: !alt_config_path!
|
274
|
+
echo.
|
275
|
+
set /p retry="Would you like to try another path? (Y/N): "
|
276
|
+
if /i "!retry!"=="Y" (
|
277
|
+
goto retry_config_path
|
278
|
+
) else (
|
279
|
+
goto end_script
|
280
|
+
)
|
281
|
+
)
|
282
|
+
|
283
|
+
:config_check_complete
|
284
|
+
|
285
|
+
:: Check if the file exists and attempt to copy it to the local directory
|
286
|
+
echo Checking for the update script...
|
287
|
+
ping -n 2 127.0.0.1 >nul
|
288
|
+
|
289
|
+
:: Continue with existing logic but with enhanced error reporting
|
290
|
+
:: First check if we already have it locally
|
291
|
+
if exist "%upgrade_medicafe_local%" (
|
292
|
+
echo Found update_medicafe.py in local directory. No action needed.
|
293
|
+
ping -n 2 127.0.0.1 >nul
|
294
|
+
) else (
|
295
|
+
if exist "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" (
|
296
|
+
echo Found update_medicafe.py in site-packages. Copying to local directory...
|
297
|
+
ping -n 2 127.0.0.1 >nul
|
298
|
+
:: Ensure MediBot directory exists
|
299
|
+
if not exist "MediBot" mkdir "MediBot"
|
300
|
+
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_local%" >nul 2>&1
|
301
|
+
if %errorlevel% neq 0 (
|
302
|
+
echo Copy to local directory failed. Error code: %errorlevel%
|
303
|
+
echo [DIAGNOSTIC] Attempting copy to F: drive - detailed error reporting
|
304
|
+
ping -n 2 127.0.0.1 >nul
|
305
|
+
:: Ensure F:\Medibot directory exists (only if F: drive is accessible)
|
306
|
+
if exist "F:\" (
|
307
|
+
if not exist "F:\Medibot" (
|
308
|
+
echo [DIAGNOSTIC] Creating F:\Medibot directory...
|
309
|
+
mkdir "F:\Medibot" 2>nul
|
310
|
+
if not exist "F:\Medibot" (
|
311
|
+
echo [ERROR] Failed to create F:\Medibot - Permission denied or read-only drive
|
312
|
+
)
|
313
|
+
)
|
314
|
+
if exist "F:\Medibot" (
|
315
|
+
echo [DIAGNOSTIC] Attempting file copy to F:\Medibot...
|
316
|
+
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_legacy%" 2>nul
|
317
|
+
if %errorlevel% neq 0 (
|
318
|
+
echo [ERROR] Copy to F:\Medibot failed with error code: %errorlevel%
|
319
|
+
echo [ERROR] Possible causes:
|
320
|
+
echo - Permission denied [insufficient write access]
|
321
|
+
echo - Disk full
|
322
|
+
echo - File locked by another process
|
323
|
+
echo - Antivirus blocking the operation
|
324
|
+
) else (
|
325
|
+
echo [SUCCESS] File copied to F:\Medibot successfully
|
326
|
+
)
|
327
|
+
)
|
328
|
+
) else (
|
329
|
+
echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
|
330
|
+
)
|
331
|
+
) else (
|
332
|
+
echo File copied to local directory successfully.
|
333
|
+
ping -n 2 127.0.0.1 >nul
|
334
|
+
)
|
335
|
+
) else (
|
336
|
+
if exist "%upgrade_medicafe_legacy%" (
|
337
|
+
echo Found update_medicafe.py in legacy F: drive location.
|
338
|
+
echo [DIAGNOSTIC] Verifying F: drive file accessibility...
|
339
|
+
type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1
|
340
|
+
if %errorlevel% equ 0 (
|
341
|
+
echo [OK] F: drive file is accessible and readable
|
342
|
+
) else (
|
343
|
+
echo [ERROR] F: drive file exists but cannot be read [permission/lock issue]
|
344
|
+
)
|
345
|
+
ping -n 2 127.0.0.1 >nul
|
346
|
+
) else (
|
347
|
+
echo update_medicafe.py not detected in any known location.
|
348
|
+
set "PRES_WARN_UPDATE_SCRIPT=1"
|
349
|
+
echo.
|
350
|
+
echo Checked locations:
|
351
|
+
echo - Site-packages: C:\Python34\Lib\site-packages\MediBot\update_medicafe.py
|
352
|
+
echo - Local: %upgrade_medicafe_local%
|
353
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
354
|
+
echo.
|
355
|
+
echo [DIAGNOSTIC] Current working directory:
|
356
|
+
cd
|
357
|
+
echo [DIAGNOSTIC] Current directory contents:
|
358
|
+
dir /b
|
359
|
+
echo.
|
360
|
+
echo [DIAGNOSTIC] MediBot directory contents:
|
361
|
+
dir /b MediBot\ 2>nul || echo MediBot directory not found
|
362
|
+
echo.
|
363
|
+
echo Continuing without update script...
|
364
|
+
ping -n 2 127.0.0.1 >nul
|
365
|
+
)
|
366
|
+
)
|
367
|
+
)
|
368
|
+
|
369
|
+
:: Auto-run CSV processing on startup
|
370
|
+
echo.
|
371
|
+
echo Running startup CSV processing...
|
372
|
+
call "%~dp0process_csvs.bat" /silent
|
373
|
+
echo Startup CSV processing complete.
|
374
|
+
echo.
|
375
|
+
|
376
|
+
:: Main menu
|
377
|
+
:main_menu
|
378
|
+
cls
|
379
|
+
echo Version: %medicafe_version%
|
380
|
+
echo --------------------------------------------------------------
|
381
|
+
echo .//* Welcome to MediCafe *\\.
|
382
|
+
echo --------------------------------------------------------------
|
383
|
+
echo.
|
384
|
+
|
385
|
+
:: Preserve important warnings/errors from boot sequence
|
386
|
+
if "%PRES_WARN_UPDATE_SCRIPT%"=="1" (
|
387
|
+
echo [WARNING] Update helper script not detected during startup. Update features may be limited.
|
388
|
+
echo.
|
389
|
+
)
|
390
|
+
if "%PRES_WARN_NO_INTERNET%"=="1" (
|
391
|
+
echo [WARNING] No internet connectivity detected during startup.
|
392
|
+
echo.
|
393
|
+
)
|
394
|
+
|
395
|
+
if "!internet_available!"=="0" (
|
396
|
+
echo NOTE: No internet detected. Options 1-5 require internet.
|
397
|
+
echo.
|
398
|
+
)
|
399
|
+
echo Please select an option:
|
400
|
+
echo.
|
401
|
+
echo 1. Update MediCafe
|
402
|
+
echo.
|
403
|
+
echo 2. Download Email de Carol
|
404
|
+
echo.
|
405
|
+
echo 3. MediLink Claims
|
406
|
+
echo.
|
407
|
+
echo 4. ^[United^] Claims Status
|
408
|
+
echo.
|
409
|
+
echo 5. ^[United^] Deductible
|
410
|
+
echo.
|
411
|
+
echo 6. Run MediBot
|
412
|
+
echo.
|
413
|
+
echo 7. Troubleshooting
|
414
|
+
echo.
|
415
|
+
echo 8. Exit
|
416
|
+
echo.
|
417
|
+
set /p choice=Enter your choice:
|
418
|
+
|
419
|
+
:: Update option numbers
|
420
|
+
if "!choice!"=="8" goto end_script
|
421
|
+
if "!choice!"=="7" goto troubleshooting_menu
|
422
|
+
if "!choice!"=="6" goto medibot_flow
|
423
|
+
if "!choice!"=="5" goto united_deductible
|
424
|
+
if "!choice!"=="4" goto united_claims_status
|
425
|
+
if "!choice!"=="3" goto medilink_flow
|
426
|
+
if "!choice!"=="2" goto download_emails
|
427
|
+
if "!choice!"=="1" goto check_updates
|
428
|
+
if "!choice!"=="0" goto end_script
|
429
|
+
|
430
|
+
echo Invalid choice. Please try again.
|
431
|
+
pause
|
432
|
+
goto main_menu
|
433
|
+
|
434
|
+
:: Medicafe Update
|
435
|
+
:check_updates
|
436
|
+
if "!internet_available!"=="0" (
|
437
|
+
echo ========================================
|
438
|
+
echo UPDATE ERROR
|
439
|
+
echo ========================================
|
440
|
+
echo.
|
441
|
+
echo [ERROR] No internet connection available.
|
442
|
+
echo.
|
443
|
+
echo MediCafe updates require an internet connection.
|
444
|
+
echo Please check your network connection and try again.
|
445
|
+
echo.
|
446
|
+
echo Press Enter to return to main menu...
|
447
|
+
pause >nul
|
448
|
+
goto main_menu
|
449
|
+
)
|
450
|
+
|
451
|
+
echo ========================================
|
452
|
+
echo MediCafe Update Process
|
453
|
+
echo ========================================
|
454
|
+
echo.
|
455
|
+
echo Checking system requirements...
|
456
|
+
echo.
|
457
|
+
|
458
|
+
:: Step 1: Verify Python installation
|
459
|
+
echo [1/5] Checking Python installation...
|
460
|
+
python --version >nul 2>&1
|
461
|
+
if %errorlevel% neq 0 (
|
462
|
+
echo [ERROR] Python is not installed or not in PATH.
|
463
|
+
echo Please install Python 3.4 or later and try again.
|
464
|
+
echo.
|
465
|
+
echo Press Enter to return to main menu...
|
466
|
+
pause >nul
|
467
|
+
goto main_menu
|
468
|
+
)
|
469
|
+
echo [OK] Python found
|
470
|
+
echo.
|
471
|
+
|
472
|
+
:: Step 2: Check if update script exists
|
473
|
+
echo [2/5] Locating update script...
|
474
|
+
if exist "%upgrade_medicafe_local%" (
|
475
|
+
set "upgrade_medicafe=%upgrade_medicafe_local%"
|
476
|
+
echo [OK] Found local update script
|
477
|
+
) else (
|
478
|
+
if exist "%upgrade_medicafe_legacy%" (
|
479
|
+
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
480
|
+
echo [OK] Found legacy update script
|
481
|
+
) else (
|
482
|
+
echo [ERROR] Update script not found
|
483
|
+
echo.
|
484
|
+
echo Expected locations:
|
485
|
+
echo - Local: %upgrade_medicafe_local%
|
486
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
487
|
+
echo.
|
488
|
+
echo Please ensure the update script is available.
|
489
|
+
echo.
|
490
|
+
echo Press Enter to return to main menu...
|
491
|
+
pause >nul
|
492
|
+
goto main_menu
|
493
|
+
)
|
494
|
+
)
|
495
|
+
echo.
|
496
|
+
|
497
|
+
:: Step 3: Check MediCafe package
|
498
|
+
echo [3/5] Checking MediCafe installation...
|
499
|
+
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" >nul 2>&1
|
500
|
+
if %errorlevel% neq 0 (
|
501
|
+
echo [WARNING] MediCafe package not found
|
502
|
+
echo Will attempt to install during update process
|
503
|
+
) else (
|
504
|
+
echo [OK] MediCafe package found
|
505
|
+
)
|
506
|
+
echo.
|
507
|
+
|
508
|
+
:: Step 4: Verify internet connectivity
|
509
|
+
echo [4/5] Testing internet connection...
|
510
|
+
ping -n 1 google.com >nul 2>&1
|
511
|
+
if %errorlevel% neq 0 (
|
512
|
+
echo [ERROR] Internet connection test failed
|
513
|
+
echo Please check your network connection and try again.
|
514
|
+
echo.
|
515
|
+
echo Press Enter to return to main menu...
|
516
|
+
pause >nul
|
517
|
+
goto main_menu
|
518
|
+
)
|
519
|
+
echo [OK] Internet connection available
|
520
|
+
echo.
|
521
|
+
|
522
|
+
:: Step 5: Start update process (self-update orchestrator)
|
523
|
+
echo [5/5] Preparing self-update...
|
524
|
+
echo.
|
525
|
+
echo ========================================
|
526
|
+
echo UPDATE PREPARATION
|
527
|
+
echo ========================================
|
528
|
+
echo The application will close to allow safe replacement of files.
|
529
|
+
echo A separate updater will run and reopen MediBot when finished.
|
530
|
+
echo.
|
531
|
+
echo Update script: %upgrade_medicafe%
|
532
|
+
echo.
|
533
|
+
|
534
|
+
:: Build a temporary updater to run after this window exits
|
535
|
+
set "_MEDIBOT_PATH=%~f0"
|
536
|
+
|
537
|
+
:: Choose a writable temp directory with XP-safe fallback
|
538
|
+
if not defined TEMP set "TEMP=%~dp0"
|
539
|
+
if not exist "%TEMP%" mkdir "%TEMP%" 2>nul
|
540
|
+
set "_UPD_RUNNER=%TEMP%\medicafe_update_runner_%RANDOM%.cmd"
|
541
|
+
|
542
|
+
:: Create updater script line-by-line to avoid XP parsing issues with grouped redirection
|
543
|
+
echo @echo off> "%_UPD_RUNNER%"
|
544
|
+
echo setlocal enabledelayedexpansion>> "%_UPD_RUNNER%"
|
545
|
+
echo set "MEDIBOT_PATH=%_MEDIBOT_PATH%" >> "%_UPD_RUNNER%"
|
546
|
+
echo rem Wait briefly to ensure the main window has exited and released file locks>> "%_UPD_RUNNER%"
|
547
|
+
echo ping 127.0.0.1 -n 3 ^>nul>> "%_UPD_RUNNER%"
|
548
|
+
echo echo Starting MediCafe updater...>> "%_UPD_RUNNER%"
|
549
|
+
:: XP-compatible Python presence check
|
550
|
+
echo python --version ^>nul 2^>nul>> "%_UPD_RUNNER%"
|
551
|
+
echo if errorlevel 1 (>> "%_UPD_RUNNER%"
|
552
|
+
echo echo [ERROR] Python not found in PATH. Aborting update.>> "%_UPD_RUNNER%"
|
553
|
+
echo goto :eof>> "%_UPD_RUNNER%"
|
554
|
+
echo )>> "%_UPD_RUNNER%"
|
555
|
+
:: Run the updater directly with fully-resolved path to avoid nested %% var expansion issues
|
556
|
+
echo python "%upgrade_medicafe%" >> "%_UPD_RUNNER%"
|
557
|
+
echo set "RET=%%ERRORLEVEL%%" >> "%_UPD_RUNNER%"
|
558
|
+
echo echo Update process exited with code %%RET%%>> "%_UPD_RUNNER%"
|
559
|
+
echo if %%RET%% neq 0 (>> "%_UPD_RUNNER%"
|
560
|
+
echo echo Update failed. Press any key to close...>> "%_UPD_RUNNER%"
|
561
|
+
echo pause ^>nul>> "%_UPD_RUNNER%"
|
562
|
+
echo exit %%RET%%>> "%_UPD_RUNNER%"
|
563
|
+
echo ) else (>> "%_UPD_RUNNER%"
|
564
|
+
echo rem Relaunch MediBot on success>> "%_UPD_RUNNER%"
|
565
|
+
echo if exist "%%MEDIBOT_PATH%%" start "MediBot" "%%MEDIBOT_PATH%%" >> "%_UPD_RUNNER%"
|
566
|
+
echo exit>> "%_UPD_RUNNER%"
|
567
|
+
echo )>> "%_UPD_RUNNER%"
|
568
|
+
|
569
|
+
if not exist "%_UPD_RUNNER%" (
|
570
|
+
echo [ERROR] Failed to create updater script at %_UPD_RUNNER%
|
571
|
+
echo Press Enter to return to main menu...
|
572
|
+
pause >nul
|
573
|
+
goto main_menu
|
574
|
+
)
|
575
|
+
|
576
|
+
echo.
|
577
|
+
echo Launching updater and closing this window...
|
578
|
+
start "MediCafe Update" "%_UPD_RUNNER%"
|
579
|
+
exit 0
|
580
|
+
|
581
|
+
:: Download Carol's Emails
|
582
|
+
:download_emails
|
583
|
+
if "!internet_available!"=="0" (
|
584
|
+
echo [WARNING] No internet connection available.
|
585
|
+
goto main_menu
|
586
|
+
)
|
587
|
+
|
588
|
+
cls
|
589
|
+
echo Starting email download via MediCafe...
|
590
|
+
cd /d "%~dp0.."
|
591
|
+
python -m MediCafe download_emails
|
592
|
+
if errorlevel 1 (
|
593
|
+
echo [ERROR] Failed to download emails.
|
594
|
+
pause
|
595
|
+
goto main_menu
|
596
|
+
)
|
597
|
+
|
598
|
+
echo.
|
599
|
+
echo Processing CSV files after email download...
|
600
|
+
call "%~dp0process_csvs.bat" /silent
|
601
|
+
|
602
|
+
pause
|
603
|
+
goto main_menu
|
604
|
+
|
605
|
+
:: MediBot Flow
|
606
|
+
:medibot_flow
|
607
|
+
cls
|
608
|
+
echo Starting MediBot flow...
|
609
|
+
cd /d "%~dp0.."
|
610
|
+
python -m MediCafe medibot
|
611
|
+
if errorlevel 1 (
|
612
|
+
echo [ERROR] Failed to start MediBot flow.
|
613
|
+
pause
|
614
|
+
)
|
615
|
+
|
616
|
+
goto main_menu
|
617
|
+
|
618
|
+
:: MediLink Flow
|
619
|
+
:medilink_flow
|
620
|
+
cls
|
621
|
+
echo Starting MediLink flow...
|
622
|
+
cd /d "%~dp0.."
|
623
|
+
python -m MediCafe medilink
|
624
|
+
if errorlevel 1 (
|
625
|
+
echo [ERROR] Failed to start MediLink flow.
|
626
|
+
pause
|
627
|
+
)
|
628
|
+
|
629
|
+
goto main_menu
|
630
|
+
|
631
|
+
:toggle_perf_logging
|
632
|
+
cls
|
633
|
+
echo ========================================
|
634
|
+
echo Performance Logging (session toggle)
|
635
|
+
echo ========================================
|
636
|
+
echo.
|
637
|
+
if /I "%MEDICAFE_PERFORMANCE_LOGGING%"=="1" (
|
638
|
+
set "MEDICAFE_PERFORMANCE_LOGGING=0"
|
639
|
+
echo Turned OFF performance logging for this session.
|
640
|
+
) else (
|
641
|
+
set "MEDICAFE_PERFORMANCE_LOGGING=1"
|
642
|
+
echo Turned ON performance logging for this session.
|
643
|
+
)
|
644
|
+
echo.
|
645
|
+
echo Note: This affects current session only. To persist, set in config.json.
|
646
|
+
pause
|
647
|
+
goto troubleshooting_menu
|
648
|
+
|
649
|
+
:: United Claims Status
|
650
|
+
:united_claims_status
|
651
|
+
cls
|
652
|
+
echo Starting United Claims Status...
|
653
|
+
cd /d "%~dp0.."
|
654
|
+
python -m MediCafe claims_status
|
655
|
+
if errorlevel 1 (
|
656
|
+
echo [ERROR] Failed to start United Claims Status.
|
657
|
+
pause
|
658
|
+
)
|
659
|
+
|
660
|
+
pause
|
661
|
+
goto main_menu
|
662
|
+
|
663
|
+
:: United Deductible
|
664
|
+
:united_deductible
|
665
|
+
cls
|
666
|
+
echo Starting United Deductible...
|
667
|
+
cd /d "%~dp0.."
|
668
|
+
python -m MediCafe deductible
|
669
|
+
if errorlevel 1 (
|
670
|
+
echo [ERROR] Failed to start United Deductible.
|
671
|
+
pause
|
672
|
+
)
|
673
|
+
|
674
|
+
pause
|
675
|
+
goto main_menu
|
676
|
+
|
677
|
+
:: Process CSV Files moved to external script
|
678
|
+
:process_csvs
|
679
|
+
echo Processing CSV files...
|
680
|
+
call "%~dp0process_csvs.bat"
|
681
|
+
echo.
|
682
|
+
echo Press any key to return to Troubleshooting menu...
|
683
|
+
pause >nul
|
684
|
+
goto troubleshooting_menu
|
685
|
+
|
686
|
+
REM [removed legacy :clear_cache block in favor of :clear_cache_menu]
|
687
|
+
|
688
|
+
REM [removed duplicate :clear_cache quick block; use :clear_cache_menu instead]
|
689
|
+
|
690
|
+
:: Clear Cache submenu (Quick vs Deep)
|
691
|
+
:clear_cache_menu
|
692
|
+
cls
|
693
|
+
echo ========================================
|
694
|
+
echo Clear Python Cache
|
695
|
+
echo ========================================
|
696
|
+
echo.
|
697
|
+
echo 1. Quick clear - compileall + delete __pycache__
|
698
|
+
echo 2. Deep clear via update_medicafe.py
|
699
|
+
echo 3. Back
|
700
|
+
echo.
|
701
|
+
set /p cc_choice=Enter your choice:
|
702
|
+
if "%cc_choice%"=="1" goto clear_cache_quick
|
703
|
+
if "%cc_choice%"=="2" goto clear_cache_deep
|
704
|
+
if "%cc_choice%"=="3" goto troubleshooting_menu
|
705
|
+
echo Invalid choice. Press any key to continue...
|
706
|
+
pause >nul
|
707
|
+
goto clear_cache_menu
|
708
|
+
|
709
|
+
:clear_cache_quick
|
710
|
+
echo Running quick cache clear...
|
711
|
+
call "%~dp0clear_cache.bat" --quick
|
712
|
+
pause
|
713
|
+
goto troubleshooting_menu
|
714
|
+
|
715
|
+
:clear_cache_deep
|
716
|
+
cls
|
717
|
+
echo Deep cache clear using update_medicafe.py...
|
718
|
+
echo.
|
719
|
+
call "%~dp0clear_cache.bat" --deep
|
720
|
+
pause
|
721
|
+
goto troubleshooting_menu
|
722
|
+
|
723
|
+
:: Troubleshooting Submenu
|
724
|
+
:troubleshooting_menu
|
725
|
+
cls
|
726
|
+
echo Troubleshooting Options:
|
727
|
+
echo.
|
728
|
+
echo 1. Open Latest Log File
|
729
|
+
echo 2. Clear Python Cache
|
730
|
+
echo 3. Toggle Performance Logging ^(session^)
|
731
|
+
echo 4. Forced MediCafe version rollback
|
732
|
+
echo 5. Process CSV Files
|
733
|
+
echo 6. Back to Main Menu
|
734
|
+
echo.
|
735
|
+
set /p tchoice=Enter your choice:
|
736
|
+
if "%tchoice%"=="1" goto open_latest_log
|
737
|
+
if "%tchoice%"=="2" goto clear_cache_menu
|
738
|
+
if "%tchoice%"=="3" goto toggle_perf_logging
|
739
|
+
if "%tchoice%"=="4" goto forced_version_rollback
|
740
|
+
if "%tchoice%"=="5" goto process_csvs
|
741
|
+
if "%tchoice%"=="6" goto main_menu
|
742
|
+
echo Invalid choice. Please try again.
|
743
|
+
pause
|
744
|
+
goto troubleshooting_menu
|
745
|
+
|
746
|
+
:: Open Latest Log (streamlined)
|
747
|
+
:open_latest_log
|
748
|
+
echo Opening the latest log file...
|
749
|
+
set "latest_log="
|
750
|
+
for /f "delims=" %%a in ('dir /b /a-d /o-d "%local_storage_path%\*.log" 2^>nul') do (
|
751
|
+
set "latest_log=%%a"
|
752
|
+
goto open_log_found
|
753
|
+
)
|
754
|
+
|
755
|
+
echo No log files found in %local_storage_path%.
|
756
|
+
pause
|
757
|
+
goto troubleshooting_menu
|
758
|
+
|
759
|
+
:: End Script
|
760
|
+
:end_script
|
761
|
+
echo Exiting MediBot
|
762
|
+
exit 0
|
763
|
+
|
764
|
+
:: Full Debug Mode moved to external script full_debug_suite.bat
|
765
|
+
|
766
|
+
:: Opened log file handling and helpers
|
767
|
+
:open_log_found
|
768
|
+
echo Found log file: %latest_log%
|
769
|
+
start notepad "%local_storage_path%\%latest_log%" >nul 2>&1
|
770
|
+
if %errorlevel% neq 0 (
|
771
|
+
start write "%local_storage_path%\%latest_log%" >nul 2>&1
|
772
|
+
)
|
773
|
+
if %errorlevel% neq 0 (
|
774
|
+
call :tail "%local_storage_path%\%latest_log%" 50
|
775
|
+
)
|
776
|
+
pause
|
777
|
+
goto troubleshooting_menu
|
778
|
+
|
779
|
+
:: Forced version rollback for MediCafe (hardcoded version placeholder)
|
780
|
+
:forced_version_rollback
|
781
|
+
cls
|
782
|
+
echo ========================================
|
783
|
+
echo Forced MediCafe Version Rollback
|
784
|
+
echo ========================================
|
785
|
+
echo.
|
786
|
+
if "!internet_available!"=="0" (
|
787
|
+
echo No internet connection available.
|
788
|
+
echo Cannot proceed with rollback without internet.
|
789
|
+
pause >nul
|
790
|
+
goto troubleshooting_menu
|
791
|
+
)
|
792
|
+
set "rollback_version=0.250813.1"
|
793
|
+
echo Forcing reinstall of %medicafe_package%==%rollback_version% with no dependencies...
|
794
|
+
python -m pip install --no-deps --force-reinstall %medicafe_package%==%rollback_version%
|
795
|
+
if errorlevel 1 (
|
796
|
+
echo.
|
797
|
+
echo [ERROR] Forced rollback failed.
|
798
|
+
pause >nul
|
799
|
+
goto troubleshooting_menu
|
800
|
+
)
|
801
|
+
|
802
|
+
:: Refresh displayed MediCafe version
|
803
|
+
set "package_version="
|
804
|
+
python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" > temp.txt 2>nul
|
805
|
+
set /p package_version=<temp.txt
|
806
|
+
if exist temp.txt del temp.txt
|
807
|
+
if defined package_version (
|
808
|
+
for /f "tokens=2 delims==" %%a in ("%package_version%") do (
|
809
|
+
set "medicafe_version=%%a"
|
810
|
+
)
|
811
|
+
)
|
812
|
+
echo.
|
813
|
+
echo Rollback complete. Current MediCafe version: %medicafe_version%
|
814
|
+
pause >nul
|
815
|
+
goto troubleshooting_menu
|
816
|
+
|
817
|
+
:: Subroutine to display the last N lines of a file
|
818
|
+
:tail
|
819
|
+
:: Usage: call :tail filename number_of_lines
|
820
|
+
setlocal
|
821
|
+
set "file=%~1"
|
822
|
+
set /a lines=%~2
|
823
|
+
|
824
|
+
:: Get total line count robustly (avoid prefixed output)
|
825
|
+
set "count=0"
|
826
|
+
for /f %%a in ('type "%file%" ^| find /v /c ""') do set count=%%a
|
827
|
+
|
828
|
+
:: Compute starting line; clamp to 1
|
829
|
+
set /a start=count-lines+1
|
830
|
+
if !start! lss 1 set start=1
|
831
|
+
|
832
|
+
for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
|
833
|
+
if %%a geq !start! echo %%b
|
834
|
+
)
|
835
835
|
endlocal & goto :eof
|