medicafe 0.250822.3__py3-none-any.whl → 0.250909.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.
- MediBot/MediBot.py +11 -4
- MediBot/MediBot_Crosswalk_Library.py +15 -2
- MediBot/MediBot_Crosswalk_Utils.py +12 -2
- MediBot/MediBot_Preprocessor_lib.py +1821 -1728
- MediBot/MediBot_docx_decoder.py +14 -3
- MediBot/__init__.py +1 -1
- MediCafe/MediLink_ConfigLoader.py +12 -1
- MediCafe/__init__.py +1 -1
- MediCafe/core_utils.py +8 -1
- MediCafe/deductible_utils.py +1233 -0
- MediLink/MediLink_837p_encoder_library.py +123 -39
- MediLink/MediLink_Deductible.py +524 -649
- MediLink/MediLink_Deductible_Validator.py +9 -3
- MediLink/MediLink_Display_Utils.py +44 -6
- MediLink/MediLink_UI.py +20 -2
- MediLink/__init__.py +1 -1
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/METADATA +1 -1
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/RECORD +22 -21
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/LICENSE +0 -0
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/WHEEL +0 -0
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/entry_points.txt +0 -0
- {medicafe-0.250822.3.dist-info → medicafe-0.250909.0.dist-info}/top_level.txt +0 -0
@@ -472,11 +472,19 @@ def _original_insurance_type_selection_logic(parsed_data):
|
|
472
472
|
except Exception as e:
|
473
473
|
MediLink_ConfigLoader.log("COB get_enhanced_insurance_options error: {}".format(str(e)), level="WARNING")
|
474
474
|
|
475
|
-
#
|
476
|
-
#
|
477
|
-
#
|
478
|
-
#
|
479
|
-
#
|
475
|
+
# STRATEGIC NOTE (Enhanced Insurance Options): COB library is fully implemented
|
476
|
+
# To activate enhanced Medicare support, replace this TODO with:
|
477
|
+
# if COB is not None and config.get('MediLink_Config', {}).get('cob_settings', {}).get('enabled', False):
|
478
|
+
# try:
|
479
|
+
# insurance_options = COB.get_enhanced_insurance_options(config)
|
480
|
+
# # This adds support for Medicare codes: MB (Part B), MA (Advantage), MC (Part C)
|
481
|
+
# except Exception as e:
|
482
|
+
# MediLink_ConfigLoader.log("COB enhancement error: {}".format(str(e)), level="WARNING")
|
483
|
+
#
|
484
|
+
# IMPLEMENTATION QUESTIONS:
|
485
|
+
# 1. Should Medicare type detection be automatic or require explicit configuration?
|
486
|
+
# 2. How should Medicare Advantage plans be distinguished from traditional Medicare?
|
487
|
+
# 3. Should enhanced options be enabled globally or per-endpoint?
|
480
488
|
|
481
489
|
def prompt_display_insurance_options():
|
482
490
|
# Prompt to display full list
|
@@ -1023,11 +1031,28 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
1023
1031
|
Verify that the service line number (LX), professional service (SV1), and service date (DTP) segments contain
|
1024
1032
|
accurate information and are formatted according to the claim's details.
|
1025
1033
|
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1034
|
+
STRATEGIC NOTE (Enhanced CLM Segment): COB library provides create_enhanced_clm_segment()
|
1035
|
+
|
1036
|
+
CRITICAL STRATEGIC QUESTIONS FOR HIGH-RISK IMPLEMENTATION:
|
1037
|
+
1. **Claim Frequency Strategy**: How should CLM05-3 be determined?
|
1038
|
+
- Always "1" (original) for secondary claims?
|
1039
|
+
- Support "7" (replacement) for corrections?
|
1040
|
+
- Automatic detection of replacement scenarios?
|
1041
|
+
|
1042
|
+
2. **COB Type Integration**: How should COB information be embedded?
|
1043
|
+
- Derive from claim_type field automatically?
|
1044
|
+
- Require explicit COB type configuration?
|
1045
|
+
- Handle mixed COB scenarios (multiple secondaries)?
|
1046
|
+
|
1047
|
+
3. **835 Data Integration**: How should adjudication data affect CLM?
|
1048
|
+
- Should 835 paid amounts influence claim totals?
|
1049
|
+
- Handle discrepancies between calculated vs adjudicated amounts?
|
1050
|
+
- What when 835 data is missing for secondary claims?
|
1051
|
+
|
1052
|
+
4. **PWK Attachment Strategy**: When should attachments be included?
|
1053
|
+
- Automatic for non-electronic EOB scenarios?
|
1054
|
+
- Manual control through UI?
|
1055
|
+
- Payer-specific attachment requirements?
|
1031
1056
|
|
1032
1057
|
See MediLink_837p_cob_library.create_enhanced_clm_segment() for enhanced implementation.
|
1033
1058
|
"""
|
@@ -1074,10 +1099,20 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
1074
1099
|
segments.extend(create_service_facility_location_npi_segment(config))
|
1075
1100
|
|
1076
1101
|
# For future reference, SBR - (Loop 2320: OI, NM1 (2330A), N3, N4, NM1 (2330B)) - Other Subscriber Information goes here.
|
1077
|
-
#
|
1078
|
-
#
|
1102
|
+
# STRATEGIC NOTE (COB Loops): COB library is fully implemented with all loop functions
|
1103
|
+
# Current implementation below (lines 1085-1118) has basic COB loop integration
|
1104
|
+
# To activate enhanced COB loops, the existing code needs these strategic decisions:
|
1105
|
+
#
|
1106
|
+
# IMPLEMENTATION QUESTIONS:
|
1107
|
+
# 1. Should COB loops be added automatically when claim_type='secondary' or require additional validation?
|
1108
|
+
# 2. How should missing prior payer information be handled (fail claim, prompt user, use defaults)?
|
1109
|
+
# 3. Should service-level COB (2430 loop) be enabled by default or require separate configuration?
|
1110
|
+
# 4. How should COB validation failures affect claim processing (warning, error, or block submission)?
|
1111
|
+
# 5. Should COB loops be configurable per payer or globally enabled?
|
1112
|
+
#
|
1113
|
+
# The COB library provides these ready-to-use functions:
|
1079
1114
|
# - create_2320_other_subscriber_segments() for secondary payer info
|
1080
|
-
# - create_2330B_prior_payer_segments() for Medicare prior payer
|
1115
|
+
# - create_2330B_prior_payer_segments() for Medicare prior payer
|
1081
1116
|
# - create_2430_service_line_cob_segments() for service-level adjudication
|
1082
1117
|
# - create_2330C_other_subscriber_name_segments() when patient != subscriber
|
1083
1118
|
#
|
@@ -1117,13 +1152,22 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
1117
1152
|
except Exception:
|
1118
1153
|
pass
|
1119
1154
|
|
1120
|
-
#
|
1121
|
-
#
|
1122
|
-
#
|
1123
|
-
#
|
1124
|
-
#
|
1125
|
-
#
|
1126
|
-
#
|
1155
|
+
# STRATEGIC NOTE (PWK Attachments): COB library provides create_pwk_attachment_segment()
|
1156
|
+
#
|
1157
|
+
# IMPLEMENTATION QUESTIONS:
|
1158
|
+
# 1. Should PWK segments be added automatically for all COB claims or only when explicitly required?
|
1159
|
+
# 2. How should attachment control numbers be generated and tracked?
|
1160
|
+
# 3. Should attachment requirements be configurable per payer?
|
1161
|
+
# 4. What validation is needed for attachment references?
|
1162
|
+
#
|
1163
|
+
# To activate: Uncomment and configure attachment logic:
|
1164
|
+
# if cob_enabled and validated_data.get('requires_attachment'):
|
1165
|
+
# try:
|
1166
|
+
# pwk_segment = COB.create_pwk_attachment_segment(validated_data, config)
|
1167
|
+
# if pwk_segment:
|
1168
|
+
# segments.append(pwk_segment)
|
1169
|
+
# except Exception as e:
|
1170
|
+
# MediLink_ConfigLoader.log("PWK attachment error: {}".format(str(e)), level="WARNING")
|
1127
1171
|
|
1128
1172
|
# LX - Service Line Counter
|
1129
1173
|
segments.append("LX*1~")
|
@@ -1138,19 +1182,54 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
1138
1182
|
# DTP - Date
|
1139
1183
|
segments.append("DTP*472*D8*{}~".format(convert_date_format(validated_data['DATE'])))
|
1140
1184
|
|
1141
|
-
#
|
1142
|
-
#
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1185
|
+
# REF*6R - Line Item Control Number (required for Medicare, optional for private insurance)
|
1186
|
+
# IMPLEMENTED: Add conditional REF*6R when payer is Medicare
|
1187
|
+
payer_id = validated_data.get('payer_id', '')
|
1188
|
+
payer_name = validated_data.get('payer_name', '').upper()
|
1189
|
+
|
1190
|
+
# Check if this is a Medicare payer (compatible with XP SP3 + Python 3.4.4)
|
1191
|
+
is_medicare = (payer_id == '00850' or
|
1192
|
+
'MEDICARE' in payer_name or
|
1193
|
+
'MCARE' in payer_name or
|
1194
|
+
payer_id in ['MEDICARE', 'CMS', 'MCARE'])
|
1195
|
+
|
1196
|
+
if is_medicare:
|
1197
|
+
# REF*6R*1 - Provider Control Number for Medicare claims
|
1198
|
+
# 6R = Provider Control Number qualifier
|
1199
|
+
# 1 = Sequential line item control number (could be enhanced to actual line number)
|
1200
|
+
segments.append("REF*6R*1~")
|
1201
|
+
try:
|
1202
|
+
MediLink_ConfigLoader.log("Added REF*6R segment for Medicare payer: {}".format(payer_name), config, level="DEBUG")
|
1203
|
+
except Exception:
|
1204
|
+
pass # Don't fail if logging fails
|
1205
|
+
|
1206
|
+
|
1207
|
+
# STRATEGIC NOTE (Service-Level COB): 2430 loop implementation is ready but needs strategic decisions
|
1208
|
+
# COB library provides create_2430_service_line_cob_segments() for service-level adjudication
|
1209
|
+
#
|
1210
|
+
# CRITICAL STRATEGIC QUESTIONS:
|
1211
|
+
# 1. **Data Source Strategy**: Where does service_adjudications data come from?
|
1212
|
+
# - Direct 835 remittance parsing?
|
1213
|
+
# - Manual entry through UI?
|
1214
|
+
# - Hybrid approach with validation?
|
1215
|
+
#
|
1216
|
+
# 2. **Activation Logic**: When should 2430 loops be included?
|
1217
|
+
# - Only when service_adjudications is populated?
|
1218
|
+
# - Required for all secondary claims?
|
1219
|
+
# - Optional enhancement based on payer requirements?
|
1220
|
+
#
|
1221
|
+
# 3. **Error Handling**: How should service-level COB failures be handled?
|
1222
|
+
# - Continue with claim-level COB only (current approach)?
|
1223
|
+
# - Block entire claim submission?
|
1224
|
+
# - Provide manual override and logging?
|
1225
|
+
#
|
1226
|
+
# To activate: Uncomment and configure the following:
|
1227
|
+
# if parsed_data.get('service_adjudications') and cob_enabled:
|
1228
|
+
# try:
|
1229
|
+
# cob_segments = COB.create_2430_service_line_cob_segments(validated_data, config, crosswalk)
|
1230
|
+
# segments.extend(cob_segments)
|
1231
|
+
# except Exception as e:
|
1232
|
+
# MediLink_ConfigLoader.log("Service-level COB error: {}".format(str(e)), level="WARNING")
|
1154
1233
|
|
1155
1234
|
return segments
|
1156
1235
|
|
@@ -1262,9 +1341,14 @@ def create_interchange_header(config, endpoint, isa13):
|
|
1262
1341
|
# GS06 Group Control Number, Field Length 1/9, must match GE02
|
1263
1342
|
# FIXED: Generate group control number using similar logic to ISA13 for consistency
|
1264
1343
|
current_time = datetime.now().strftime('%H%M%S')
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1344
|
+
# Normalize GS06 to suppress leading zeros per X12 numeric element rules
|
1345
|
+
try:
|
1346
|
+
_gs06_val = int(current_time[-6:] or '0')
|
1347
|
+
except Exception:
|
1348
|
+
_gs06_val = 0
|
1349
|
+
if _gs06_val < 1:
|
1350
|
+
_gs06_val = 1
|
1351
|
+
gs06 = str(_gs06_val)
|
1268
1352
|
|
1269
1353
|
gs_segment = "GS*HC*{}*{}*{}*{}*{}*X*005010X222A1~".format(
|
1270
1354
|
gs_sender_code, gs_receiver_code, format_datetime(), format_datetime(format_type='time'), gs06
|
@@ -1399,9 +1483,9 @@ def validate_claim_data_for_837p(parsed_data, config, crosswalk):
|
|
1399
1483
|
# FIXED: Error handling and logging added for file save failures
|
1400
1484
|
#
|
1401
1485
|
# REMAINING WORKFLOW ISSUES:
|
1402
|
-
# 1. Validation still happens during encoding (too late in the process) - FUTURE ENHANCEMENT
|
1403
|
-
# 2. No backup or rollback mechanism for crosswalk changes - FUTURE ENHANCEMENT
|
1404
|
-
# 3. No validation of new mappings before they're added - FUTURE ENHANCEMENT
|
1486
|
+
# 1. Validation still happens during encoding (too late in the process) - FUTURE ENHANCEMENT (High Priority - but difficult to implement)
|
1487
|
+
# 2. No backup or rollback mechanism for crosswalk changes - FUTURE ENHANCEMENT (Lower Priority)
|
1488
|
+
# 3. No validation of new mappings before they're added - FUTURE ENHANCEMENT (Medium Priority)
|
1405
1489
|
#
|
1406
1490
|
# FUTURE ENHANCEMENTS (NOT CRITICAL):
|
1407
1491
|
#
|