medicafe 0.250806.10__tar.gz → 0.250806.13__tar.gz
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.
Potentially problematic release.
This version of medicafe might be problematic. Click here for more details.
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot.bat +279 -102
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot.py +1 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Crosswalk_Library.py +22 -3
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Crosswalk_Utils.py +20 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Preprocessor_lib.py +84 -13
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/api_core.py +42 -7
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/api_factory.py +17 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_837p_encoder_library.py +38 -3
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_PatientProcessor.py +48 -3
- {medicafe-0.250806.10 → medicafe-0.250806.13}/PKG-INFO +1 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/PKG-INFO +1 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/setup.py +1 -1
- {medicafe-0.250806.10 → medicafe-0.250806.13}/LICENSE +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MANIFEST.in +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Charges.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Post.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_Preprocessor.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_UI.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_dataformat_library.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_docx_decoder.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/MediBot_smart_import.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/__init__.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/get_medicafe_version.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/update_json.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediBot/update_medicafe.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/MediLink_ConfigLoader.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/__init__.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/__main__.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/api_core_backup.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/api_utils.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/core_utils.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/graphql_utils.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/logging_config.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/logging_demo.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/migration_helpers.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediCafe/smart_import.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_837p_cob_library.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_837p_encoder.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_837p_utilities.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_API_Generator.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Azure.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_ClaimStatus.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_DataMgmt.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Decoder.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Deductible.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Deductible_Validator.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Display_Utils.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Down.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Gmail.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Mailer.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Parser.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Scan.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Scheduler.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_UI.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_Up.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_insurance_utils.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_main.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/MediLink_smart_import.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/Soumit_api.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/__init__.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/insurance_type_integration_test.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/openssl.cnf +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/test.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/test_cob_library.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/test_timing.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/test_validation.py +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/MediLink/webapp.html +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/SOURCES.txt +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/dependency_links.txt +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/entry_points.txt +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/not-zip-safe +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/requires.txt +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/medicafe.egg-info/top_level.txt +0 -0
- {medicafe-0.250806.10 → medicafe-0.250806.13}/setup.cfg +0 -0
|
@@ -2,16 +2,38 @@
|
|
|
2
2
|
@echo off
|
|
3
3
|
setlocal enabledelayedexpansion
|
|
4
4
|
|
|
5
|
-
:: Define paths
|
|
5
|
+
:: Define paths with local fallbacks for F: drive dependencies
|
|
6
6
|
set "source_folder=C:\MEDIANSI\MediCare"
|
|
7
|
-
set "local_storage_path=F:\Medibot\DOWNLOADS"
|
|
8
7
|
set "target_folder=C:\MEDIANSI\MediCare\CSV"
|
|
9
|
-
set "config_file=F:\Medibot\json\config.json"
|
|
10
8
|
set "python_script=C:\Python34\Lib\site-packages\MediBot\update_json.py"
|
|
11
9
|
set "python_script2=C:\Python34\Lib\site-packages\MediBot\Medibot.py"
|
|
12
10
|
set "medicafe_package=medicafe"
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
|
|
12
|
+
:: Priority order: 1) Local relative path, 2) F: drive path (legacy)
|
|
13
|
+
set "upgrade_medicafe_local=MediBot\update_medicafe.py"
|
|
14
|
+
set "upgrade_medicafe_legacy=F:\Medibot\update_medicafe.py"
|
|
15
|
+
|
|
16
|
+
:: Storage and config paths with local fallbacks
|
|
17
|
+
set "local_storage_legacy=F:\Medibot\DOWNLOADS"
|
|
18
|
+
set "local_storage_local=MediBot\DOWNLOADS"
|
|
19
|
+
set "config_file_legacy=F:\Medibot\json\config.json"
|
|
20
|
+
set "config_file_local=MediBot\json\config.json"
|
|
21
|
+
set "temp_file_legacy=F:\Medibot\last_update_timestamp.txt"
|
|
22
|
+
set "temp_file_local=MediBot\last_update_timestamp.txt"
|
|
23
|
+
|
|
24
|
+
:: Determine which paths to use based on availability
|
|
25
|
+
if exist "F:\Medibot" (
|
|
26
|
+
set "local_storage_path=%local_storage_legacy%"
|
|
27
|
+
set "config_file=%config_file_legacy%"
|
|
28
|
+
set "temp_file=%temp_file_legacy%"
|
|
29
|
+
) else (
|
|
30
|
+
set "local_storage_path=%local_storage_local%"
|
|
31
|
+
set "config_file=%config_file_local%"
|
|
32
|
+
set "temp_file=%temp_file_local%"
|
|
33
|
+
:: Ensure local directories exist
|
|
34
|
+
if not exist "MediBot\json" mkdir "MediBot\json" 2>nul
|
|
35
|
+
if not exist "MediBot\DOWNLOADS" mkdir "MediBot\DOWNLOADS" 2>nul
|
|
36
|
+
)
|
|
15
37
|
set "firefox_path=C:\Program Files\Mozilla Firefox\firefox.exe"
|
|
16
38
|
set "claims_status_script=..\MediLink\MediLink_ClaimStatus.py"
|
|
17
39
|
set "deductible_script=..\MediLink\MediLink_Deductible.py"
|
|
@@ -214,72 +236,175 @@ if exist "!alt_config_path!" (
|
|
|
214
236
|
|
|
215
237
|
:config_check_complete
|
|
216
238
|
|
|
217
|
-
:: Check if the file exists and attempt to
|
|
218
|
-
:: Implementing a check with copy as a fallback if move fails
|
|
239
|
+
:: Check if the file exists and attempt to copy it to the local directory
|
|
219
240
|
echo Checking for the update script...
|
|
220
241
|
ping -n 2 127.0.0.1 >nul
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
242
|
+
|
|
243
|
+
:: DIAGNOSTIC SECTION - Analyze F: drive accessibility
|
|
244
|
+
echo.
|
|
245
|
+
echo ==========================================
|
|
246
|
+
echo F: DRIVE ACCESSIBILITY DIAGNOSTICS
|
|
247
|
+
echo ==========================================
|
|
248
|
+
echo.
|
|
249
|
+
|
|
250
|
+
:: Check if F: drive exists at all
|
|
251
|
+
echo [DIAGNOSTIC] Checking F: drive existence...
|
|
252
|
+
if exist "F:\" (
|
|
253
|
+
echo [OK] F: drive is accessible
|
|
254
|
+
|
|
255
|
+
:: Check F: drive properties
|
|
256
|
+
echo [DIAGNOSTIC] F: drive properties:
|
|
257
|
+
dir F:\ | find "Directory of" 2>nul || echo [!] Cannot read F: drive directory listing
|
|
258
|
+
|
|
259
|
+
:: Check available space
|
|
260
|
+
echo [DIAGNOSTIC] F: drive free space:
|
|
261
|
+
dir F:\ | find "bytes free" 2>nul || echo [!] Cannot determine free space
|
|
262
|
+
|
|
263
|
+
:: Check if F:\Medibot directory exists
|
|
264
|
+
echo [DIAGNOSTIC] Checking F:\Medibot directory...
|
|
265
|
+
if exist "F:\Medibot" (
|
|
266
|
+
echo [OK] F:\Medibot directory exists
|
|
267
|
+
|
|
268
|
+
:: Check directory permissions by attempting to create a test file
|
|
269
|
+
echo [DIAGNOSTIC] Testing write permissions to F:\Medibot...
|
|
270
|
+
echo test > "F:\Medibot\permission_test.tmp" 2>nul
|
|
271
|
+
if exist "F:\Medibot\permission_test.tmp" (
|
|
272
|
+
echo [OK] Write permissions confirmed
|
|
273
|
+
del "F:\Medibot\permission_test.tmp" >nul 2>&1
|
|
232
274
|
) else (
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
275
|
+
echo [ERROR] PERMISSION DENIED - Cannot write to F:\Medibot
|
|
276
|
+
echo [ERROR] This is likely the cause of the path error!
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
:: List contents of F:\Medibot
|
|
280
|
+
echo [DIAGNOSTIC] F:\Medibot directory contents:
|
|
281
|
+
dir /b "F:\Medibot" 2>nul || echo [!] Cannot list directory contents (permission issue?)
|
|
282
|
+
|
|
283
|
+
:: Check if update_medicafe.py specifically exists
|
|
284
|
+
echo [DIAGNOSTIC] Checking for update_medicafe.py...
|
|
285
|
+
if exist "F:\Medibot\update_medicafe.py" (
|
|
286
|
+
echo [OK] update_medicafe.py found at F:\Medibot\update_medicafe.py
|
|
287
|
+
echo [DIAGNOSTIC] File details:
|
|
288
|
+
dir "F:\Medibot\update_medicafe.py" 2>nul || echo [!] Cannot read file details
|
|
289
|
+
|
|
290
|
+
:: Test file accessibility by attempting to read it
|
|
291
|
+
echo [DIAGNOSTIC] Testing file read permissions...
|
|
292
|
+
type "F:\Medibot\update_medicafe.py" | find "#update_medicafe.py" >nul 2>&1
|
|
293
|
+
if %errorlevel% equ 0 (
|
|
294
|
+
echo [OK] File is readable
|
|
237
295
|
) else (
|
|
238
|
-
|
|
239
|
-
|
|
296
|
+
echo [ERROR] FILE READ ERROR - Cannot read update_medicafe.py
|
|
297
|
+
echo [ERROR] File exists but is not accessible (permission/lock issue?)
|
|
240
298
|
)
|
|
299
|
+
) else (
|
|
300
|
+
echo [ERROR] update_medicafe.py NOT FOUND at F:\Medibot\update_medicafe.py
|
|
241
301
|
)
|
|
302
|
+
|
|
242
303
|
) else (
|
|
243
|
-
|
|
244
|
-
|
|
304
|
+
echo [ERROR] F:\Medibot directory does NOT exist
|
|
305
|
+
echo [DIAGNOSTIC] Attempting to create F:\Medibot...
|
|
306
|
+
mkdir "F:\Medibot" 2>nul
|
|
307
|
+
if exist "F:\Medibot" (
|
|
308
|
+
echo [OK] Successfully created F:\Medibot directory
|
|
309
|
+
) else (
|
|
310
|
+
echo [ERROR] FAILED to create F:\Medibot directory
|
|
311
|
+
echo [ERROR] Permission denied or F: drive is read-only
|
|
312
|
+
)
|
|
245
313
|
)
|
|
314
|
+
|
|
246
315
|
) else (
|
|
247
|
-
echo
|
|
316
|
+
echo [ERROR] F: drive is NOT accessible
|
|
317
|
+
echo [ERROR] F: drive may be:
|
|
318
|
+
echo - Disconnected network drive
|
|
319
|
+
echo - Unmounted USB/external drive
|
|
320
|
+
echo - Mapped drive that's no longer available
|
|
321
|
+
echo - Security policy blocking access
|
|
322
|
+
|
|
323
|
+
:: Check what drives are actually available
|
|
324
|
+
echo [DIAGNOSTIC] Available drives on this system:
|
|
325
|
+
wmic logicaldisk get size,freespace,caption 2>nul || echo [!] Cannot enumerate drives
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
echo.
|
|
329
|
+
echo ==========================================
|
|
330
|
+
echo END F: DRIVE DIAGNOSTICS
|
|
331
|
+
echo ==========================================
|
|
332
|
+
echo.
|
|
333
|
+
|
|
334
|
+
:: Continue with existing logic but with enhanced error reporting
|
|
335
|
+
:: First check if we already have it locally
|
|
336
|
+
if exist "%upgrade_medicafe_local%" (
|
|
337
|
+
echo Found update_medicafe.py in local directory. No action needed.
|
|
248
338
|
ping -n 2 127.0.0.1 >nul
|
|
249
|
-
|
|
250
|
-
|
|
339
|
+
) else if exist "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" (
|
|
340
|
+
echo Found update_medicafe.py in site-packages. Copying to local directory...
|
|
341
|
+
ping -n 2 127.0.0.1 >nul
|
|
342
|
+
:: Ensure MediBot directory exists
|
|
343
|
+
if not exist "MediBot" mkdir "MediBot"
|
|
344
|
+
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_local%" >nul 2>&1
|
|
345
|
+
if %errorlevel% neq 0 (
|
|
346
|
+
echo Copy to local directory failed. Error code: %errorlevel%
|
|
347
|
+
echo [DIAGNOSTIC] Attempting copy to F: drive (with detailed error reporting)...
|
|
251
348
|
ping -n 2 127.0.0.1 >nul
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
echo Update script not found at: !alt_update_path!
|
|
275
|
-
echo Continuing without update script...
|
|
276
|
-
ping -n 2 127.0.0.1 >nul
|
|
349
|
+
:: Ensure F:\Medibot directory exists (only if F: drive is accessible)
|
|
350
|
+
if exist "F:\" (
|
|
351
|
+
if not exist "F:\Medibot" (
|
|
352
|
+
echo [DIAGNOSTIC] Creating F:\Medibot directory...
|
|
353
|
+
mkdir "F:\Medibot" 2>nul
|
|
354
|
+
if not exist "F:\Medibot" (
|
|
355
|
+
echo [ERROR] Failed to create F:\Medibot - Permission denied or read-only drive
|
|
356
|
+
)
|
|
357
|
+
)
|
|
358
|
+
if exist "F:\Medibot" (
|
|
359
|
+
echo [DIAGNOSTIC] Attempting file copy to F:\Medibot...
|
|
360
|
+
copy "C:\Python34\Lib\site-packages\MediBot\update_medicafe.py" "%upgrade_medicafe_legacy%" 2>nul
|
|
361
|
+
if %errorlevel% neq 0 (
|
|
362
|
+
echo [ERROR] Copy to F:\Medibot failed with error code: %errorlevel%
|
|
363
|
+
echo [ERROR] Possible causes:
|
|
364
|
+
echo - Permission denied (insufficient write access)
|
|
365
|
+
echo - Disk full
|
|
366
|
+
echo - File locked by another process
|
|
367
|
+
echo - Antivirus blocking the operation
|
|
368
|
+
) else (
|
|
369
|
+
echo [SUCCESS] File copied to F:\Medibot successfully
|
|
370
|
+
)
|
|
277
371
|
)
|
|
278
372
|
) else (
|
|
279
|
-
echo
|
|
280
|
-
ping -n 2 127.0.0.1 >nul
|
|
373
|
+
echo [ERROR] F: drive not accessible - skipping F: drive copy attempt
|
|
281
374
|
)
|
|
375
|
+
) else (
|
|
376
|
+
echo File copied to local directory successfully.
|
|
377
|
+
ping -n 2 127.0.0.1 >nul
|
|
282
378
|
)
|
|
379
|
+
) else if exist "%upgrade_medicafe_legacy%" (
|
|
380
|
+
echo Found update_medicafe.py in legacy F: drive location.
|
|
381
|
+
echo [DIAGNOSTIC] Verifying F: drive file accessibility...
|
|
382
|
+
type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1
|
|
383
|
+
if %errorlevel% equ 0 (
|
|
384
|
+
echo [OK] F: drive file is accessible and readable
|
|
385
|
+
) else (
|
|
386
|
+
echo [ERROR] F: drive file exists but cannot be read (permission/lock issue)
|
|
387
|
+
)
|
|
388
|
+
ping -n 2 127.0.0.1 >nul
|
|
389
|
+
) else (
|
|
390
|
+
echo update_medicafe.py not detected in any known location.
|
|
391
|
+
echo.
|
|
392
|
+
echo Checked locations:
|
|
393
|
+
echo - Site-packages: C:\Python34\Lib\site-packages\MediBot\update_medicafe.py
|
|
394
|
+
echo - Local: %upgrade_medicafe_local%
|
|
395
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
|
396
|
+
echo.
|
|
397
|
+
echo [DIAGNOSTIC] Current working directory:
|
|
398
|
+
cd
|
|
399
|
+
echo [DIAGNOSTIC] Current directory contents:
|
|
400
|
+
dir /b
|
|
401
|
+
echo.
|
|
402
|
+
echo [DIAGNOSTIC] MediBot directory contents:
|
|
403
|
+
dir /b MediBot\ 2>nul || echo MediBot directory not found
|
|
404
|
+
echo.
|
|
405
|
+
echo Continuing without update script...
|
|
406
|
+
ping -n 2 127.0.0.1 >nul
|
|
407
|
+
)
|
|
283
408
|
)
|
|
284
409
|
|
|
285
410
|
:: Main menu
|
|
@@ -355,27 +480,27 @@ echo ========================================
|
|
|
355
480
|
echo DEBUG STEP 1: Checking for update script
|
|
356
481
|
echo ========================================
|
|
357
482
|
echo.
|
|
358
|
-
echo Checking
|
|
359
|
-
if exist "%
|
|
360
|
-
echo [SUCCESS] Found update script at: %
|
|
483
|
+
echo Checking for update script (priority: local first, then legacy path)...
|
|
484
|
+
if exist "%upgrade_medicafe_local%" (
|
|
485
|
+
echo [SUCCESS] Found update script at: %upgrade_medicafe_local%
|
|
486
|
+
echo File size:
|
|
487
|
+
dir "%upgrade_medicafe_local%" | find "update_medicafe.py"
|
|
488
|
+
set "upgrade_medicafe=%upgrade_medicafe_local%"
|
|
489
|
+
) else if exist "%upgrade_medicafe_legacy%" (
|
|
490
|
+
echo [SUCCESS] Found update script at legacy location: %upgrade_medicafe_legacy%
|
|
361
491
|
echo File size:
|
|
362
|
-
dir "%
|
|
492
|
+
dir "%upgrade_medicafe_legacy%" | find "update_medicafe.py"
|
|
493
|
+
set "upgrade_medicafe=%upgrade_medicafe_legacy%"
|
|
363
494
|
) else (
|
|
364
|
-
echo [FAILED] Update script not found
|
|
495
|
+
echo [FAILED] Update script not found in either location:
|
|
496
|
+
echo - Local: %upgrade_medicafe_local%
|
|
497
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
|
365
498
|
echo.
|
|
366
|
-
echo
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
) else (
|
|
372
|
-
echo [FAILED] Update script not found at: MediBot\update_medicafe.py
|
|
373
|
-
echo.
|
|
374
|
-
echo Available files in current directory:
|
|
375
|
-
dir /b
|
|
376
|
-
echo.
|
|
377
|
-
echo Available files in MediBot directory:
|
|
378
|
-
dir /b MediBot\ 2>nul || echo MediBot directory not found
|
|
499
|
+
echo Available files in current directory:
|
|
500
|
+
dir /b
|
|
501
|
+
echo.
|
|
502
|
+
echo Available files in MediBot directory:
|
|
503
|
+
dir /b MediBot\ 2>nul || echo MediBot directory not found
|
|
379
504
|
)
|
|
380
505
|
)
|
|
381
506
|
echo.
|
|
@@ -477,48 +602,79 @@ echo.
|
|
|
477
602
|
echo Starting update process...
|
|
478
603
|
echo.
|
|
479
604
|
|
|
480
|
-
:: Check if update_medicafe.py exists
|
|
481
|
-
if exist "%
|
|
482
|
-
echo [INFO] Using update script at: %
|
|
483
|
-
echo Command: python "%
|
|
605
|
+
:: Check if update_medicafe.py exists using the new priority system
|
|
606
|
+
if exist "%upgrade_medicafe_local%" (
|
|
607
|
+
echo [INFO] Using local update script at: %upgrade_medicafe_local%
|
|
608
|
+
echo Command: python "%upgrade_medicafe_local%" %package_version%
|
|
609
|
+
|
|
610
|
+
:: Pre-execution diagnostics
|
|
611
|
+
echo.
|
|
612
|
+
echo [DIAGNOSTIC] Pre-execution checks for local script:
|
|
613
|
+
echo [DIAGNOSTIC] File size and permissions:
|
|
614
|
+
dir "%upgrade_medicafe_local%" 2>nul || echo [!] Cannot read file details
|
|
615
|
+
echo [DIAGNOSTIC] Testing Python access to file:
|
|
616
|
+
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
|
|
617
|
+
|
|
484
618
|
echo.
|
|
485
619
|
echo Press Enter to execute update command...
|
|
486
620
|
pause >nul
|
|
487
621
|
echo.
|
|
488
622
|
echo Executing update command...
|
|
489
|
-
|
|
490
|
-
|
|
623
|
+
echo.
|
|
624
|
+
echo The update window will open and show detailed progress.
|
|
625
|
+
echo All output will be displayed on screen.
|
|
626
|
+
echo.
|
|
627
|
+
start "Medicafe Update" cmd /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_local%\" %package_version% & echo. & python \"%upgrade_medicafe_local%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: %ERRORLEVEL% & echo Update process completed. Press any key to close... & pause >nul" && (
|
|
628
|
+
echo %DATE% %TIME% Upgrade initiated successfully (local). >> "%temp_file%"
|
|
491
629
|
echo [SUCCESS] Update process started successfully
|
|
492
630
|
echo All output will be displayed in the update window.
|
|
493
631
|
) || (
|
|
494
|
-
echo %DATE% %TIME% Update failed. >> "%temp_file%"
|
|
632
|
+
echo %DATE% %TIME% Update failed (local). >> "%temp_file%"
|
|
495
633
|
echo [ERROR] Upgrade failed. Check the update window for details.
|
|
634
|
+
echo [DIAGNOSTIC] Possible causes for local script failure:
|
|
635
|
+
echo - Python not in PATH
|
|
636
|
+
echo - Script syntax error
|
|
637
|
+
echo - Missing Python dependencies
|
|
638
|
+
echo - File corruption
|
|
496
639
|
)
|
|
497
|
-
) else if exist "
|
|
498
|
-
echo [INFO] Using update script at:
|
|
499
|
-
echo Command: python "
|
|
640
|
+
) else if exist "%upgrade_medicafe_legacy%" (
|
|
641
|
+
echo [INFO] Using legacy update script at: %upgrade_medicafe_legacy%
|
|
642
|
+
echo Command: python "%upgrade_medicafe_legacy%" %package_version%
|
|
643
|
+
|
|
644
|
+
:: Pre-execution diagnostics for F: drive
|
|
645
|
+
echo.
|
|
646
|
+
echo [DIAGNOSTIC] Pre-execution checks for F: drive script:
|
|
647
|
+
echo [DIAGNOSTIC] File size and permissions:
|
|
648
|
+
dir "%upgrade_medicafe_legacy%" 2>nul || echo [!] Cannot read file details
|
|
649
|
+
echo [DIAGNOSTIC] Testing Python access to F: drive file:
|
|
650
|
+
python -c "import os; print('[OK] Python can access F: drive file') if os.path.exists('%upgrade_medicafe_legacy%') else print('[ERROR] Python cannot access F: drive file')" 2>nul || echo [!] Python F: drive test failed
|
|
651
|
+
echo [DIAGNOSTIC] Testing file read permissions:
|
|
652
|
+
type "%upgrade_medicafe_legacy%" | find "#update_medicafe.py" >nul 2>&1 && echo [OK] File content readable || echo [ERROR] Cannot read file content
|
|
653
|
+
|
|
500
654
|
echo.
|
|
501
655
|
echo Press Enter to execute update command...
|
|
502
656
|
pause >nul
|
|
503
657
|
echo.
|
|
504
658
|
echo Executing update command...
|
|
505
|
-
echo.
|
|
506
|
-
|
|
507
|
-
echo All output will be displayed on screen.
|
|
508
|
-
echo.
|
|
509
|
-
start "Medicafe Update" cmd /c "python \"MediBot\update_medicafe.py\" %package_version% & echo. & echo Update process completed. Press any key to close... & pause >nul" && (
|
|
510
|
-
echo %DATE% %TIME% Upgrade initiated successfully. >> "%temp_file%"
|
|
659
|
+
start "Medicafe Update" cmd /c "echo [DIAGNOSTIC] About to execute: python \"%upgrade_medicafe_legacy%\" %package_version% & echo [DIAGNOSTIC] F: drive accessibility test... & dir F:\ ^| find \"Directory of\" ^>nul 2^>^&1 ^&^& echo [OK] F: drive accessible ^|^| echo [ERROR] F: drive access lost & echo. & python \"%upgrade_medicafe_legacy%\" %package_version% & echo. & echo [DIAGNOSTIC] Python exit code: %ERRORLEVEL% & echo Update process completed. Press any key to close... & pause >nul" && (
|
|
660
|
+
echo %DATE% %TIME% Upgrade initiated successfully (legacy). >> "%temp_file%"
|
|
511
661
|
echo [SUCCESS] Update process started successfully
|
|
512
662
|
echo All output will be displayed in the update window.
|
|
513
663
|
) || (
|
|
514
|
-
echo %DATE% %TIME% Update failed. >> "%temp_file%"
|
|
664
|
+
echo %DATE% %TIME% Update failed (legacy). >> "%temp_file%"
|
|
515
665
|
echo [ERROR] Upgrade failed. Check the update window for details.
|
|
666
|
+
echo [DIAGNOSTIC] Possible causes for F: drive script failure:
|
|
667
|
+
echo - F: drive disconnected during execution
|
|
668
|
+
echo - Permission denied accessing F: drive
|
|
669
|
+
echo - F: drive file locked by antivirus
|
|
670
|
+
echo - Network drive timeout
|
|
671
|
+
echo - Python cannot access network paths
|
|
516
672
|
)
|
|
517
673
|
) else (
|
|
518
674
|
echo [ERROR] update_medicafe.py not found in either location
|
|
519
675
|
echo Expected locations:
|
|
520
|
-
echo - %
|
|
521
|
-
echo -
|
|
676
|
+
echo - Local: %upgrade_medicafe_local%
|
|
677
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
|
522
678
|
echo.
|
|
523
679
|
echo Current directory contents:
|
|
524
680
|
dir /b
|
|
@@ -728,18 +884,39 @@ echo Clearing Python cache for MediCafe...
|
|
|
728
884
|
echo.
|
|
729
885
|
cd /d "%~dp0.."
|
|
730
886
|
|
|
731
|
-
:: Check if update_medicafe.py exists
|
|
732
|
-
if exist "
|
|
733
|
-
echo Found update_medicafe.py in
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
887
|
+
:: Check if update_medicafe.py exists using priority system (local first)
|
|
888
|
+
if exist "%upgrade_medicafe_local%" (
|
|
889
|
+
echo Found update_medicafe.py in local location - using relative path
|
|
890
|
+
echo [DIAGNOSTIC] Cache clearing with local script:
|
|
891
|
+
echo [DIAGNOSTIC] Command: python "%upgrade_medicafe_local%" --clear-cache
|
|
892
|
+
python "%upgrade_medicafe_local%" --clear-cache
|
|
893
|
+
if %errorlevel% neq 0 (
|
|
894
|
+
echo [ERROR] Cache clearing failed with local script, error code: %errorlevel%
|
|
895
|
+
echo [DIAGNOSTIC] Possible causes:
|
|
896
|
+
echo - Python not in PATH
|
|
897
|
+
echo - Script syntax error
|
|
898
|
+
echo - Missing dependencies
|
|
899
|
+
)
|
|
900
|
+
) else if exist "%upgrade_medicafe_legacy%" (
|
|
901
|
+
echo Found update_medicafe.py in legacy location - using F: drive path
|
|
902
|
+
echo [DIAGNOSTIC] Cache clearing with F: drive script:
|
|
903
|
+
echo [DIAGNOSTIC] Command: python "%upgrade_medicafe_legacy%" --clear-cache
|
|
904
|
+
echo [DIAGNOSTIC] Testing F: drive access before execution:
|
|
905
|
+
dir "F:\Medibot" >nul 2>&1 && echo [OK] F: drive accessible || echo [ERROR] F: drive access issue
|
|
906
|
+
python "%upgrade_medicafe_legacy%" --clear-cache
|
|
907
|
+
if %errorlevel% neq 0 (
|
|
908
|
+
echo [ERROR] Cache clearing failed with F: drive script, error code: %errorlevel%
|
|
909
|
+
echo [DIAGNOSTIC] Possible causes:
|
|
910
|
+
echo - F: drive disconnected during execution
|
|
911
|
+
echo - Permission denied accessing F: drive file
|
|
912
|
+
echo - F: drive file locked
|
|
913
|
+
echo - Python cannot access network paths
|
|
914
|
+
)
|
|
738
915
|
) else (
|
|
739
916
|
echo ERROR: update_medicafe.py not found in either location
|
|
740
917
|
echo Expected locations:
|
|
741
|
-
echo -
|
|
742
|
-
echo -
|
|
918
|
+
echo - Local: %upgrade_medicafe_local%
|
|
919
|
+
echo - Legacy: %upgrade_medicafe_legacy%
|
|
743
920
|
pause
|
|
744
921
|
goto main_menu
|
|
745
922
|
)
|
|
@@ -462,7 +462,7 @@ if __name__ == "__main__":
|
|
|
462
462
|
|
|
463
463
|
if existing_patients:
|
|
464
464
|
print("\nNOTE: The following patient(s) already EXIST in the system and \n will be excluded from processing:")
|
|
465
|
-
|
|
465
|
+
# BUG There a "ERROR: 'str' object has no attribute 'strftime'" that shows up after this somewhere.
|
|
466
466
|
# Collect surgery dates and patient info for existing patients
|
|
467
467
|
patient_info = []
|
|
468
468
|
for patient_id, patient_name in existing_patients:
|
|
@@ -256,14 +256,33 @@ def crosswalk_update(client, config, crosswalk): # Upstream of this is only Medi
|
|
|
256
256
|
api_cache = {}
|
|
257
257
|
|
|
258
258
|
# Load insurance data from MAINS (optional - continue if not available)
|
|
259
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
259
260
|
insurance_name_to_id = {}
|
|
260
261
|
try:
|
|
261
262
|
MediLink_ConfigLoader.log("Attempting to load insurance data from MAINS...", config, level="DEBUG")
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
|
|
264
|
+
if MediBot_Preprocessor_lib and hasattr(MediBot_Preprocessor_lib, 'load_insurance_data_from_mains'):
|
|
265
|
+
insurance_name_to_id = MediBot_Preprocessor_lib.load_insurance_data_from_mains(config)
|
|
266
|
+
if insurance_name_to_id:
|
|
267
|
+
MediLink_ConfigLoader.log("Loaded insurance data from MAINS with {} entries.".format(len(insurance_name_to_id)), config, level="INFO")
|
|
268
|
+
else:
|
|
269
|
+
MediLink_ConfigLoader.log("load_insurance_data_from_mains returned empty data", config, level="WARNING")
|
|
270
|
+
else:
|
|
271
|
+
error_msg = "MediBot_Preprocessor_lib or load_insurance_data_from_mains not available"
|
|
272
|
+
MediLink_ConfigLoader.log(error_msg, config, level="WARNING")
|
|
273
|
+
print("Warning: {}".format(error_msg))
|
|
274
|
+
|
|
275
|
+
except AttributeError as e:
|
|
276
|
+
error_msg = "AttributeError accessing load_insurance_data_from_mains: {}".format(str(e))
|
|
277
|
+
MediLink_ConfigLoader.log(error_msg, config, level="WARNING")
|
|
278
|
+
print("Warning: {}. Some crosswalk features may be limited.".format(error_msg))
|
|
279
|
+
except ImportError as e:
|
|
280
|
+
error_msg = "ImportError with MediBot_Preprocessor_lib: {}".format(str(e))
|
|
281
|
+
MediLink_ConfigLoader.log(error_msg, config, level="WARNING")
|
|
282
|
+
print("Warning: {}. Some crosswalk features may be limited.".format(error_msg))
|
|
264
283
|
except Exception as e:
|
|
265
284
|
MediLink_ConfigLoader.log("Error loading insurance data from MAINS: {}. Continuing without MAINS data.".format(e), config, level="WARNING")
|
|
266
|
-
print("Warning: MAINS data not available. Some crosswalk features may be limited.")
|
|
285
|
+
print("Warning: MAINS data not available ({}). Some crosswalk features may be limited.".format(str(e)))
|
|
267
286
|
# Continue without MAINS data - don't return False
|
|
268
287
|
|
|
269
288
|
# Load historical payer to patient mappings (optional - continue if not available)
|
|
@@ -459,13 +459,32 @@ def update_crosswalk_with_new_payer_id(client, insurance_name, payer_id, config,
|
|
|
459
459
|
return False
|
|
460
460
|
|
|
461
461
|
# Load the Medisoft ID for the given insurance name
|
|
462
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
462
463
|
try:
|
|
463
464
|
# Note: MediBot_Preprocessor_lib is imported at module level
|
|
464
|
-
|
|
465
|
+
if MediBot_Preprocessor_lib and hasattr(MediBot_Preprocessor_lib, 'load_insurance_data_from_mains'):
|
|
466
|
+
insurance_data = MediBot_Preprocessor_lib.load_insurance_data_from_mains(config)
|
|
467
|
+
medisoft_id = insurance_data.get(insurance_name) if insurance_data else None
|
|
468
|
+
MediLink_ConfigLoader.log("Successfully retrieved insurance data for {}".format(insurance_name), config, level="DEBUG")
|
|
469
|
+
else:
|
|
470
|
+
error_msg = "MediBot_Preprocessor_lib or load_insurance_data_from_mains not available"
|
|
471
|
+
MediLink_ConfigLoader.log(error_msg, config, level="WARNING")
|
|
472
|
+
print("Warning: {}".format(error_msg))
|
|
473
|
+
medisoft_id = None
|
|
474
|
+
except AttributeError as e:
|
|
475
|
+
error_msg = "AttributeError accessing load_insurance_data_from_mains: {}".format(str(e))
|
|
476
|
+
MediLink_ConfigLoader.log(error_msg, config, level="WARNING")
|
|
477
|
+
print("Warning: {}".format(error_msg))
|
|
478
|
+
medisoft_id = None
|
|
465
479
|
except KeyError as e: # Handle KeyError for config
|
|
466
480
|
MediLink_ConfigLoader.log("KeyError while loading Medisoft ID: {}".format(e), config, level="ERROR")
|
|
467
481
|
print("KeyError while loading Medisoft ID for insurance name {}: {}".format(insurance_name, e))
|
|
468
482
|
return False
|
|
483
|
+
except Exception as e:
|
|
484
|
+
error_msg = "Unexpected error loading insurance data: {}".format(str(e))
|
|
485
|
+
MediLink_ConfigLoader.log(error_msg, config, level="ERROR")
|
|
486
|
+
print("Error: {}".format(error_msg))
|
|
487
|
+
medisoft_id = None
|
|
469
488
|
|
|
470
489
|
MediLink_ConfigLoader.log("Retrieved Medisoft ID for insurance name {}: {}.".format(insurance_name, medisoft_id), config, level="DEBUG")
|
|
471
490
|
|
|
@@ -66,6 +66,56 @@ try:
|
|
|
66
66
|
except ImportError:
|
|
67
67
|
# Fallback to local flag if centralized config is not available
|
|
68
68
|
PERFORMANCE_LOGGING = False
|
|
69
|
+
|
|
70
|
+
# XP Compatibility: Add robust fallback for configuration loading
|
|
71
|
+
def get_cached_configuration_xp_safe():
|
|
72
|
+
"""
|
|
73
|
+
XP-compatible version of get_cached_configuration with robust fallbacks.
|
|
74
|
+
"""
|
|
75
|
+
global _config_cache, _crosswalk_cache
|
|
76
|
+
|
|
77
|
+
# If we already have cached data, return it
|
|
78
|
+
if _config_cache is not None and _crosswalk_cache is not None:
|
|
79
|
+
return _config_cache, _crosswalk_cache
|
|
80
|
+
|
|
81
|
+
# Try to load configuration using the standard method
|
|
82
|
+
try:
|
|
83
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'load_configuration'):
|
|
84
|
+
_config_cache, _crosswalk_cache = MediLink_ConfigLoader.load_configuration()
|
|
85
|
+
return _config_cache, _crosswalk_cache
|
|
86
|
+
except Exception as e:
|
|
87
|
+
print("Warning: Failed to load configuration via MediLink_ConfigLoader: {}".format(e))
|
|
88
|
+
|
|
89
|
+
# Fallback: Try to load configuration files directly
|
|
90
|
+
try:
|
|
91
|
+
import json
|
|
92
|
+
project_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
93
|
+
|
|
94
|
+
# Try to load config.json
|
|
95
|
+
config_path = os.path.join(project_dir, 'json', 'config.json')
|
|
96
|
+
if os.path.exists(config_path):
|
|
97
|
+
with open(config_path, 'r') as f:
|
|
98
|
+
_config_cache = json.load(f)
|
|
99
|
+
else:
|
|
100
|
+
_config_cache = {}
|
|
101
|
+
|
|
102
|
+
# Try to load crosswalk.json
|
|
103
|
+
crosswalk_path = os.path.join(project_dir, 'json', 'crosswalk.json')
|
|
104
|
+
if os.path.exists(crosswalk_path):
|
|
105
|
+
with open(crosswalk_path, 'r') as f:
|
|
106
|
+
_crosswalk_cache = json.load(f)
|
|
107
|
+
else:
|
|
108
|
+
_crosswalk_cache = {}
|
|
109
|
+
|
|
110
|
+
return _config_cache, _crosswalk_cache
|
|
111
|
+
|
|
112
|
+
except Exception as e:
|
|
113
|
+
print("Warning: Failed to load configuration files directly: {}".format(e))
|
|
114
|
+
# Return empty defaults
|
|
115
|
+
_config_cache = {}
|
|
116
|
+
_crosswalk_cache = {}
|
|
117
|
+
return _config_cache, _crosswalk_cache
|
|
118
|
+
|
|
69
119
|
class InitializationError(Exception):
|
|
70
120
|
def __init__(self, message):
|
|
71
121
|
self.message = message
|
|
@@ -91,12 +141,7 @@ def get_cached_configuration():
|
|
|
91
141
|
"""
|
|
92
142
|
Returns cached configuration and crosswalk data to avoid repeated I/O operations.
|
|
93
143
|
"""
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if _config_cache is None or _crosswalk_cache is None:
|
|
97
|
-
_config_cache, _crosswalk_cache = MediLink_ConfigLoader.load_configuration()
|
|
98
|
-
|
|
99
|
-
return _config_cache, _crosswalk_cache
|
|
144
|
+
return get_cached_configuration_xp_safe()
|
|
100
145
|
|
|
101
146
|
def open_csv_for_editing(csv_file_path):
|
|
102
147
|
try:
|
|
@@ -1134,7 +1179,17 @@ def load_insurance_data_from_mains(config):
|
|
|
1134
1179
|
dict: A dictionary mapping insurance names to insurance IDs.
|
|
1135
1180
|
"""
|
|
1136
1181
|
# Use cached configuration to avoid repeated loading
|
|
1137
|
-
|
|
1182
|
+
try:
|
|
1183
|
+
config, crosswalk = get_cached_configuration()
|
|
1184
|
+
except Exception as e:
|
|
1185
|
+
print("Warning: Failed to load cached configuration: {}".format(e))
|
|
1186
|
+
# Return empty mapping if configuration loading fails
|
|
1187
|
+
return {}
|
|
1188
|
+
|
|
1189
|
+
# XP Compatibility: Check if MediLink_DataMgmt is available
|
|
1190
|
+
if MediLink_DataMgmt is None:
|
|
1191
|
+
print("Warning: MediLink_DataMgmt not available. Cannot load MAINS data.")
|
|
1192
|
+
return {}
|
|
1138
1193
|
|
|
1139
1194
|
# Retrieve MAINS path and slicing information from the configuration
|
|
1140
1195
|
# TODO (Low) For secondary insurance, this needs to be pulling from the correct MAINS (there are 2)
|
|
@@ -1142,8 +1197,12 @@ def load_insurance_data_from_mains(config):
|
|
|
1142
1197
|
# Meh, this just has to be part of the new architecture plan where we make Medisoft a downstream
|
|
1143
1198
|
# recipient from the db.
|
|
1144
1199
|
# TODO (High) The Medisoft Medicare flag needs to be brought in here.
|
|
1145
|
-
|
|
1146
|
-
|
|
1200
|
+
try:
|
|
1201
|
+
mains_path = config.get('MAINS_MED_PATH', '')
|
|
1202
|
+
mains_slices = crosswalk.get('mains_mapping', {}).get('slices', {})
|
|
1203
|
+
except (KeyError, AttributeError) as e:
|
|
1204
|
+
print("Warning: Failed to get MAINS configuration: {}".format(e))
|
|
1205
|
+
return {}
|
|
1147
1206
|
|
|
1148
1207
|
# Initialize the dictionary to hold the insurance to insurance ID mappings
|
|
1149
1208
|
insurance_to_id = {}
|
|
@@ -1152,7 +1211,8 @@ def load_insurance_data_from_mains(config):
|
|
|
1152
1211
|
# Check if MAINS file exists before attempting to read
|
|
1153
1212
|
if not os.path.exists(mains_path):
|
|
1154
1213
|
error_msg = "CRITICAL: MAINS file not found at: {}. This file is required for insurance name to Medisoft ID mapping.".format(mains_path)
|
|
1155
|
-
MediLink_ConfigLoader
|
|
1214
|
+
if hasattr(MediLink_ConfigLoader, 'log'):
|
|
1215
|
+
MediLink_ConfigLoader.log(error_msg, level="CRITICAL")
|
|
1156
1216
|
print("\n" + "="*80)
|
|
1157
1217
|
print("CRITICAL ERROR: MAINS FILE MISSING")
|
|
1158
1218
|
print("="*80)
|
|
@@ -1171,17 +1231,26 @@ def load_insurance_data_from_mains(config):
|
|
|
1171
1231
|
print("="*80)
|
|
1172
1232
|
return insurance_to_id
|
|
1173
1233
|
|
|
1234
|
+
# XP Compatibility: Check if MediLink_DataMgmt has the required function
|
|
1235
|
+
if not hasattr(MediLink_DataMgmt, 'read_general_fixed_width_data'):
|
|
1236
|
+
print("Warning: MediLink_DataMgmt.read_general_fixed_width_data not available. Cannot load MAINS data.")
|
|
1237
|
+
return insurance_to_id
|
|
1238
|
+
|
|
1174
1239
|
# Read data from MAINS using a provided function to handle fixed-width data
|
|
1175
1240
|
for record, line_number in MediLink_DataMgmt.read_general_fixed_width_data(mains_path, mains_slices):
|
|
1176
1241
|
insurance_name = record['MAINSNAME']
|
|
1177
1242
|
# Assuming line_number gives the correct insurance ID without needing adjustment
|
|
1178
1243
|
insurance_to_id[insurance_name] = line_number
|
|
1179
1244
|
|
|
1180
|
-
|
|
1245
|
+
if hasattr(MediLink_ConfigLoader, 'log'):
|
|
1246
|
+
MediLink_ConfigLoader.log("Successfully loaded {} insurance records from MAINS".format(len(insurance_to_id)), level="INFO")
|
|
1247
|
+
else:
|
|
1248
|
+
print("Successfully loaded {} insurance records from MAINS".format(len(insurance_to_id)))
|
|
1181
1249
|
|
|
1182
1250
|
except FileNotFoundError:
|
|
1183
1251
|
error_msg = "CRITICAL: MAINS file not found: {}. This file is required for insurance name to Medisoft ID mapping.".format(mains_path)
|
|
1184
|
-
MediLink_ConfigLoader
|
|
1252
|
+
if hasattr(MediLink_ConfigLoader, 'log'):
|
|
1253
|
+
MediLink_ConfigLoader.log(error_msg, level="CRITICAL")
|
|
1185
1254
|
print("\n" + "="*80)
|
|
1186
1255
|
print("CRITICAL ERROR: MAINS FILE MISSING")
|
|
1187
1256
|
print("="*80)
|
|
@@ -1199,7 +1268,9 @@ def load_insurance_data_from_mains(config):
|
|
|
1199
1268
|
print("3. The file should contain insurance company data from your Medisoft system")
|
|
1200
1269
|
print("="*80)
|
|
1201
1270
|
except Exception as e:
|
|
1202
|
-
|
|
1271
|
+
error_msg = "Error loading MAINS data: {}. Continuing without MAINS data.".format(str(e))
|
|
1272
|
+
if hasattr(MediLink_ConfigLoader, 'log'):
|
|
1273
|
+
MediLink_ConfigLoader.log(error_msg, level="ERROR")
|
|
1203
1274
|
print("Error loading MAINS data: {}. Continuing without MAINS data.".format(str(e)))
|
|
1204
1275
|
|
|
1205
1276
|
return insurance_to_id
|
|
@@ -138,24 +138,59 @@ class APIClient(BaseAPIClient):
|
|
|
138
138
|
super().__init__(config)
|
|
139
139
|
|
|
140
140
|
# Add enhanced features if available
|
|
141
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
141
142
|
try:
|
|
142
143
|
from MediCafe.api_utils import APICircuitBreaker, APICache, APIRateLimiter
|
|
144
|
+
MediLink_ConfigLoader.log("Successfully imported MediCafe.api_utils", level="DEBUG")
|
|
145
|
+
except ImportError as e:
|
|
146
|
+
MediLink_ConfigLoader.log("Warning: MediCafe.api_utils not available: {}".format(str(e)), level="WARNING")
|
|
147
|
+
print("Warning: MediCafe.api_utils import failed: {}".format(str(e)))
|
|
148
|
+
APICircuitBreaker = None
|
|
149
|
+
APICache = None
|
|
150
|
+
APIRateLimiter = None
|
|
151
|
+
except Exception as e:
|
|
152
|
+
MediLink_ConfigLoader.log("Unexpected error importing MediCafe.api_utils: {}".format(str(e)), level="ERROR")
|
|
153
|
+
print("Error: Unexpected MediCafe.api_utils import error: {}".format(str(e)))
|
|
154
|
+
APICircuitBreaker = None
|
|
155
|
+
APICache = None
|
|
156
|
+
APIRateLimiter = None
|
|
157
|
+
|
|
158
|
+
try:
|
|
143
159
|
from MediLink.MediLink_insurance_utils import get_feature_flag
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
MediLink_ConfigLoader.log("Successfully imported MediLink.MediLink_insurance_utils", level="DEBUG")
|
|
161
|
+
except ImportError as e:
|
|
162
|
+
MediLink_ConfigLoader.log("Warning: MediLink.MediLink_insurance_utils not available: {}".format(str(e)), level="WARNING")
|
|
163
|
+
print("Warning: MediLink.MediLink_insurance_utils import failed: {}".format(str(e)))
|
|
164
|
+
# Provide fallback function
|
|
165
|
+
def get_feature_flag(flag_name, default=False):
|
|
166
|
+
MediLink_ConfigLoader.log("Using fallback get_feature_flag for '{}', returning default: {}".format(flag_name, default), level="DEBUG")
|
|
167
|
+
return default
|
|
168
|
+
except Exception as e:
|
|
169
|
+
MediLink_ConfigLoader.log("Unexpected error importing MediLink.MediLink_insurance_utils: {}".format(str(e)), level="ERROR")
|
|
170
|
+
print("Error: Unexpected MediLink.MediLink_insurance_utils import error: {}".format(str(e)))
|
|
171
|
+
# Provide fallback function
|
|
172
|
+
def get_feature_flag(flag_name, default=False):
|
|
173
|
+
MediLink_ConfigLoader.log("Using fallback get_feature_flag for '{}', returning default: {}".format(flag_name, default), level="DEBUG")
|
|
174
|
+
return default
|
|
175
|
+
|
|
176
|
+
# Initialize enhancements with error handling
|
|
177
|
+
try:
|
|
146
178
|
enable_circuit_breaker = get_feature_flag('api_circuit_breaker', default=False)
|
|
147
179
|
enable_caching = get_feature_flag('api_caching', default=False)
|
|
148
180
|
enable_rate_limiting = get_feature_flag('api_rate_limiting', default=False)
|
|
149
181
|
|
|
150
|
-
self.circuit_breaker = APICircuitBreaker() if enable_circuit_breaker else None
|
|
151
|
-
self.api_cache = APICache() if enable_caching else None
|
|
152
|
-
self.rate_limiter = APIRateLimiter() if enable_rate_limiting else None
|
|
182
|
+
self.circuit_breaker = APICircuitBreaker() if (enable_circuit_breaker and APICircuitBreaker) else None
|
|
183
|
+
self.api_cache = APICache() if (enable_caching and APICache) else None
|
|
184
|
+
self.rate_limiter = APIRateLimiter() if (enable_rate_limiting and APIRateLimiter) else None
|
|
153
185
|
|
|
154
186
|
if any([enable_circuit_breaker, enable_caching, enable_rate_limiting]):
|
|
155
187
|
MediLink_ConfigLoader.log("Enhanced API client initialized with circuit_breaker={}, caching={}, rate_limiting={}".format(
|
|
156
188
|
enable_circuit_breaker, enable_caching, enable_rate_limiting), level="INFO")
|
|
157
|
-
|
|
158
|
-
|
|
189
|
+
else:
|
|
190
|
+
MediLink_ConfigLoader.log("API enhancements disabled or not available, using standard client", level="DEBUG")
|
|
191
|
+
except Exception as e:
|
|
192
|
+
MediLink_ConfigLoader.log("Error initializing API enhancements: {}. Using standard client.".format(str(e)), level="WARNING")
|
|
193
|
+
print("Warning: API enhancement initialization failed: {}".format(str(e)))
|
|
159
194
|
self.circuit_breaker = None
|
|
160
195
|
self.api_cache = None
|
|
161
196
|
self.rate_limiter = None
|
|
@@ -181,7 +181,23 @@ class APIClientFactory:
|
|
|
181
181
|
|
|
182
182
|
return client
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
# XP/Python34 Compatibility: Wrap circuit breaker call with error handling
|
|
185
|
+
try:
|
|
186
|
+
if self.circuit_breaker and hasattr(self.circuit_breaker, 'call'):
|
|
187
|
+
return self.circuit_breaker.call(create_client)
|
|
188
|
+
else:
|
|
189
|
+
MediLink_ConfigLoader.log("Circuit breaker not available, calling create_client directly", level="WARNING")
|
|
190
|
+
return create_client()
|
|
191
|
+
except Exception as e:
|
|
192
|
+
MediLink_ConfigLoader.log("Circuit breaker call failed: {}. Falling back to direct client creation.".format(str(e)), level="WARNING")
|
|
193
|
+
print("Warning: Circuit breaker error ({}), using fallback client creation".format(str(e)))
|
|
194
|
+
try:
|
|
195
|
+
return create_client()
|
|
196
|
+
except Exception as e2:
|
|
197
|
+
MediLink_ConfigLoader.log("Direct client creation also failed: {}".format(str(e2)), level="ERROR")
|
|
198
|
+
print("Error: Both circuit breaker and direct client creation failed: {}".format(str(e2)))
|
|
199
|
+
# Return a minimal fallback client
|
|
200
|
+
return ProductionAPIClient()
|
|
185
201
|
|
|
186
202
|
@classmethod
|
|
187
203
|
def get_shared_client(cls, **kwargs):
|
|
@@ -13,15 +13,42 @@ if project_dir not in sys.path:
|
|
|
13
13
|
sys.path.append(project_dir)
|
|
14
14
|
|
|
15
15
|
# Import MediBot modules conditionally to avoid circular imports
|
|
16
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
16
17
|
MediBot_Preprocessor_lib = None
|
|
17
18
|
load_insurance_data_from_mains = None
|
|
18
19
|
|
|
19
20
|
try:
|
|
20
21
|
from MediBot import MediBot_Preprocessor_lib
|
|
22
|
+
MediLink_ConfigLoader.log("Successfully imported MediBot_Preprocessor_lib", level="DEBUG")
|
|
23
|
+
|
|
21
24
|
if hasattr(MediBot_Preprocessor_lib, 'load_insurance_data_from_mains'):
|
|
22
25
|
load_insurance_data_from_mains = MediBot_Preprocessor_lib.load_insurance_data_from_mains
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
MediLink_ConfigLoader.log("Successfully accessed load_insurance_data_from_mains function", level="DEBUG")
|
|
27
|
+
else:
|
|
28
|
+
MediLink_ConfigLoader.log("Warning: MediBot_Preprocessor_lib found but load_insurance_data_from_mains attribute missing", level="WARNING")
|
|
29
|
+
print("Warning: MediBot_Preprocessor_lib missing load_insurance_data_from_mains attribute")
|
|
30
|
+
except ImportError as e:
|
|
31
|
+
MediLink_ConfigLoader.log("ImportError accessing MediBot_Preprocessor_lib: {}".format(str(e)), level="WARNING")
|
|
32
|
+
print("Warning: Cannot import MediBot_Preprocessor_lib: {}".format(str(e)))
|
|
33
|
+
except AttributeError as e:
|
|
34
|
+
MediLink_ConfigLoader.log("AttributeError accessing load_insurance_data_from_mains: {}".format(str(e)), level="WARNING")
|
|
35
|
+
print("Warning: AttributeError with load_insurance_data_from_mains: {}".format(str(e)))
|
|
36
|
+
except Exception as e:
|
|
37
|
+
MediLink_ConfigLoader.log("Unexpected error accessing MediBot_Preprocessor_lib: {}".format(str(e)), level="ERROR")
|
|
38
|
+
print("Error: Unexpected error with MediBot_Preprocessor_lib: {}".format(str(e)))
|
|
39
|
+
|
|
40
|
+
# XP Compatibility: Add fallback function if import fails
|
|
41
|
+
if load_insurance_data_from_mains is None:
|
|
42
|
+
def load_insurance_data_from_mains_fallback(config):
|
|
43
|
+
"""
|
|
44
|
+
Fallback function for load_insurance_data_from_mains when MediBot_Preprocessor_lib is not available.
|
|
45
|
+
Returns empty dictionary to prevent AttributeError.
|
|
46
|
+
"""
|
|
47
|
+
MediLink_ConfigLoader.log("Using fallback load_insurance_data_from_mains function", level="WARNING")
|
|
48
|
+
print("Warning: load_insurance_data_from_mains not available. Using empty insurance mapping.")
|
|
49
|
+
return {}
|
|
50
|
+
|
|
51
|
+
load_insurance_data_from_mains = load_insurance_data_from_mains_fallback
|
|
25
52
|
|
|
26
53
|
try:
|
|
27
54
|
from MediBot import MediBot_Crosswalk_Library
|
|
@@ -71,9 +98,17 @@ except ImportError:
|
|
|
71
98
|
update_crosswalk_with_new_payer_id = None
|
|
72
99
|
|
|
73
100
|
# Import enhanced insurance selection with fallback
|
|
101
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
74
102
|
try:
|
|
75
103
|
from MediLink_insurance_utils import safe_insurance_type_selection
|
|
76
|
-
|
|
104
|
+
MediLink_ConfigLoader.log("Successfully imported safe_insurance_type_selection from MediLink_insurance_utils", level="DEBUG")
|
|
105
|
+
except ImportError as e:
|
|
106
|
+
MediLink_ConfigLoader.log("ImportError importing safe_insurance_type_selection: {}".format(str(e)), level="WARNING")
|
|
107
|
+
print("Warning: safe_insurance_type_selection not available: {}".format(str(e)))
|
|
108
|
+
safe_insurance_type_selection = None
|
|
109
|
+
except Exception as e:
|
|
110
|
+
MediLink_ConfigLoader.log("Unexpected error importing safe_insurance_type_selection: {}".format(str(e)), level="ERROR")
|
|
111
|
+
print("Error: Unexpected error importing safe_insurance_type_selection: {}".format(str(e)))
|
|
77
112
|
safe_insurance_type_selection = None
|
|
78
113
|
|
|
79
114
|
# Import display utilities
|
|
@@ -17,17 +17,59 @@ if project_dir not in sys.path:
|
|
|
17
17
|
sys.path.append(project_dir)
|
|
18
18
|
|
|
19
19
|
# Use dynamic import to avoid circular dependencies
|
|
20
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
20
21
|
def _get_load_insurance_function():
|
|
21
22
|
"""Dynamically import load_insurance_data_from_mains to avoid circular imports."""
|
|
22
23
|
try:
|
|
23
24
|
import MediBot_Preprocessor_lib
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
26
|
+
MediLink_ConfigLoader.log("Successfully imported MediBot_Preprocessor_lib", level="DEBUG")
|
|
27
|
+
|
|
28
|
+
if hasattr(MediBot_Preprocessor_lib, 'load_insurance_data_from_mains'):
|
|
29
|
+
func = MediBot_Preprocessor_lib.load_insurance_data_from_mains
|
|
30
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
31
|
+
MediLink_ConfigLoader.log("Successfully accessed load_insurance_data_from_mains function", level="DEBUG")
|
|
32
|
+
return func
|
|
33
|
+
else:
|
|
34
|
+
error_msg = "MediBot_Preprocessor_lib imported but load_insurance_data_from_mains attribute missing"
|
|
35
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
36
|
+
MediLink_ConfigLoader.log(error_msg, level="WARNING")
|
|
37
|
+
print("Warning: {}".format(error_msg))
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
except ImportError as e:
|
|
41
|
+
error_msg = "ImportError accessing MediBot_Preprocessor_lib: {}".format(str(e))
|
|
42
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
43
|
+
MediLink_ConfigLoader.log(error_msg, level="WARNING")
|
|
44
|
+
print("Warning: {}".format(error_msg))
|
|
45
|
+
return None
|
|
46
|
+
except AttributeError as e:
|
|
47
|
+
error_msg = "AttributeError accessing load_insurance_data_from_mains: {}".format(str(e))
|
|
48
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
49
|
+
MediLink_ConfigLoader.log(error_msg, level="WARNING")
|
|
50
|
+
print("Warning: {}".format(error_msg))
|
|
51
|
+
return None
|
|
52
|
+
except Exception as e:
|
|
53
|
+
error_msg = "Unexpected error accessing MediBot_Preprocessor_lib: {}".format(str(e))
|
|
54
|
+
if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
|
|
55
|
+
MediLink_ConfigLoader.log(error_msg, level="ERROR")
|
|
56
|
+
print("Error: {}".format(error_msg))
|
|
27
57
|
return None
|
|
28
58
|
|
|
29
59
|
load_insurance_data_from_mains = _get_load_insurance_function()
|
|
30
60
|
|
|
61
|
+
# XP Compatibility: Add fallback function if import fails
|
|
62
|
+
if load_insurance_data_from_mains is None:
|
|
63
|
+
def load_insurance_data_from_mains_fallback(config):
|
|
64
|
+
"""
|
|
65
|
+
Fallback function for load_insurance_data_from_mains when MediBot_Preprocessor_lib is not available.
|
|
66
|
+
Returns empty dictionary to prevent AttributeError.
|
|
67
|
+
"""
|
|
68
|
+
print("Warning: load_insurance_data_from_mains not available. Using empty insurance mapping.")
|
|
69
|
+
return {}
|
|
70
|
+
|
|
71
|
+
load_insurance_data_from_mains = load_insurance_data_from_mains_fallback
|
|
72
|
+
|
|
31
73
|
|
|
32
74
|
def collect_detailed_patient_data(selected_files, config, crosswalk):
|
|
33
75
|
"""
|
|
@@ -94,6 +136,7 @@ def enrich_with_insurance_type(detailed_patient_data, patient_insurance_type_map
|
|
|
94
136
|
# Enhanced mode check with graceful degradation
|
|
95
137
|
enhanced_mode = False
|
|
96
138
|
|
|
139
|
+
# XP/Python34 Compatibility: Enhanced error handling with verbose output
|
|
97
140
|
try:
|
|
98
141
|
from MediLink_insurance_utils import (
|
|
99
142
|
get_feature_flag,
|
|
@@ -103,9 +146,11 @@ def enrich_with_insurance_type(detailed_patient_data, patient_insurance_type_map
|
|
|
103
146
|
MediLink_ConfigLoader.log("Insurance enhancement utilities loaded successfully", level="DEBUG")
|
|
104
147
|
except ImportError as e:
|
|
105
148
|
MediLink_ConfigLoader.log("Insurance utils not available: {}. Using legacy mode.".format(str(e)), level="INFO")
|
|
149
|
+
print("Info: Using legacy insurance processing mode due to: {}".format(str(e)))
|
|
106
150
|
enhanced_mode = False
|
|
107
151
|
except Exception as e:
|
|
108
152
|
MediLink_ConfigLoader.log("Error initializing insurance enhancements: {}. Using legacy mode.".format(str(e)), level="ERROR")
|
|
153
|
+
print("Warning: Insurance enhancement error ({}), using legacy mode".format(str(e)))
|
|
109
154
|
enhanced_mode = False
|
|
110
155
|
|
|
111
156
|
if patient_insurance_type_mapping is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|