medicafe 0.250728.9__py3-none-any.whl → 0.250805.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of medicafe might be problematic. Click here for more details.

Files changed (57) hide show
  1. MediBot/MediBot.bat +233 -19
  2. MediBot/MediBot.py +138 -46
  3. MediBot/MediBot_Crosswalk_Library.py +127 -623
  4. MediBot/MediBot_Crosswalk_Utils.py +618 -0
  5. MediBot/MediBot_Preprocessor.py +72 -17
  6. MediBot/MediBot_Preprocessor_lib.py +470 -76
  7. MediBot/MediBot_UI.py +32 -17
  8. MediBot/MediBot_dataformat_library.py +68 -20
  9. MediBot/MediBot_docx_decoder.py +120 -19
  10. MediBot/MediBot_smart_import.py +180 -0
  11. MediBot/__init__.py +89 -0
  12. MediBot/get_medicafe_version.py +25 -0
  13. MediBot/update_json.py +35 -6
  14. MediBot/update_medicafe.py +19 -1
  15. MediCafe/MediLink_ConfigLoader.py +160 -0
  16. MediCafe/__init__.py +171 -0
  17. MediCafe/__main__.py +222 -0
  18. MediCafe/api_core.py +1098 -0
  19. MediCafe/api_core_backup.py +427 -0
  20. MediCafe/api_factory.py +306 -0
  21. MediCafe/api_utils.py +356 -0
  22. MediCafe/core_utils.py +450 -0
  23. MediCafe/graphql_utils.py +445 -0
  24. MediCafe/logging_config.py +123 -0
  25. MediCafe/logging_demo.py +61 -0
  26. MediCafe/migration_helpers.py +463 -0
  27. MediCafe/smart_import.py +436 -0
  28. MediLink/MediLink_837p_cob_library.py +28 -28
  29. MediLink/MediLink_837p_encoder.py +33 -34
  30. MediLink/MediLink_837p_encoder_library.py +226 -150
  31. MediLink/MediLink_837p_utilities.py +129 -5
  32. MediLink/MediLink_API_Generator.py +83 -60
  33. MediLink/MediLink_API_v3.py +1 -1
  34. MediLink/MediLink_ClaimStatus.py +177 -31
  35. MediLink/MediLink_DataMgmt.py +378 -63
  36. MediLink/MediLink_Decoder.py +20 -1
  37. MediLink/MediLink_Deductible.py +155 -28
  38. MediLink/MediLink_Display_Utils.py +72 -0
  39. MediLink/MediLink_Down.py +127 -5
  40. MediLink/MediLink_Gmail.py +712 -653
  41. MediLink/MediLink_PatientProcessor.py +257 -0
  42. MediLink/MediLink_UI.py +85 -71
  43. MediLink/MediLink_Up.py +28 -4
  44. MediLink/MediLink_insurance_utils.py +227 -230
  45. MediLink/MediLink_main.py +248 -0
  46. MediLink/MediLink_smart_import.py +264 -0
  47. MediLink/__init__.py +93 -1
  48. MediLink/insurance_type_integration_test.py +13 -3
  49. MediLink/test.py +1 -1
  50. MediLink/test_timing.py +59 -0
  51. {medicafe-0.250728.9.dist-info → medicafe-0.250805.0.dist-info}/METADATA +1 -1
  52. medicafe-0.250805.0.dist-info/RECORD +81 -0
  53. medicafe-0.250805.0.dist-info/entry_points.txt +2 -0
  54. {medicafe-0.250728.9.dist-info → medicafe-0.250805.0.dist-info}/top_level.txt +1 -0
  55. medicafe-0.250728.9.dist-info/RECORD +0 -59
  56. {medicafe-0.250728.9.dist-info → medicafe-0.250805.0.dist-info}/LICENSE +0 -0
  57. {medicafe-0.250728.9.dist-info → medicafe-0.250805.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,61 @@
1
+ # MediCafe/logging_demo.py
2
+ """
3
+ Demo script showing how to use the centralized logging configuration.
4
+ This demonstrates the different logging modes available.
5
+ """
6
+
7
+ from MediCafe.logging_config import (
8
+ DEBUG, CONSOLE_LOGGING, PERFORMANCE_LOGGING,
9
+ enable_debug_mode, enable_performance_mode, enable_quiet_mode,
10
+ get_logging_status, print_logging_status
11
+ )
12
+
13
+ def demo_logging_modes():
14
+ """Demonstrate different logging modes"""
15
+
16
+ print("=" * 60)
17
+ print("MEDICAFE LOGGING CONFIGURATION DEMO")
18
+ print("=" * 60)
19
+
20
+ # Show initial status
21
+ print("\n1. Initial Status:")
22
+ print_logging_status()
23
+
24
+ # Demo quiet mode
25
+ print("\n2. Enabling Quiet Mode (minimal output):")
26
+ enable_quiet_mode()
27
+ print_logging_status()
28
+
29
+ # Demo performance mode
30
+ print("\n3. Enabling Performance Mode (timing only):")
31
+ enable_performance_mode()
32
+ print_logging_status()
33
+
34
+ # Demo debug mode
35
+ print("\n4. Enabling Debug Mode (full verbose output):")
36
+ enable_debug_mode()
37
+ print_logging_status()
38
+
39
+ # Reset to quiet
40
+ print("\n5. Resetting to Quiet Mode:")
41
+ enable_quiet_mode()
42
+ print_logging_status()
43
+
44
+ print("\n" + "=" * 60)
45
+ print("USAGE EXAMPLES:")
46
+ print("=" * 60)
47
+ print("from MediCafe.logging_config import enable_debug_mode")
48
+ print("enable_debug_mode() # Enable all verbose logging")
49
+ print("")
50
+ print("from MediCafe.logging_config import enable_performance_mode")
51
+ print("enable_performance_mode() # Enable only timing messages")
52
+ print("")
53
+ print("from MediCafe.logging_config import enable_quiet_mode")
54
+ print("enable_quiet_mode() # Enable minimal output")
55
+ print("")
56
+ print("from MediCafe.logging_config import DEBUG, CONSOLE_LOGGING")
57
+ print("if DEBUG: print('Debug message')")
58
+ print("if CONSOLE_LOGGING: print('Console message')")
59
+
60
+ if __name__ == "__main__":
61
+ demo_logging_modes()
@@ -0,0 +1,463 @@
1
+ """
2
+ MediCafe Migration Helpers
3
+
4
+ This module provides tools to help migrate existing MediBot and MediLink modules
5
+ to use the new MediCafe smart import system. It includes analysis tools,
6
+ migration utilities, and validation functions.
7
+
8
+ Usage:
9
+ # Analyze a module's imports
10
+ from MediCafe.migration_helpers import analyze_module_imports
11
+ analysis = analyze_module_imports('MediBot/MediBot.py')
12
+
13
+ # Generate migration suggestions
14
+ from MediCafe.migration_helpers import suggest_migration
15
+ suggestions = suggest_migration('MediBot/MediBot.py')
16
+
17
+ # Validate smart import system
18
+ from MediCafe.migration_helpers import validate_smart_import_system
19
+ validate_smart_import_system()
20
+ """
21
+
22
+ import os
23
+ import re
24
+ import ast
25
+ import importlib
26
+ # from typing import Dict, List, Tuple, Optional, Set, Any # Removed for Python 3.4.4 compatibility
27
+ # from pathlib import Path # Replaced with os.path for Python 3.4.4 compatibility
28
+ import warnings
29
+
30
+ def analyze_module_imports(file_path: str) -> Dict[str, Any]:
31
+ """Analyze the import statements in a Python module."""
32
+ try:
33
+ with open(file_path, 'r', encoding='utf-8') as f:
34
+ content = f.read()
35
+ except FileNotFoundError:
36
+ return {'error': 'File not found: {}'.format(file_path)}
37
+ except Exception as e:
38
+ return {'error': 'Error reading file: {}'.format(e)}
39
+
40
+ # Parse imports using AST
41
+ try:
42
+ tree = ast.parse(content)
43
+ except SyntaxError as e:
44
+ return {'error': 'Syntax error in file: {}'.format(e)}
45
+
46
+ imports = {
47
+ 'standard_library': [],
48
+ 'third_party': [],
49
+ 'medicafe_imports': [],
50
+ 'medibot_imports': [],
51
+ 'medilink_imports': [],
52
+ 'relative_imports': [],
53
+ 'other_imports': []
54
+ }
55
+
56
+ for node in ast.walk(tree):
57
+ if isinstance(node, ast.Import):
58
+ for alias in node.names:
59
+ module_name = alias.name
60
+ imports = _categorize_import(module_name, imports)
61
+ elif isinstance(node, ast.ImportFrom):
62
+ module_name = node.module or ''
63
+ level = node.level
64
+
65
+ if level > 0: # Relative import
66
+ imports['relative_imports'].append({
67
+ 'module': module_name,
68
+ 'names': [alias.name for alias in node.names],
69
+ 'level': level
70
+ })
71
+ else:
72
+ imports = _categorize_import(module_name, imports, node.names)
73
+
74
+ # Count imports by category
75
+ import_counts = {key: len(value) for key, value in imports.items()}
76
+
77
+ # Suggest smart import alternatives
78
+ smart_import_suggestions = _generate_smart_import_suggestions(imports)
79
+
80
+ return {
81
+ 'file_path': file_path,
82
+ 'imports': imports,
83
+ 'import_counts': import_counts,
84
+ 'smart_import_suggestions': smart_import_suggestions,
85
+ 'migration_complexity': _assess_migration_complexity(imports)
86
+ }
87
+
88
+ def _categorize_import(module_name: str, imports: Dict, names: Optional[List] = None) -> Dict:
89
+ """Categorize an import based on the module name."""
90
+ import_info = {
91
+ 'module': module_name,
92
+ 'names': [alias.name for alias in names] if names else None
93
+ }
94
+
95
+ if module_name.startswith('MediCafe'):
96
+ imports['medicafe_imports'].append(import_info)
97
+ elif module_name.startswith('MediBot'):
98
+ imports['medibot_imports'].append(import_info)
99
+ elif module_name.startswith('MediLink'):
100
+ imports['medilink_imports'].append(import_info)
101
+ elif module_name in ['os', 'sys', 'json', 'datetime', 're', 'pathlib', 'typing', 'collections']:
102
+ imports['standard_library'].append(import_info)
103
+ elif '.' in module_name or module_name in ['pandas', 'numpy', 'requests', 'flask', 'django']:
104
+ imports['third_party'].append(import_info)
105
+ else:
106
+ imports['other_imports'].append(import_info)
107
+
108
+ return imports
109
+
110
+ def _generate_smart_import_suggestions(imports: Dict) -> List[Dict[str, str]]:
111
+ """Generate suggestions for using smart import system."""
112
+ suggestions = []
113
+
114
+ # Check for MediCafe imports that could be simplified
115
+ medicafe_imports = imports.get('medicafe_imports', [])
116
+ if medicafe_imports:
117
+ components = []
118
+ for imp in medicafe_imports:
119
+ if imp['module'] == 'MediCafe.api_core':
120
+ components.append('api_core')
121
+ elif imp['module'] == 'MediCafe.logging_config':
122
+ components.append('logging_config')
123
+ elif imp['module'] == 'MediCafe.core_utils':
124
+ components.append('core_utils')
125
+ # Add more mappings as needed
126
+
127
+ if components:
128
+ suggestion = {
129
+ 'type': 'smart_import_conversion',
130
+ 'original': "Multiple MediCafe imports: {}".format([imp['module'] for imp in medicafe_imports]),
131
+ 'suggested': "from MediCafe import get_components\n{} = get_components({})".format(', '.join(components), ', '.join(repr(c) for c in components))
132
+ }
133
+ suggestions.append(suggestion)
134
+
135
+ # Check for cross-package imports that indicate need for smart import
136
+ cross_package_imports = []
137
+ cross_package_imports.extend(imports.get('medibot_imports', []))
138
+ cross_package_imports.extend(imports.get('medilink_imports', []))
139
+
140
+ if cross_package_imports:
141
+ suggestion = {
142
+ 'type': 'cross_package_optimization',
143
+ 'original': 'Cross-package imports detected',
144
+ 'suggested': 'Consider using setup_for_medibot() or setup_for_medilink() for comprehensive component access'
145
+ }
146
+ suggestions.append(suggestion)
147
+
148
+ return suggestions
149
+
150
+ def _assess_migration_complexity(imports: Dict) -> str:
151
+ """Assess the complexity of migrating a module to smart import system."""
152
+ total_relevant_imports = (
153
+ len(imports.get('medicafe_imports', [])) +
154
+ len(imports.get('medibot_imports', [])) +
155
+ len(imports.get('medilink_imports', []))
156
+ )
157
+
158
+ if total_relevant_imports == 0:
159
+ return 'none'
160
+ elif total_relevant_imports <= 3:
161
+ return 'low'
162
+ elif total_relevant_imports <= 7:
163
+ return 'medium'
164
+ else:
165
+ return 'high'
166
+
167
+ def suggest_migration(file_path: str) -> Dict[str, Any]:
168
+ """Generate detailed migration suggestions for a module."""
169
+ analysis = analyze_module_imports(file_path)
170
+
171
+ if 'error' in analysis:
172
+ return analysis
173
+
174
+ suggestions = []
175
+
176
+ # Determine module type based on file path
177
+ module_type = _determine_module_type(file_path)
178
+
179
+ if module_type:
180
+ suggestions.append({
181
+ 'type': 'module_setup',
182
+ 'title': 'Use {} setup function'.format(module_type),
183
+ 'description': 'Replace individual imports with setup_for_{}()'.format(module_type.split("_")[0]),
184
+ 'example': _generate_setup_example(module_type, analysis)
185
+ })
186
+
187
+ # Add specific component suggestions
188
+ component_suggestions = _generate_component_suggestions(analysis)
189
+ suggestions.extend(component_suggestions)
190
+
191
+ return {
192
+ 'file_path': file_path,
193
+ 'module_type': module_type,
194
+ 'migration_complexity': analysis['migration_complexity'],
195
+ 'suggestions': suggestions,
196
+ 'estimated_effort': _estimate_migration_effort(analysis)
197
+ }
198
+
199
+ def _determine_module_type(file_path: str) -> Optional[str]:
200
+ """Determine the appropriate module type based on file path and name."""
201
+ file_name = os.path.basename(file_path).lower()
202
+
203
+ if 'medibot' in file_path.lower():
204
+ if 'preprocessor' in file_name:
205
+ return 'medibot_preprocessor'
206
+ elif 'ui' in file_name:
207
+ return 'medibot_ui'
208
+ elif 'crosswalk' in file_name:
209
+ return 'medibot_crosswalk'
210
+ elif 'docx' in file_name or 'document' in file_name:
211
+ return 'medibot_document_processing'
212
+ else:
213
+ return 'medibot_preprocessor' # Default
214
+
215
+ elif 'medilink' in file_path.lower():
216
+ if 'claim' in file_name:
217
+ return 'medilink_claim_processing'
218
+ elif 'deductible' in file_name:
219
+ return 'medilink_deductible_processing'
220
+ elif 'gmail' in file_name or 'mail' in file_name:
221
+ return 'medilink_communication'
222
+ elif 'data' in file_name or 'mgmt' in file_name:
223
+ return 'medilink_data_management'
224
+ else:
225
+ return 'medilink_main' # Default
226
+
227
+ return None
228
+
229
+ def _generate_setup_example(module_type: str, analysis: Dict) -> str:
230
+ """Generate an example of how to use the setup function."""
231
+ if module_type.startswith('medibot'):
232
+ setup_func = "setup_for_medibot('{}')".format(module_type)
233
+ elif module_type.startswith('medilink'):
234
+ setup_func = "setup_for_medilink('{}')".format(module_type)
235
+ else:
236
+ setup_func = "get_api_access()"
237
+
238
+ example = """
239
+ # Replace multiple imports with smart import
240
+ from MediCafe import {setup_func.split('(')[0]}
241
+ components = {setup_func}
242
+
243
+ # Access components
244
+ api_core = components.get('api_core')
245
+ logging_config = components.get('logging_config')
246
+ # ... other components as needed
247
+ """
248
+ return example.strip()
249
+
250
+ def _generate_component_suggestions(analysis: Dict) -> List[Dict]:
251
+ """Generate specific component-level suggestions."""
252
+ suggestions = []
253
+
254
+ # Look for common patterns
255
+ imports = analysis.get('imports', {})
256
+
257
+ # Check for logging imports
258
+ for imp in imports.get('medicafe_imports', []):
259
+ if 'logging' in imp['module'].lower():
260
+ suggestions.append({
261
+ 'type': 'component_simplification',
262
+ 'title': 'Simplify logging import',
263
+ 'description': 'Use get_logging() convenience function',
264
+ 'example': 'from MediCafe import get_logging\nlogging_config = get_logging()'
265
+ })
266
+ break
267
+
268
+ # Check for API imports
269
+ api_imports = [imp for imp in imports.get('medicafe_imports', [])
270
+ if 'api' in imp['module'].lower()]
271
+ if api_imports:
272
+ suggestions.append({
273
+ 'type': 'api_suite',
274
+ 'title': 'Use API access suite',
275
+ 'description': 'Consolidate API-related imports',
276
+ 'example': 'from MediCafe import get_api_access\napi_suite = get_api_access()'
277
+ })
278
+
279
+ return suggestions
280
+
281
+ def _estimate_migration_effort(analysis: Dict) -> str:
282
+ """Estimate the effort required for migration."""
283
+ complexity = analysis['migration_complexity']
284
+ import_counts = analysis['import_counts']
285
+
286
+ total_imports = sum(import_counts.values())
287
+ relevant_imports = (
288
+ import_counts.get('medicafe_imports', 0) +
289
+ import_counts.get('medibot_imports', 0) +
290
+ import_counts.get('medilink_imports', 0)
291
+ )
292
+
293
+ if complexity == 'none':
294
+ return 'No migration needed'
295
+ elif complexity == 'low' and relevant_imports <= 2:
296
+ return 'Minimal (< 30 minutes)'
297
+ elif complexity == 'medium' and relevant_imports <= 5:
298
+ return 'Moderate (30-60 minutes)'
299
+ else:
300
+ return 'Significant (> 60 minutes)'
301
+
302
+ def validate_smart_import_system() -> Dict[str, Any]:
303
+ """Validate the smart import system functionality."""
304
+ results = {
305
+ 'system_available': False,
306
+ 'component_tests': {},
307
+ 'module_type_tests': {},
308
+ 'errors': [],
309
+ 'warnings': []
310
+ }
311
+
312
+ try:
313
+ from MediCafe import get_components, setup_for_medibot, setup_for_medilink
314
+ results['system_available'] = True
315
+
316
+ # Test core components
317
+ core_components = ['logging_config', 'core_utils']
318
+ for component in core_components:
319
+ try:
320
+ comp = get_components(component, silent_fail=True)
321
+ results['component_tests'][component] = comp is not None
322
+ except Exception as e:
323
+ results['component_tests'][component] = False
324
+ results['errors'].append("Failed to load {}: {}".format(component, e))
325
+
326
+ # Test module types
327
+ module_types = ['medibot_preprocessor', 'medilink_main']
328
+ for module_type in module_types:
329
+ try:
330
+ if 'medibot' in module_type:
331
+ components = setup_for_medibot(module_type)
332
+ else:
333
+ components = setup_for_medilink(module_type)
334
+ results['module_type_tests'][module_type] = len(components) > 0
335
+ except Exception as e:
336
+ results['module_type_tests'][module_type] = False
337
+ results['errors'].append("Failed to setup {}: {}".format(module_type, e))
338
+
339
+ except ImportError as e:
340
+ results['errors'].append("Smart import system not available: {}".format(e))
341
+
342
+ return results
343
+
344
+ def batch_analyze_directory(directory: str, pattern: str = "*.py") -> Dict[str, Any]:
345
+ """Analyze all Python files in a directory for migration opportunities."""
346
+ directory_path = directory
347
+
348
+ if not os.path.exists(directory_path):
349
+ return {'error': 'Directory not found: {}'.format(directory)}
350
+
351
+ results = {
352
+ 'directory': directory,
353
+ 'files_analyzed': 0,
354
+ 'migration_candidates': [],
355
+ 'summary': {
356
+ 'high_complexity': 0,
357
+ 'medium_complexity': 0,
358
+ 'low_complexity': 0,
359
+ 'no_migration_needed': 0
360
+ }
361
+ }
362
+
363
+ for file_path in directory_path.glob(pattern):
364
+ if file_path.is_file():
365
+ analysis = analyze_module_imports(str(file_path))
366
+ results['files_analyzed'] += 1
367
+
368
+ if 'error' not in analysis:
369
+ complexity = analysis['migration_complexity']
370
+ results['summary']['{}_complexity'.format(complexity)] += 1
371
+
372
+ if complexity != 'none':
373
+ results['migration_candidates'].append({
374
+ 'file': str(file_path),
375
+ 'complexity': complexity,
376
+ 'import_counts': analysis['import_counts']
377
+ })
378
+
379
+ return results
380
+
381
+ def generate_migration_report(directories: List[str]) -> str:
382
+ """Generate a comprehensive migration report for multiple directories."""
383
+ report_lines = [
384
+ "MediCafe Smart Import System - Migration Report",
385
+ "=" * 50,
386
+ ""
387
+ ]
388
+
389
+ total_files = 0
390
+ total_candidates = 0
391
+
392
+ for directory in directories:
393
+ if os.path.exists(directory):
394
+ analysis = batch_analyze_directory(directory)
395
+
396
+ if 'error' not in analysis:
397
+ report_lines.extend([
398
+ "Directory: {}".format(directory),
399
+ "Files analyzed: {}".format(analysis['files_analyzed']),
400
+ "Migration candidates: {}".format(len(analysis['migration_candidates'])),
401
+ ""
402
+ ])
403
+
404
+ total_files += analysis['files_analyzed']
405
+ total_candidates += len(analysis['migration_candidates'])
406
+
407
+ # Add complexity breakdown
408
+ summary = analysis['summary']
409
+ report_lines.extend([
410
+ "Complexity breakdown:",
411
+ " High: {}".format(summary['high_complexity']),
412
+ " Medium: {}".format(summary['medium_complexity']),
413
+ " Low: {}".format(summary['low_complexity']),
414
+ " None: {}".format(summary['no_migration_needed']),
415
+ ""
416
+ ])
417
+
418
+ # Add summary
419
+ report_lines.extend([
420
+ "Overall Summary:",
421
+ "Total files analyzed: {}".format(total_files),
422
+ "Total migration candidates: {}".format(total_candidates),
423
+ "Migration rate: {:.1f}%".format((total_candidates/total_files*100)) if total_files > 0 else "N/A",
424
+ ""
425
+ ])
426
+
427
+ # Add validation results
428
+ validation = validate_smart_import_system()
429
+ report_lines.extend([
430
+ "Smart Import System Status:",
431
+ "System available: {}".format(validation['system_available']),
432
+ "Component tests passed: {}/{}".format(sum(validation['component_tests'].values()), len(validation['component_tests'])),
433
+ "Module type tests passed: {}/{}".format(sum(validation['module_type_tests'].values()), len(validation['module_type_tests'])),
434
+ ])
435
+
436
+ if validation['errors']:
437
+ report_lines.extend([
438
+ "",
439
+ "Errors:",
440
+ *[" - {}".format(error) for error in validation['errors']]
441
+ ])
442
+
443
+ return "\n".join(report_lines)
444
+
445
+ # Convenience function for quick analysis
446
+ def quick_migration_check():
447
+ """Perform a quick migration check of the main directories."""
448
+ directories = ['MediBot', 'MediLink']
449
+ existing_dirs = [d for d in directories if os.path.exists(d)]
450
+
451
+ if not existing_dirs:
452
+ print("No MediBot or MediLink directories found in current location.")
453
+ return
454
+
455
+ report = generate_migration_report(existing_dirs)
456
+ print(report)
457
+
458
+ # Suggest next steps
459
+ print("\nNext Steps:")
460
+ print("1. Review migration candidates with high/medium complexity")
461
+ print("2. Use suggest_migration(file_path) for detailed suggestions")
462
+ print("3. Test smart import system with validate_smart_import_system()")
463
+ print("4. Start migration with low-complexity files first")