medicafe 0.250810.2__tar.gz → 0.250810.4__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.
Files changed (74) hide show
  1. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/update_medicafe.py +149 -168
  2. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/__main__.py +5 -8
  3. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/api_core.py +7 -1
  4. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/core_utils.py +12 -8
  5. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_837p_encoder_library.py +8 -0
  6. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_PatientProcessor.py +8 -10
  7. {medicafe-0.250810.2/medicafe.egg-info → medicafe-0.250810.4}/PKG-INFO +1 -1
  8. {medicafe-0.250810.2 → medicafe-0.250810.4/medicafe.egg-info}/PKG-INFO +1 -1
  9. {medicafe-0.250810.2 → medicafe-0.250810.4}/setup.py +1 -1
  10. {medicafe-0.250810.2 → medicafe-0.250810.4}/LICENSE +0 -0
  11. {medicafe-0.250810.2 → medicafe-0.250810.4}/MANIFEST.in +0 -0
  12. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot.bat +0 -0
  13. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot.py +0 -0
  14. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Charges.py +0 -0
  15. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Crosswalk_Library.py +0 -0
  16. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Crosswalk_Utils.py +0 -0
  17. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Post.py +0 -0
  18. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Preprocessor.py +0 -0
  19. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_Preprocessor_lib.py +0 -0
  20. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_UI.py +0 -0
  21. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_dataformat_library.py +0 -0
  22. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_docx_decoder.py +0 -0
  23. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/MediBot_smart_import.py +0 -0
  24. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/__init__.py +0 -0
  25. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/get_medicafe_version.py +0 -0
  26. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediBot/update_json.py +0 -0
  27. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/MediLink_ConfigLoader.py +0 -0
  28. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/__init__.py +0 -0
  29. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/api_core_backup.py +0 -0
  30. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/api_factory.py +0 -0
  31. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/api_utils.py +0 -0
  32. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/graphql_utils.py +0 -0
  33. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/logging_config.py +0 -0
  34. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/logging_demo.py +0 -0
  35. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/migration_helpers.py +0 -0
  36. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediCafe/smart_import.py +0 -0
  37. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_837p_cob_library.py +0 -0
  38. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_837p_encoder.py +0 -0
  39. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_837p_utilities.py +0 -0
  40. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_API_Generator.py +0 -0
  41. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Azure.py +0 -0
  42. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_ClaimStatus.py +0 -0
  43. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_DataMgmt.py +0 -0
  44. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Decoder.py +0 -0
  45. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Deductible.py +0 -0
  46. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Deductible_Validator.py +0 -0
  47. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Display_Utils.py +0 -0
  48. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Down.py +0 -0
  49. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Gmail.py +0 -0
  50. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Mailer.py +0 -0
  51. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Parser.py +0 -0
  52. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Scan.py +0 -0
  53. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Scheduler.py +0 -0
  54. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_UI.py +0 -0
  55. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_Up.py +0 -0
  56. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_insurance_utils.py +0 -0
  57. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_main.py +0 -0
  58. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/MediLink_smart_import.py +0 -0
  59. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/Soumit_api.py +0 -0
  60. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/__init__.py +0 -0
  61. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/insurance_type_integration_test.py +0 -0
  62. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/openssl.cnf +0 -0
  63. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/test.py +0 -0
  64. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/test_cob_library.py +0 -0
  65. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/test_timing.py +0 -0
  66. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/test_validation.py +0 -0
  67. {medicafe-0.250810.2 → medicafe-0.250810.4}/MediLink/webapp.html +0 -0
  68. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/SOURCES.txt +0 -0
  69. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/dependency_links.txt +0 -0
  70. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/entry_points.txt +0 -0
  71. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/not-zip-safe +0 -0
  72. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/requires.txt +0 -0
  73. {medicafe-0.250810.2 → medicafe-0.250810.4}/medicafe.egg-info/top_level.txt +0 -0
  74. {medicafe-0.250810.2 → medicafe-0.250810.4}/setup.cfg +0 -0
@@ -84,6 +84,18 @@ def print_final_result(success, message):
84
84
 
85
85
  def get_installed_version(package):
86
86
  try:
87
+ # First try using pkg_resources directly (more reliable for Python 3.4)
88
+ if pkg_resources:
89
+ try:
90
+ version = pkg_resources.get_distribution(package).version
91
+ return version
92
+ except pkg_resources.DistributionNotFound:
93
+ return None
94
+ except Exception as e:
95
+ print("Warning: pkg_resources failed: {}".format(e))
96
+ # Fall through to pip method
97
+
98
+ # Fallback to pip show (may fail on Python 3.4 due to packaging issues)
87
99
  process = subprocess.Popen(
88
100
  [sys.executable, '-m', 'pip', 'show', package],
89
101
  stdout=subprocess.PIPE,
@@ -114,30 +126,29 @@ def get_latest_version(package, retries=3, delay=1):
114
126
  data = response.json()
115
127
  latest_version = data['info']['version']
116
128
 
117
- # Print the version with attempt information (only in debug mode)
118
- if DEBUG_MODE:
119
- if attempt == 1:
120
- print("Latest available version: {}".format(latest_version))
121
- else:
122
- print("Latest available version: {} ({} attempt)".format(latest_version, attempt))
129
+ # Print the version with attempt information
130
+ if attempt == 1:
131
+ print("Latest available version: {}".format(latest_version))
132
+ else:
133
+ print("Latest available version: {} ({} attempt)".format(latest_version, attempt))
123
134
 
124
135
  # Check if the latest version is different from the current version
125
136
  current_version = get_installed_version(package)
126
137
  if current_version and compare_versions(latest_version, current_version) == 0:
127
- # If the versions are the same, perform a second request
138
+ # If the versions are the same, perform a second request to ensure we have the latest
128
139
  time.sleep(delay)
129
140
  response = requests.get("https://pypi.org/pypi/{}/json".format(package), timeout=10)
130
141
  response.raise_for_status()
131
142
  data = response.json()
132
143
  latest_version = data['info']['version']
144
+ print("Double-checked latest version: {}".format(latest_version))
133
145
 
134
146
  return latest_version # Return the version after the check
135
147
  except requests.RequestException as e:
136
- if DEBUG_MODE:
137
- print("Attempt {}: Error fetching latest version: {}".format(attempt, e))
138
- if attempt < retries:
139
- print("Retrying in {} seconds...".format(delay))
140
- time.sleep(delay)
148
+ print("Attempt {}: Error fetching latest version: {}".format(attempt, e))
149
+ if attempt < retries:
150
+ print("Retrying in {} seconds...".format(delay))
151
+ time.sleep(delay)
141
152
  return None
142
153
 
143
154
  def check_internet_connection():
@@ -159,8 +170,7 @@ def clear_python_cache(workspace_path=None):
159
170
  bool: True if cache was cleared successfully, False otherwise
160
171
  """
161
172
  try:
162
- if DEBUG_MODE:
163
- print_status("Clearing Python bytecode cache...", "INFO")
173
+ print_status("Clearing Python bytecode cache...", "INFO")
164
174
 
165
175
  # If no workspace path provided, try to detect it
166
176
  if not workspace_path:
@@ -181,12 +191,10 @@ def clear_python_cache(workspace_path=None):
181
191
  break
182
192
 
183
193
  if not workspace_path:
184
- if DEBUG_MODE:
185
- print_status("Could not detect workspace path. Cache clearing skipped.", "WARNING")
194
+ print_status("Could not detect workspace path. Cache clearing skipped.", "WARNING")
186
195
  return False
187
196
 
188
- if DEBUG_MODE:
189
- print("Workspace path: {}".format(workspace_path))
197
+ print("Workspace path: {}".format(workspace_path))
190
198
 
191
199
  # Directories to clear cache from
192
200
  cache_dirs = [
@@ -204,12 +212,10 @@ def clear_python_cache(workspace_path=None):
204
212
  if os.path.exists(pycache_path):
205
213
  try:
206
214
  shutil.rmtree(pycache_path)
207
- if DEBUG_MODE:
208
- print("Cleared cache: {}".format(pycache_path))
215
+ print("Cleared cache: {}".format(pycache_path))
209
216
  cleared_count += 1
210
217
  except Exception as e:
211
- if DEBUG_MODE:
212
- print("Warning: Could not clear cache at {}: {}".format(pycache_path, e))
218
+ print("Warning: Could not clear cache at {}: {}".format(pycache_path, e))
213
219
 
214
220
  # Remove .pyc files
215
221
  for root, dirs, files in os.walk(cache_dir):
@@ -217,25 +223,20 @@ def clear_python_cache(workspace_path=None):
217
223
  if file.endswith('.pyc'):
218
224
  try:
219
225
  os.remove(os.path.join(root, file))
220
- if DEBUG_MODE:
221
- print("Removed .pyc file: {}".format(os.path.join(root, file)))
226
+ print("Removed .pyc file: {}".format(os.path.join(root, file)))
222
227
  cleared_count += 1
223
228
  except Exception as e:
224
- if DEBUG_MODE:
225
- print("Warning: Could not remove .pyc file {}: {}".format(file, e))
229
+ print("Warning: Could not remove .pyc file {}: {}".format(file, e))
226
230
 
227
231
  if cleared_count > 0:
228
- if DEBUG_MODE:
229
- print_status("Successfully cleared {} cache items".format(cleared_count), "SUCCESS")
232
+ print_status("Successfully cleared {} cache items".format(cleared_count), "SUCCESS")
230
233
  return True
231
234
  else:
232
- if DEBUG_MODE:
233
- print_status("No cache files found to clear", "INFO")
235
+ print_status("No cache files found to clear", "INFO")
234
236
  return True
235
237
 
236
238
  except Exception as e:
237
- if DEBUG_MODE:
238
- print_status("Error clearing cache: {}".format(e), "ERROR")
239
+ print_status("Error clearing cache: {}".format(e), "ERROR")
239
240
  return False
240
241
 
241
242
  def compare_versions(version1, version2):
@@ -252,22 +253,20 @@ def upgrade_package(package, retries=3, delay=2): # Updated retries to 3
252
253
  print_final_result(False, "No internet connection available")
253
254
 
254
255
  for attempt in range(1, retries + 1):
255
- if DEBUG_MODE:
256
- print("Attempt {} to upgrade {}...".format(attempt, package))
257
- process = subprocess.Popen(
258
- [
259
- sys.executable, '-m', 'pip', 'install', '--upgrade',
260
- package, '--no-cache-dir', '--disable-pip-version-check', '-q'
261
- ],
262
- stdout=subprocess.PIPE,
263
- stderr=subprocess.PIPE
264
- )
256
+ print("Attempt {} to upgrade {}...".format(attempt, package))
265
257
 
258
+ # Use a more compatible approach for Python 3.4
259
+ # Try with --no-deps first to avoid dependency resolution issues
260
+ cmd = [
261
+ sys.executable, '-m', 'pip', 'install', '--upgrade',
262
+ '--no-deps', '--no-cache-dir', '--disable-pip-version-check', '-q', package
263
+ ]
264
+
265
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
266
266
  stdout, stderr = process.communicate()
267
267
 
268
268
  if process.returncode == 0:
269
- if DEBUG_MODE:
270
- print(stdout.decode().strip())
269
+ print(stdout.decode().strip())
271
270
  new_version = get_installed_version(package) # Get new version after upgrade
272
271
  if compare_versions(new_version, get_latest_version(package)) >= 0: # Compare versions
273
272
  if attempt == 1:
@@ -279,17 +278,39 @@ def upgrade_package(package, retries=3, delay=2): # Updated retries to 3
279
278
  else:
280
279
  print_status("Upgrade failed. Current version remains: {}".format(new_version), "WARNING")
281
280
  if attempt < retries:
282
- if DEBUG_MODE:
283
- print("Retrying in {} seconds...".format(delay))
281
+ print("Retrying in {} seconds...".format(delay))
284
282
  time.sleep(delay)
285
283
  else:
286
- if DEBUG_MODE:
287
- print(stderr.decode().strip())
288
- print_status("Attempt {}: Upgrade failed.".format(attempt), "WARNING")
284
+ print(stderr.decode().strip())
285
+ print_status("Attempt {}: Upgrade failed with --no-deps.".format(attempt), "WARNING")
286
+
287
+ # If --no-deps failed, try with --force-reinstall to bypass dependency issues
289
288
  if attempt < retries:
290
- if DEBUG_MODE:
289
+ print("Retrying with --force-reinstall...")
290
+ cmd = [
291
+ sys.executable, '-m', 'pip', 'install', '--upgrade',
292
+ '--force-reinstall', '--no-cache-dir', '--disable-pip-version-check', '-q', package
293
+ ]
294
+
295
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
296
+ stdout, stderr = process.communicate()
297
+
298
+ if process.returncode == 0:
299
+ print(stdout.decode().strip())
300
+ new_version = get_installed_version(package)
301
+ if compare_versions(new_version, get_latest_version(package)) >= 0:
302
+ print_status("Attempt {}: Upgrade succeeded with --force-reinstall!".format(attempt), "SUCCESS")
303
+ time.sleep(delay)
304
+ return True
305
+ else:
306
+ print_status("Upgrade failed. Current version remains: {}".format(new_version), "WARNING")
307
+ else:
308
+ print(stderr.decode().strip())
309
+ print_status("Attempt {}: Upgrade failed with --force-reinstall.".format(attempt), "WARNING")
310
+
311
+ if attempt < retries:
291
312
  print("Retrying in {} seconds...".format(delay))
292
- time.sleep(delay)
313
+ time.sleep(delay)
293
314
 
294
315
  print_status("All upgrade attempts failed.", "ERROR")
295
316
  return False
@@ -402,170 +423,130 @@ def main():
402
423
  # Enable debug mode if requested via CLI or environment
403
424
  DEBUG_MODE = ('--debug' in sys.argv) or (os.environ.get('MEDICAFE_DEBUG', '0') in ['1', 'true', 'TRUE'])
404
425
 
405
- # Always show the header for user feedback
406
- print("="*60)
407
- print("MediCafe Update Utility")
408
- print("="*60)
409
- print("Timestamp: {}".format(time.strftime("%Y-%m-%d %H:%M:%S")))
410
- print("Python Version: {}".format(sys.version.split()[0]))
411
- print("Platform: {}".format(platform.system()))
412
- print("="*60)
413
- print()
414
-
415
- # STEP 1: Environment Information (always show basic info)
416
- print("STEP 1: Environment Check")
417
- print("-" * 40)
418
- print("Working Directory: {}".format(os.getcwd()))
419
- print("Script Location: {}".format(os.path.basename(__file__)))
420
- print("Python Executable: {}".format(sys.executable))
421
- print()
422
-
423
- # STEP 2: Check Python and pip (always verify)
424
- print("STEP 2: Python Environment")
425
- print("-" * 40)
426
+ print_status("MediCafe Update Utility", "INFO")
427
+ print("Starting update process...")
428
+
429
+ # STEP 1: Environment Information
430
+ debug_step(1, "Environment Information",
431
+ "Python version: {}\n"
432
+ "Platform: {}\n"
433
+ "Current working directory: {}\n"
434
+ "Script location: {}\n"
435
+ "sys.executable: {}".format(
436
+ sys.version, platform.platform(), os.getcwd(),
437
+ __file__, sys.executable))
438
+
439
+ # STEP 2: Check Python and pip
440
+ debug_step(2, "Python and pip Verification")
426
441
  print("Checking Python installation...")
427
442
  try:
428
- process = subprocess.Popen([sys.executable, '--version'],
443
+ process = subprocess.Popen([sys.executable, '--version'],
429
444
  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
430
445
  stdout, stderr = process.communicate()
431
446
  if process.returncode == 0:
432
- print("Python: {}".format(stdout.decode().strip()))
447
+ print("Python version: {}".format(stdout.decode().strip()))
433
448
  else:
434
- print("Python: ERROR - {}".format(stderr.decode().strip()))
435
- print_final_result(False, "Python installation check failed")
449
+ print("Error checking Python: {}".format(stderr.decode().strip()))
436
450
  except Exception as e:
437
- print("Python: ERROR - {}".format(e))
438
- print_final_result(False, "Python installation check failed")
439
-
440
- print("Checking pip installation...")
451
+ print("Error checking Python: {}".format(e))
452
+
453
+ print("\nChecking pip installation...")
441
454
  try:
442
- process = subprocess.Popen([sys.executable, '-m', 'pip', '--version'],
455
+ process = subprocess.Popen([sys.executable, '-m', 'pip', '--version'],
443
456
  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
444
457
  stdout, stderr = process.communicate()
445
458
  if process.returncode == 0:
446
- print("pip: {}".format(stdout.decode().strip()))
459
+ print("pip version: {}".format(stdout.decode().strip()))
447
460
  else:
448
- print("pip: ERROR - {}".format(stderr.decode().strip()))
449
- print_final_result(False, "pip installation check failed")
461
+ print("Error checking pip: {}".format(stderr.decode().strip()))
450
462
  except Exception as e:
451
- print("pip: ERROR - {}".format(e))
452
- print_final_result(False, "pip installation check failed")
453
- print()
454
-
455
- # STEP 3: Check MediCafe package (always check)
456
- print("STEP 3: MediCafe Package")
457
- print("-" * 40)
463
+ print("Error checking pip: {}".format(e))
464
+
465
+ # STEP 3: Check MediCafe package
466
+ debug_step(3, "MediCafe Package Check")
458
467
  package = "medicafe"
459
468
  current_version = get_installed_version(package)
460
469
  if current_version:
461
- print("Current Version: {}".format(current_version))
470
+ print("Current MediCafe version: {}".format(current_version))
462
471
  else:
463
- print("MediCafe: NOT INSTALLED")
464
- print("Attempting to install MediCafe...")
465
- if upgrade_package(package):
466
- current_version = get_installed_version(package)
467
- if current_version:
468
- print("MediCafe installed successfully: {}".format(current_version))
469
- else:
470
- print_final_result(False, "Failed to install MediCafe")
471
- else:
472
- print_final_result(False, "Failed to install MediCafe")
473
- print()
474
-
475
- # STEP 4: Internet connectivity (always check)
476
- print("STEP 4: Internet Connection")
477
- print("-" * 40)
478
- print("Testing internet connectivity...")
472
+ print("MediCafe package not found or not accessible")
473
+
474
+ # STEP 4: Internet connectivity
475
+ debug_step(4, "Internet Connectivity Test")
479
476
  if check_internet_connection():
480
- print("Internet: CONNECTED")
481
- if DEBUG_MODE:
482
- print("Testing PyPI connectivity...")
483
- try:
484
- response = requests.get("https://pypi.org/pypi/medicafe/json", timeout=10)
485
- print("PyPI: CONNECTED (Status: {})".format(response.status_code))
486
- except Exception as e:
487
- print("PyPI: ERROR - {}".format(e))
477
+ print("Internet connection: OK")
478
+ print("Testing PyPI connectivity...")
479
+ try:
480
+ response = requests.get("https://pypi.org/pypi/medicafe/json", timeout=10)
481
+ print("PyPI connectivity: OK (Status: {})".format(response.status_code))
482
+ except Exception as e:
483
+ print("PyPI connectivity: FAILED - {}".format(e))
488
484
  else:
489
- print("Internet: NOT CONNECTED")
485
+ print("Internet connection: FAILED")
490
486
  print_final_result(False, "No internet connection available")
491
- print()
492
-
493
- # STEP 5: Check for updates (always check)
494
- print("STEP 5: Version Check")
495
- print("-" * 40)
487
+
488
+ # STEP 5: Check for updates
489
+ debug_step(5, "Version Comparison")
496
490
  latest_version = get_latest_version(package)
497
491
  if latest_version:
498
- print("Latest Available: {}".format(latest_version))
492
+ print("Latest available version: {}".format(latest_version))
499
493
  if current_version:
500
494
  comparison = compare_versions(latest_version, current_version)
501
495
  if comparison > 0:
502
- print("Status: UPDATE NEEDED")
503
- print("Current: {} -> Latest: {}".format(current_version, latest_version))
496
+ print("Update needed: Current ({}) < Latest ({})".format(current_version, latest_version))
504
497
  elif comparison == 0:
505
- print("Status: UP TO DATE")
506
- print("Current: {} = Latest: {}".format(current_version, latest_version))
498
+ print("Already up to date: Current ({}) = Latest ({})".format(current_version, latest_version))
507
499
  else:
508
- print("Status: VERSION MISMATCH")
509
- print("Current: {} > Latest: {}".format(current_version, latest_version))
500
+ print("Version mismatch: Current ({}) > Latest ({})".format(current_version, latest_version))
510
501
  else:
511
- print("Status: CANNOT COMPARE")
512
- print("Current version not available")
502
+ print("Cannot compare versions - current version not available")
513
503
  else:
514
- print("Status: ERROR")
515
- print("Could not retrieve latest version")
504
+ print("Could not retrieve latest version information")
516
505
  print_final_result(False, "Unable to fetch latest version")
517
- print()
518
-
519
- # STEP 6: Dependencies check (only in debug mode)
506
+
507
+ # STEP 6: Dependencies check (skipped by default in streamlined mode)
508
+ debug_step(6, "Dependencies Check")
520
509
  if DEBUG_MODE:
521
- print("STEP 6: Dependencies Check")
522
- print("-" * 40)
523
- response = input("Check dependencies? (y/n, default=n): ").strip().lower()
510
+ response = input("Do you want to check dependencies? (yes/no, default/enter is no): ").strip().lower()
524
511
  if response in ['yes', 'y']:
525
512
  ensure_dependencies()
526
513
  else:
527
- print("Skipping dependency check.")
528
- print()
529
-
530
- # STEP 7: Perform update (always show progress)
531
- print("STEP 7: Update Process")
532
- print("-" * 40)
514
+ print_status("Skipping dependency check.", "INFO")
515
+ else:
516
+ print_status("Skipping dependency check (streamlined mode).", "INFO")
517
+
518
+ # STEP 7: Perform update
519
+ debug_step(7, "Update Execution")
533
520
  if current_version and latest_version and compare_versions(latest_version, current_version) > 0:
534
- print("Starting update process...")
535
- print("From: {} -> To: {}".format(current_version, latest_version))
536
- print()
537
-
521
+ print_status("A newer version is available. Proceeding with upgrade.", "INFO")
522
+ print("Current version: {}".format(current_version))
523
+ print("Target version: {}".format(latest_version))
524
+
538
525
  if upgrade_package(package):
539
526
  # STEP 8: Verify upgrade
540
- print("STEP 8: Verification")
541
- print("-" * 40)
527
+ debug_step(8, "Upgrade Verification")
542
528
  new_version = get_installed_version(package)
543
- print("New Version: {}".format(new_version))
544
-
529
+ print("New installed version: {}".format(new_version))
530
+
545
531
  if compare_versions(new_version, latest_version) >= 0:
546
- print("Status: SUCCESS")
547
-
548
- # STEP 9: Clear cache (always do, minimal output)
549
- print("STEP 9: Cache Cleanup")
550
- print("-" * 40)
551
- print("Clearing Python cache...")
532
+ print_status("Upgrade successful. New version: {}".format(new_version), "SUCCESS")
533
+
534
+ # DEBUG STEP 9: Clear cache
535
+ debug_step(9, "Cache Clearing")
536
+ print_status("Clearing Python cache to prevent import issues...", "INFO")
552
537
  if clear_python_cache():
553
- print("Cache: CLEARED")
538
+ print_status("Cache cleared successfully. Update complete.", "SUCCESS")
554
539
  else:
555
- print("Cache: WARNING - Some files could not be cleared")
556
-
540
+ print_status("Cache clearing failed, but update was successful.", "WARNING")
541
+
557
542
  print_final_result(True, "Successfully upgraded to version {}".format(new_version))
558
543
  else:
559
- print("Status: FAILED")
560
- print("Version verification failed")
544
+ print_status("Upgrade failed. Current version remains: {}".format(new_version), "ERROR")
561
545
  print_final_result(False, "Upgrade verification failed")
562
546
  else:
563
- print("Status: FAILED")
564
- print("Update process failed")
565
547
  print_final_result(False, "Upgrade process failed")
566
548
  else:
567
- print("Status: NO UPDATE NEEDED")
568
- print("MediCafe is already up to date.")
549
+ print_status("You already have the latest version installed.", "SUCCESS")
569
550
  print_final_result(True, "Already running latest version")
570
551
 
571
552
  if __name__ == "__main__":
@@ -38,14 +38,11 @@ def setup_entry_point_paths():
38
38
  if workspace_str not in sys.path:
39
39
  sys.path.insert(0, workspace_str)
40
40
 
41
- # Also add MediBot and MediLink directories specifically
42
- medibot_dir = os.path.join(workspace_root, 'MediBot')
43
- medilink_dir = os.path.join(workspace_root, 'MediLink')
44
-
45
- if medibot_dir not in sys.path:
46
- sys.path.insert(0, medibot_dir)
47
- if medilink_dir not in sys.path:
48
- sys.path.insert(0, medilink_dir)
41
+ # Ensure we do NOT add package directories directly; only project root should be on sys.path
42
+ # Clean any existing direct package paths that could break package imports (e.g., 'MediLink' is not a package)
43
+ for pkg_dir in (os.path.join(workspace_root, 'MediBot'), os.path.join(workspace_root, 'MediLink')):
44
+ while pkg_dir in sys.path:
45
+ sys.path.remove(pkg_dir)
49
46
 
50
47
  def run_medibot(config_file=None):
51
48
  """Run MediBot application"""
@@ -156,7 +156,13 @@ class APIClient(BaseAPIClient):
156
156
  APIRateLimiter = None
157
157
 
158
158
  try:
159
- from MediLink import MediLink_insurance_utils
159
+ try:
160
+ from MediLink import MediLink_insurance_utils
161
+ except Exception:
162
+ MediLink_insurance_utils = None
163
+ if MediLink_insurance_utils is None:
164
+ import importlib
165
+ MediLink_insurance_utils = importlib.import_module('MediLink.MediLink_insurance_utils')
160
166
  get_feature_flag = MediLink_insurance_utils.get_feature_flag
161
167
  MediLink_ConfigLoader.log("Successfully imported MediLink.MediLink_insurance_utils", level="DEBUG")
162
168
  except ImportError as e:
@@ -10,16 +10,20 @@ import os, sys
10
10
  # Ensure proper path setup for imports
11
11
  # Get the project root directory (parent of MediCafe directory)
12
12
  project_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
13
- medilink_dir = os.path.join(project_dir, 'MediLink')
14
- medibot_dir = os.path.join(project_dir, 'MediBot')
15
13
 
16
- # Add paths in order of priority - project root first, then module directories
14
+ # Only add project root to sys.path; do NOT add package directories directly
17
15
  if project_dir not in sys.path:
18
16
  sys.path.insert(0, project_dir)
19
- if medilink_dir not in sys.path:
20
- sys.path.insert(0, medilink_dir)
21
- if medibot_dir not in sys.path:
22
- sys.path.insert(0, medibot_dir)
17
+
18
+ # Remove any direct package paths that may have been injected elsewhere
19
+ _pkg_dirs = [os.path.join(project_dir, 'MediLink'), os.path.join(project_dir, 'MediBot')]
20
+ for _p in list(sys.path):
21
+ if _p in _pkg_dirs:
22
+ try:
23
+ while _p in sys.path:
24
+ sys.path.remove(_p)
25
+ except Exception:
26
+ pass
23
27
 
24
28
  # Common constants and configurations
25
29
  DEFAULT_CONFIG_PATH = os.path.join(project_dir, 'json', 'config.json')
@@ -62,7 +66,7 @@ def setup_module_paths(file_path):
62
66
  project_dir = os.path.abspath(os.path.join(os.path.dirname(file_path), ".."))
63
67
  current_dir = os.path.abspath(os.path.dirname(file_path))
64
68
 
65
- # Add paths in order of priority
69
+ # Add only project root and current module dir; avoid adding package dirs explicitly
66
70
  if project_dir not in sys.path:
67
71
  sys.path.insert(0, project_dir)
68
72
  if current_dir not in sys.path:
@@ -107,6 +107,14 @@ except ImportError:
107
107
  # XP/Python34 Compatibility: Enhanced error handling with verbose output
108
108
  try:
109
109
  from MediLink import MediLink_insurance_utils
110
+ except Exception:
111
+ MediLink_insurance_utils = None
112
+
113
+ safe_insurance_type_selection = None
114
+ try:
115
+ if MediLink_insurance_utils is None:
116
+ import importlib
117
+ MediLink_insurance_utils = importlib.import_module('MediLink.MediLink_insurance_utils')
110
118
  safe_insurance_type_selection = getattr(MediLink_insurance_utils, 'safe_insurance_type_selection', None)
111
119
  MediLink_ConfigLoader.log("Successfully imported safe_insurance_type_selection from MediLink_insurance_utils", level="DEBUG")
112
120
  except ImportError as e:
@@ -5,7 +5,7 @@
5
5
  import os, sys
6
6
 
7
7
  # Use core utilities for standardized imports
8
- from MediCafe.core_utils import get_shared_config_loader
8
+ from MediCafe.core_utils import get_shared_config_loader, import_medibot_module
9
9
  MediLink_ConfigLoader = get_shared_config_loader()
10
10
 
11
11
  import MediLink_DataMgmt
@@ -21,11 +21,10 @@ if project_dir not in sys.path:
21
21
  def _get_load_insurance_function():
22
22
  """Dynamically import load_insurance_data_from_mains to avoid circular imports."""
23
23
  try:
24
- import MediBot_Preprocessor_lib
24
+ MediBot_Preprocessor_lib = import_medibot_module('MediBot_Preprocessor_lib')
25
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'):
26
+ MediLink_ConfigLoader.log("Successfully imported MediBot_Preprocessor_lib via core_utils", level="DEBUG")
27
+ if MediBot_Preprocessor_lib and hasattr(MediBot_Preprocessor_lib, 'load_insurance_data_from_mains'):
29
28
  func = MediBot_Preprocessor_lib.load_insurance_data_from_mains
30
29
  if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
31
30
  MediLink_ConfigLoader.log("Successfully accessed load_insurance_data_from_mains function", level="DEBUG")
@@ -36,12 +35,11 @@ def _get_load_insurance_function():
36
35
  MediLink_ConfigLoader.log(error_msg, level="WARNING")
37
36
  print("Warning: {}".format(error_msg))
38
37
  return None
39
-
40
- except ImportError as e:
41
- error_msg = "ImportError accessing MediBot_Preprocessor_lib: {}".format(str(e))
38
+ except Exception as e:
39
+ error_msg = "Unexpected error accessing MediBot_Preprocessor_lib: {}".format(str(e))
42
40
  if MediLink_ConfigLoader and hasattr(MediLink_ConfigLoader, 'log'):
43
- MediLink_ConfigLoader.log(error_msg, level="WARNING")
44
- print("Warning: {}".format(error_msg))
41
+ MediLink_ConfigLoader.log(error_msg, level="ERROR")
42
+ print("Error: {}".format(error_msg))
45
43
  return None
46
44
  except AttributeError as e:
47
45
  error_msg = "AttributeError accessing load_insurance_data_from_mains: {}".format(str(e))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: medicafe
3
- Version: 0.250810.2
3
+ Version: 0.250810.4
4
4
  Summary: MediCafe
5
5
  Home-page: https://github.com/katanada2
6
6
  Author: Daniel Vidaud
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: medicafe
3
- Version: 0.250810.2
3
+ Version: 0.250810.4
4
4
  Summary: MediCafe
5
5
  Home-page: https://github.com/katanada2
6
6
  Author: Daniel Vidaud
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='medicafe',
5
- version="0.250810.2",
5
+ version="0.250810.4",
6
6
  description='MediCafe',
7
7
  long_description="""
8
8
  # Project Overview: MediCafe
File without changes
File without changes
File without changes