medicafe 0.250728.9__py3-none-any.whl → 0.250805.2__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.
- MediBot/MediBot.bat +233 -19
- MediBot/MediBot.py +138 -46
- MediBot/MediBot_Crosswalk_Library.py +127 -623
- MediBot/MediBot_Crosswalk_Utils.py +618 -0
- MediBot/MediBot_Preprocessor.py +72 -17
- MediBot/MediBot_Preprocessor_lib.py +470 -76
- MediBot/MediBot_UI.py +32 -17
- MediBot/MediBot_dataformat_library.py +68 -20
- MediBot/MediBot_docx_decoder.py +120 -19
- MediBot/MediBot_smart_import.py +180 -0
- MediBot/__init__.py +89 -0
- MediBot/get_medicafe_version.py +25 -0
- MediBot/update_json.py +35 -6
- MediBot/update_medicafe.py +19 -1
- MediCafe/MediLink_ConfigLoader.py +160 -0
- MediCafe/__init__.py +171 -0
- MediCafe/__main__.py +314 -0
- MediCafe/api_core.py +1098 -0
- MediCafe/api_core_backup.py +427 -0
- MediCafe/api_factory.py +306 -0
- MediCafe/api_utils.py +356 -0
- MediCafe/core_utils.py +450 -0
- MediCafe/graphql_utils.py +445 -0
- MediCafe/logging_config.py +123 -0
- MediCafe/logging_demo.py +61 -0
- MediCafe/migration_helpers.py +463 -0
- MediCafe/smart_import.py +436 -0
- MediLink/MediLink_837p_cob_library.py +28 -28
- MediLink/MediLink_837p_encoder.py +33 -34
- MediLink/MediLink_837p_encoder_library.py +226 -150
- MediLink/MediLink_837p_utilities.py +129 -5
- MediLink/MediLink_API_Generator.py +83 -60
- MediLink/MediLink_API_v3.py +1 -1
- MediLink/MediLink_ClaimStatus.py +177 -31
- MediLink/MediLink_DataMgmt.py +378 -63
- MediLink/MediLink_Decoder.py +20 -1
- MediLink/MediLink_Deductible.py +155 -28
- MediLink/MediLink_Display_Utils.py +72 -0
- MediLink/MediLink_Down.py +127 -5
- MediLink/MediLink_Gmail.py +720 -653
- MediLink/MediLink_PatientProcessor.py +257 -0
- MediLink/MediLink_UI.py +85 -71
- MediLink/MediLink_Up.py +28 -4
- MediLink/MediLink_insurance_utils.py +227 -230
- MediLink/MediLink_main.py +248 -0
- MediLink/MediLink_smart_import.py +264 -0
- MediLink/__init__.py +93 -1
- MediLink/insurance_type_integration_test.py +13 -3
- MediLink/test.py +1 -1
- MediLink/test_timing.py +59 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/METADATA +1 -1
- medicafe-0.250805.2.dist-info/RECORD +81 -0
- medicafe-0.250805.2.dist-info/entry_points.txt +2 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/top_level.txt +1 -0
- medicafe-0.250728.9.dist-info/RECORD +0 -59
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/LICENSE +0 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/WHEEL +0 -0
|
@@ -1,231 +1,228 @@
|
|
|
1
|
-
# MediLink_insurance_utils.py
|
|
2
|
-
# Insurance type enhancement utilities extracted from enhanced implementations
|
|
3
|
-
# Provides safe helper functions for production integration
|
|
4
|
-
# Python 3.4.4 compatible implementation
|
|
5
|
-
|
|
6
|
-
import time
|
|
7
|
-
import json
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
insurance_type_code
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"""
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
MediLink_ConfigLoader.log("
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"""
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"""
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
"""
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
MediLink_ConfigLoader.log("Batch processing completed with {} errors out of {} patients".format(
|
|
229
|
-
len(errors), len(patients)), level="WARNING")
|
|
230
|
-
|
|
1
|
+
# MediLink_insurance_utils.py
|
|
2
|
+
# Insurance type enhancement utilities extracted from enhanced implementations
|
|
3
|
+
# Provides safe helper functions for production integration
|
|
4
|
+
# Python 3.4.4 compatible implementation
|
|
5
|
+
|
|
6
|
+
import time
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
# Use core utilities for standardized imports
|
|
10
|
+
from MediCafe.core_utils import get_shared_config_loader
|
|
11
|
+
MediLink_ConfigLoader = get_shared_config_loader()
|
|
12
|
+
|
|
13
|
+
# Safe tqdm import with fallback
|
|
14
|
+
try:
|
|
15
|
+
from tqdm import tqdm
|
|
16
|
+
except ImportError:
|
|
17
|
+
# Fallback for when tqdm is not available
|
|
18
|
+
def tqdm(iterable, desc="Processing", **kwargs):
|
|
19
|
+
if desc:
|
|
20
|
+
print("{}...".format(desc))
|
|
21
|
+
return iterable
|
|
22
|
+
|
|
23
|
+
# Feature flag system
|
|
24
|
+
def get_feature_flag(flag_name, default=False):
|
|
25
|
+
"""Get feature flag from config or return default"""
|
|
26
|
+
try:
|
|
27
|
+
config, _ = MediLink_ConfigLoader.load_configuration()
|
|
28
|
+
feature_flags = config.get("MediLink_Config", {}).get("feature_flags", {})
|
|
29
|
+
return feature_flags.get(flag_name, default)
|
|
30
|
+
except Exception as e:
|
|
31
|
+
MediLink_ConfigLoader.log("Error reading feature flag {}: {}".format(flag_name, str(e)), level="WARNING")
|
|
32
|
+
return default
|
|
33
|
+
|
|
34
|
+
# Enhanced insurance type validation
|
|
35
|
+
def validate_insurance_type_from_config(insurance_type_code, payer_id=""):
|
|
36
|
+
"""
|
|
37
|
+
Validate insurance type against configuration.
|
|
38
|
+
Returns validated type or safe fallback.
|
|
39
|
+
"""
|
|
40
|
+
try:
|
|
41
|
+
config, _ = MediLink_ConfigLoader.load_configuration()
|
|
42
|
+
insurance_options = config.get('MediLink_Config', {}).get('insurance_options', {})
|
|
43
|
+
|
|
44
|
+
if not insurance_type_code:
|
|
45
|
+
MediLink_ConfigLoader.log("Empty insurance type code for payer {}, using default PPO".format(payer_id), level="INFO")
|
|
46
|
+
return '12' # Default to PPO
|
|
47
|
+
|
|
48
|
+
# Clean and normalize input
|
|
49
|
+
insurance_type_code = str(insurance_type_code).strip().upper()
|
|
50
|
+
|
|
51
|
+
# Basic format validation
|
|
52
|
+
if len(insurance_type_code) > 3 or not insurance_type_code.isalnum():
|
|
53
|
+
MediLink_ConfigLoader.log("Invalid insurance type format '{}' for payer {}, using PPO fallback".format(
|
|
54
|
+
insurance_type_code, payer_id), level="WARNING")
|
|
55
|
+
return '12'
|
|
56
|
+
|
|
57
|
+
# Configuration lookup - insurance type exists in config
|
|
58
|
+
if insurance_type_code in insurance_options:
|
|
59
|
+
MediLink_ConfigLoader.log("Validated insurance type '{}' for payer {}".format(
|
|
60
|
+
insurance_type_code, payer_id), level="DEBUG")
|
|
61
|
+
return insurance_type_code
|
|
62
|
+
|
|
63
|
+
# Unknown type - log and fallback
|
|
64
|
+
MediLink_ConfigLoader.log("Unknown insurance type '{}' for payer {} - using PPO fallback".format(
|
|
65
|
+
insurance_type_code, payer_id), level="WARNING")
|
|
66
|
+
|
|
67
|
+
return '12' # Safe fallback to PPO
|
|
68
|
+
|
|
69
|
+
except Exception as e:
|
|
70
|
+
MediLink_ConfigLoader.log("Insurance validation error: {} - using PPO fallback".format(str(e)), level="ERROR")
|
|
71
|
+
return '12'
|
|
72
|
+
|
|
73
|
+
# Monitoring and statistics
|
|
74
|
+
def generate_insurance_assignment_summary(detailed_patient_data):
|
|
75
|
+
"""Generate basic summary statistics for insurance type assignments"""
|
|
76
|
+
if not detailed_patient_data:
|
|
77
|
+
return {}
|
|
78
|
+
|
|
79
|
+
# Collect basic statistics
|
|
80
|
+
insurance_type_counts = {}
|
|
81
|
+
|
|
82
|
+
for data in detailed_patient_data:
|
|
83
|
+
insurance_type = data.get('insurance_type', 'UNKNOWN')
|
|
84
|
+
insurance_type_counts[insurance_type] = insurance_type_counts.get(insurance_type, 0) + 1
|
|
85
|
+
|
|
86
|
+
summary = {
|
|
87
|
+
'total_patients': len(detailed_patient_data),
|
|
88
|
+
'insurance_types': insurance_type_counts
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Log summary
|
|
92
|
+
MediLink_ConfigLoader.log("Insurance Assignment Summary: {}".format(json.dumps(summary)), level="INFO")
|
|
93
|
+
|
|
94
|
+
return summary
|
|
95
|
+
|
|
96
|
+
# Safe wrapper for insurance type selection
|
|
97
|
+
def safe_insurance_type_selection(parsed_data, fallback_function):
|
|
98
|
+
"""
|
|
99
|
+
Safe wrapper that attempts enhanced selection with fallback to original function.
|
|
100
|
+
Provides comprehensive error handling and logging.
|
|
101
|
+
"""
|
|
102
|
+
patient_name = parsed_data.get('LAST', 'UNKNOWN')
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
# Check if enhanced mode is enabled
|
|
106
|
+
enhanced_mode = get_feature_flag('enhanced_insurance_selection', default=False)
|
|
107
|
+
|
|
108
|
+
if enhanced_mode:
|
|
109
|
+
# Try enhanced selection (would be implemented here)
|
|
110
|
+
MediLink_ConfigLoader.log("Attempting enhanced insurance selection", level="DEBUG")
|
|
111
|
+
# For now, just call fallback - actual enhancement would go here
|
|
112
|
+
result = fallback_function(parsed_data)
|
|
113
|
+
MediLink_ConfigLoader.log("Insurance decision: type={}, method=ENHANCED".format(result), level="INFO")
|
|
114
|
+
return result
|
|
115
|
+
else:
|
|
116
|
+
# Use standard selection
|
|
117
|
+
result = fallback_function(parsed_data)
|
|
118
|
+
MediLink_ConfigLoader.log("Insurance decision: type={}, method=MANUAL".format(result), level="INFO")
|
|
119
|
+
return result
|
|
120
|
+
|
|
121
|
+
except Exception as e:
|
|
122
|
+
# Error handling with safe fallback
|
|
123
|
+
MediLink_ConfigLoader.log("Insurance selection error: {}. Using PPO default.".format(str(e)), level="ERROR")
|
|
124
|
+
|
|
125
|
+
MediLink_ConfigLoader.log("Insurance decision: type=12, method=ERROR_FALLBACK, error={}".format(str(e)), level="INFO")
|
|
126
|
+
return '12' # Safe fallback
|
|
127
|
+
|
|
128
|
+
# Configuration validation
|
|
129
|
+
def validate_insurance_configuration():
|
|
130
|
+
"""
|
|
131
|
+
Validate insurance configuration for production readiness.
|
|
132
|
+
Returns True if valid, raises exception if invalid.
|
|
133
|
+
"""
|
|
134
|
+
try:
|
|
135
|
+
config, _ = MediLink_ConfigLoader.load_configuration()
|
|
136
|
+
insurance_options = config['MediLink_Config'].get('insurance_options', {})
|
|
137
|
+
|
|
138
|
+
if not insurance_options:
|
|
139
|
+
raise ValueError("Missing insurance_options in MediLink_Config")
|
|
140
|
+
|
|
141
|
+
# Validate insurance options format
|
|
142
|
+
for code, description in insurance_options.items():
|
|
143
|
+
if not isinstance(code, str) or len(code) < 1:
|
|
144
|
+
raise ValueError("Invalid insurance code format: {}".format(code))
|
|
145
|
+
if not isinstance(description, str):
|
|
146
|
+
raise ValueError("Invalid insurance description for code: {}".format(code))
|
|
147
|
+
|
|
148
|
+
MediLink_ConfigLoader.log("Insurance configuration validation passed: {} options loaded".format(
|
|
149
|
+
len(insurance_options)), level="INFO")
|
|
150
|
+
return True
|
|
151
|
+
|
|
152
|
+
except Exception as e:
|
|
153
|
+
MediLink_ConfigLoader.log("Insurance configuration validation failed: {}".format(str(e)), level="ERROR")
|
|
154
|
+
raise e
|
|
155
|
+
|
|
156
|
+
# Production readiness check
|
|
157
|
+
def check_production_readiness():
|
|
158
|
+
"""
|
|
159
|
+
Check if system is ready for production deployment.
|
|
160
|
+
Returns list of warnings/errors that need attention.
|
|
161
|
+
"""
|
|
162
|
+
issues = []
|
|
163
|
+
|
|
164
|
+
try:
|
|
165
|
+
# Check configuration
|
|
166
|
+
validate_insurance_configuration()
|
|
167
|
+
except Exception as e:
|
|
168
|
+
issues.append("Configuration invalid: {}".format(str(e)))
|
|
169
|
+
|
|
170
|
+
# Check for test mode flags
|
|
171
|
+
try:
|
|
172
|
+
config, _ = MediLink_ConfigLoader.load_configuration()
|
|
173
|
+
test_mode = config.get("MediLink_Config", {}).get("TestMode", False)
|
|
174
|
+
if test_mode:
|
|
175
|
+
issues.append("TestMode is enabled - should be disabled for production")
|
|
176
|
+
except Exception as e:
|
|
177
|
+
issues.append("Cannot check test mode: {}".format(str(e)))
|
|
178
|
+
|
|
179
|
+
return issues
|
|
180
|
+
|
|
181
|
+
# Enhanced error handling wrapper
|
|
182
|
+
def with_insurance_error_handling(func):
|
|
183
|
+
"""
|
|
184
|
+
Decorator for insurance-related functions to add consistent error handling.
|
|
185
|
+
Python 3.4.4 compatible implementation.
|
|
186
|
+
"""
|
|
187
|
+
def wrapper(*args, **kwargs):
|
|
188
|
+
try:
|
|
189
|
+
return func(*args, **kwargs)
|
|
190
|
+
except Exception as e:
|
|
191
|
+
MediLink_ConfigLoader.log("Insurance function error in {}: {}".format(func.__name__, str(e)), level="ERROR")
|
|
192
|
+
# Return safe defaults based on function type
|
|
193
|
+
if 'insurance_type' in func.__name__:
|
|
194
|
+
return '12' # Default PPO for insurance type functions
|
|
195
|
+
else:
|
|
196
|
+
raise e # Re-raise for non-insurance type functions
|
|
197
|
+
return wrapper
|
|
198
|
+
|
|
199
|
+
# Utility for batch processing with progress tracking
|
|
200
|
+
def process_patients_with_progress(patients, processing_function, description="Processing patients"):
|
|
201
|
+
"""
|
|
202
|
+
Process patients with progress tracking and error collection.
|
|
203
|
+
Returns processed results and error summary.
|
|
204
|
+
"""
|
|
205
|
+
processed_results = []
|
|
206
|
+
errors = []
|
|
207
|
+
|
|
208
|
+
iterator = tqdm(patients, desc=description)
|
|
209
|
+
|
|
210
|
+
for i, patient in enumerate(iterator):
|
|
211
|
+
try:
|
|
212
|
+
result = processing_function(patient)
|
|
213
|
+
processed_results.append(result)
|
|
214
|
+
except Exception as e:
|
|
215
|
+
error_info = {
|
|
216
|
+
'patient_index': i,
|
|
217
|
+
'patient_id': patient.get('patient_id', 'UNKNOWN'),
|
|
218
|
+
'error': str(e)
|
|
219
|
+
}
|
|
220
|
+
errors.append(error_info)
|
|
221
|
+
MediLink_ConfigLoader.log("Error processing patient {}: {}".format(
|
|
222
|
+
patient.get('patient_id', i), str(e)), level="ERROR")
|
|
223
|
+
|
|
224
|
+
if errors:
|
|
225
|
+
MediLink_ConfigLoader.log("Batch processing completed with {} errors out of {} patients".format(
|
|
226
|
+
len(errors), len(patients)), level="WARNING")
|
|
227
|
+
|
|
231
228
|
return processed_results, errors
|