medicafe 0.250711.1__py3-none-any.whl → 0.250720.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.
- MediBot/MediBot_Crosswalk_Library.py +109 -1
- MediLink/MediLink_837p_cob_library.py +862 -0
- MediLink/MediLink_837p_encoder.py +40 -0
- MediLink/MediLink_837p_encoder_library.py +54 -6
- MediLink/MediLink_ClaimStatus.py +4 -3
- MediLink/MediLink_Deductible.py +345 -108
- MediLink/MediLink_Deductible_Validator.py +440 -0
- MediLink/test_cob_library.py +436 -0
- MediLink/test_validation.py +127 -0
- {medicafe-0.250711.1.dist-info → medicafe-0.250720.0.dist-info}/METADATA +1 -1
- {medicafe-0.250711.1.dist-info → medicafe-0.250720.0.dist-info}/RECORD +14 -10
- {medicafe-0.250711.1.dist-info → medicafe-0.250720.0.dist-info}/LICENSE +0 -0
- {medicafe-0.250711.1.dist-info → medicafe-0.250720.0.dist-info}/WHEEL +0 -0
- {medicafe-0.250711.1.dist-info → medicafe-0.250720.0.dist-info}/top_level.txt +0 -0
|
@@ -4,6 +4,8 @@ from datetime import datetime
|
|
|
4
4
|
import MediLink_ConfigLoader
|
|
5
5
|
from MediLink_DataMgmt import parse_fixed_width_data, read_fixed_width_data
|
|
6
6
|
import MediLink_837p_encoder_library
|
|
7
|
+
# TODO (COB ENHANCEMENT): Import COB library when implementing Medicare and secondary claim support
|
|
8
|
+
# import MediLink_837p_cob_library
|
|
7
9
|
#from tqdm import tqdm
|
|
8
10
|
|
|
9
11
|
def format_single_claim(patient_data, config, endpoint, transaction_set_control_number, crosswalk, client):
|
|
@@ -46,7 +48,18 @@ def format_single_claim(patient_data, config, endpoint, transaction_set_control_
|
|
|
46
48
|
|
|
47
49
|
# Subscriber information, possibly including endpoint-specific logic
|
|
48
50
|
segments.extend(MediLink_837p_encoder_library.create_hl_subscriber_segment())
|
|
51
|
+
|
|
52
|
+
# TODO (COB ENHANCEMENT): Enhanced SBR segment creation for COB scenarios
|
|
53
|
+
# Replace the standard SBR segment creation with enhanced COB-aware version
|
|
54
|
+
# Current: segments.append(MediLink_837p_encoder_library.create_sbr_segment(config, patient_data, endpoint))
|
|
55
|
+
# Enhanced:
|
|
56
|
+
# if patient_data.get('claim_type') == 'secondary':
|
|
57
|
+
# enhanced_sbr = MediLink_837p_cob_library.create_enhanced_sbr_segment(patient_data, config, crosswalk)
|
|
58
|
+
# segments.append(enhanced_sbr)
|
|
59
|
+
# else:
|
|
60
|
+
# segments.append(MediLink_837p_encoder_library.create_sbr_segment(config, patient_data, endpoint))
|
|
49
61
|
segments.append(MediLink_837p_encoder_library.create_sbr_segment(config, patient_data, endpoint))
|
|
62
|
+
|
|
50
63
|
segments.append(MediLink_837p_encoder_library.create_nm1_subscriber_segment(config, patient_data, endpoint))
|
|
51
64
|
segments.extend(MediLink_837p_encoder_library.create_subscriber_address_segments(patient_data))
|
|
52
65
|
segments.append(MediLink_837p_encoder_library.create_dmg_segment(patient_data))
|
|
@@ -58,9 +71,36 @@ def format_single_claim(patient_data, config, endpoint, transaction_set_control_
|
|
|
58
71
|
segments.extend([MediLink_837p_encoder_library.create_2010BB_payer_information_segment(patient_data)])
|
|
59
72
|
#segments.extend(MediLink_837p_encoder_library.create_payer_address_segments(config)) OMITTED
|
|
60
73
|
|
|
74
|
+
# TODO (COB ENHANCEMENT): COB processing for secondary claims and Medicare adjudication
|
|
75
|
+
# See MediLink_837p_cob_library.process_cob_claim() for complete COB implementation
|
|
76
|
+
# This would include:
|
|
77
|
+
# - Enhanced SBR segments with Medicare payer types (MB/MA)
|
|
78
|
+
# - 2320 loop for other subscriber information
|
|
79
|
+
# - 2330B loop for prior payer (Medicare) information
|
|
80
|
+
# - 2330C loop when patient != subscriber
|
|
81
|
+
# - 2430 loop for service-level COB adjudication
|
|
82
|
+
# - PWK segments for attachment references
|
|
83
|
+
#
|
|
84
|
+
# Integration point for COB processing:
|
|
85
|
+
# if patient_data.get('claim_type') == 'secondary' or patient_data.get('requires_cob_processing'):
|
|
86
|
+
# cob_segments = MediLink_837p_cob_library.process_cob_claim(patient_data, config, crosswalk, client)
|
|
87
|
+
# segments.extend(cob_segments)
|
|
88
|
+
|
|
61
89
|
# Rendering Provider (2310B Loop)
|
|
62
90
|
segments.extend(MediLink_837p_encoder_library.create_nm1_rendering_provider_segment(config))
|
|
63
91
|
|
|
92
|
+
# TODO (COB ENHANCEMENT): Enhanced CLM segment creation for COB claims
|
|
93
|
+
# Replace standard CLM creation with COB-aware version
|
|
94
|
+
# Current: segments.extend(MediLink_837p_encoder_library.create_clm_and_related_segments(patient_data, config, crosswalk))
|
|
95
|
+
# Enhanced:
|
|
96
|
+
# if patient_data.get('claim_type') == 'secondary':
|
|
97
|
+
# enhanced_clm = MediLink_837p_cob_library.create_enhanced_clm_segment(patient_data, config, crosswalk)
|
|
98
|
+
# segments.append(enhanced_clm)
|
|
99
|
+
# # Add service line segments separately for COB
|
|
100
|
+
# segments.extend(MediLink_837p_encoder_library.create_service_line_segments(patient_data, config, crosswalk))
|
|
101
|
+
# else:
|
|
102
|
+
# segments.extend(MediLink_837p_encoder_library.create_clm_and_related_segments(patient_data, config, crosswalk))
|
|
103
|
+
|
|
64
104
|
# Claim information 2300, 2310C Service Facility and 2400 loop segments
|
|
65
105
|
segments.extend(MediLink_837p_encoder_library.create_clm_and_related_segments(patient_data, config, crosswalk))
|
|
66
106
|
|
|
@@ -159,7 +159,7 @@ def create_1000A_submitter_name_segment(patient_data, config, endpoint):
|
|
|
159
159
|
|
|
160
160
|
# Construct PER segment for the submitter's contact information
|
|
161
161
|
per_segment = "PER*IC*{}*TE*{}~".format(contact_name, contact_telephone_number)
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
return [nm1_segment, per_segment]
|
|
164
164
|
|
|
165
165
|
# Constructs the NM1 segment for the receiver (1000B).
|
|
@@ -539,6 +539,12 @@ def create_sbr_segment(config, parsed_data, endpoint):
|
|
|
539
539
|
# Insurance Type Code
|
|
540
540
|
insurance_type_code = insurance_type_selection(parsed_data)
|
|
541
541
|
|
|
542
|
+
# TODO (COB ENHANCEMENT): Enhanced SBR segment for Medicare and COB support
|
|
543
|
+
# For Medicare Part B: SBR09 = "MB"
|
|
544
|
+
# For Medicare Advantage: SBR09 = "MA"
|
|
545
|
+
# For secondary claims: SBR01 = "S"
|
|
546
|
+
# See MediLink_837p_cob_library.create_enhanced_sbr_segment() for implementation
|
|
547
|
+
|
|
542
548
|
# Construct the SBR segment using the determined codes
|
|
543
549
|
sbr_segment = "SBR*{responsibility_code}*18*******{insurance_type_code}~".format(
|
|
544
550
|
responsibility_code=responsibility_code,
|
|
@@ -591,6 +597,12 @@ def insurance_type_selection(parsed_data):
|
|
|
591
597
|
# Retrieve insurance options with codes and descriptions
|
|
592
598
|
config, _ = MediLink_ConfigLoader.load_configuration()
|
|
593
599
|
insurance_options = config['MediLink_Config'].get('insurance_options')
|
|
600
|
+
|
|
601
|
+
# TODO (COB ENHANCEMENT): Enhanced insurance options for Medicare support
|
|
602
|
+
# See MediLink_837p_cob_library.get_enhanced_insurance_options() for Medicare codes:
|
|
603
|
+
# - MB: Medicare Part B
|
|
604
|
+
# - MA: Medicare Advantage
|
|
605
|
+
# - MC: Medicare Part C
|
|
594
606
|
|
|
595
607
|
def prompt_display_insurance_options():
|
|
596
608
|
# Prompt to display full list
|
|
@@ -705,6 +717,14 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
|
705
717
|
Service Line Information (2400 Loop):
|
|
706
718
|
Verify that the service line number (LX), professional service (SV1), and service date (DTP) segments contain
|
|
707
719
|
accurate information and are formatted according to the claim's details.
|
|
720
|
+
|
|
721
|
+
TODO (COB ENHANCEMENT): This function needs enhancement for COB scenarios:
|
|
722
|
+
1. Enhanced CLM segment with proper claim frequency (CLM05-3)
|
|
723
|
+
2. Support for service-level COB adjudication (2430 loop)
|
|
724
|
+
3. Integration with 835-derived adjudication data
|
|
725
|
+
4. PWK segment support for attachments
|
|
726
|
+
|
|
727
|
+
See MediLink_837p_cob_library.create_enhanced_clm_segment() for enhanced implementation.
|
|
708
728
|
"""
|
|
709
729
|
|
|
710
730
|
segments = []
|
|
@@ -715,15 +735,22 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
|
715
735
|
formatted_claim_number = format_claim_number(chart_number, date_of_service)
|
|
716
736
|
|
|
717
737
|
# CLM - Claim Information
|
|
718
|
-
|
|
738
|
+
# TODO (COB ENHANCEMENT): Enhanced claim frequency handling
|
|
739
|
+
# For COB claims, CLM05-3 should be "1" (original) unless replacement logic applies
|
|
740
|
+
claim_frequency = "1" # Default to original
|
|
741
|
+
# if parsed_data.get('claim_type') == 'secondary':
|
|
742
|
+
# claim_frequency = "1" # Original for secondary claims
|
|
743
|
+
|
|
744
|
+
segments.append("CLM*{}*{}***{}:B:{}*Y*A*Y*Y~".format(
|
|
719
745
|
formatted_claim_number,
|
|
720
746
|
parsed_data['AMOUNT'],
|
|
721
|
-
parsed_data['TOS']
|
|
747
|
+
parsed_data['TOS'],
|
|
748
|
+
claim_frequency))
|
|
722
749
|
|
|
723
750
|
# HI - Health Care Diagnosis Code
|
|
724
751
|
# Hardcoding "ABK" for ICD-10 codes as they are the only ones used now.
|
|
725
752
|
medisoft_code = ''.join(filter(str.isalnum, parsed_data['DIAG']))
|
|
726
|
-
diagnosis_code = next((key for key, value in crosswalk.get('diagnosis_to_medisoft', {}).items() if value == medisoft_code), None)
|
|
753
|
+
diagnosis_code = next((key for key, value in crosswalk.get('diagnosis_to_medisoft', {}).items() if value == medisoft_code), None)
|
|
727
754
|
|
|
728
755
|
if diagnosis_code is None:
|
|
729
756
|
error_message = "Diagnosis code is empty for chart number: {}. Please verify. Medisoft code is {}".format(chart_number, medisoft_code)
|
|
@@ -743,8 +770,21 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
|
743
770
|
segments.extend(create_service_facility_location_npi_segment(config))
|
|
744
771
|
|
|
745
772
|
# For future reference, SBR - (Loop 2320: OI, NM1 (2330A), N3, N4, NM1 (2330B)) - Other Subscriber Information goes here.
|
|
746
|
-
|
|
747
|
-
#
|
|
773
|
+
# TODO (COB ENHANCEMENT): COB loops for secondary claims and Medicare adjudication
|
|
774
|
+
# See MediLink_837p_cob_library for implementation of:
|
|
775
|
+
# - create_2320_other_subscriber_segments() for secondary payer info
|
|
776
|
+
# - create_2330B_prior_payer_segments() for Medicare prior payer
|
|
777
|
+
# - create_2430_service_line_cob_segments() for service-level adjudication
|
|
778
|
+
# - create_2330C_other_subscriber_name_segments() when patient != subscriber
|
|
779
|
+
# TODO (COB ENHANCEMENT): Optional attachment references (PWK) for non-electronic EOB handling
|
|
780
|
+
# See MediLink_837p_cob_library.create_pwk_attachment_segment() for implementation
|
|
781
|
+
# Example: PWK*EB*FX*123456~ for attachment control number
|
|
782
|
+
# if parsed_data.get('requires_attachment'):
|
|
783
|
+
# pwk_segment = MediLink_837p_cob_library.create_pwk_attachment_segment(parsed_data, config)
|
|
784
|
+
# if pwk_segment:
|
|
785
|
+
# segments.append(pwk_segment)
|
|
786
|
+
|
|
787
|
+
# LX - Service Line Counter
|
|
748
788
|
segments.append("LX*1~")
|
|
749
789
|
|
|
750
790
|
# SV1 - Professional Service
|
|
@@ -762,6 +802,14 @@ def create_clm_and_related_segments(parsed_data, config, crosswalk):
|
|
|
762
802
|
# 6R - Provider Control Number (Number assigned by information provider company for tracking and billing purposes)
|
|
763
803
|
# 1 - Reference information as defined for a particular Transaction Set or as specified by the Reference Identification Qualifier
|
|
764
804
|
|
|
805
|
+
|
|
806
|
+
# TODO (COB ENHANCEMENT): Service-level COB adjudication (2430 loop)
|
|
807
|
+
# See MediLink_837p_cob_library.create_2430_service_line_cob_segments() for implementation
|
|
808
|
+
# This would include SVD, CAS, and DTP*573 segments for service-level adjudication
|
|
809
|
+
# if parsed_data.get('service_adjudications'):
|
|
810
|
+
# cob_segments = MediLink_837p_cob_library.create_2430_service_line_cob_segments(parsed_data, config, crosswalk)
|
|
811
|
+
# segments.extend(cob_segments)
|
|
812
|
+
|
|
765
813
|
return segments
|
|
766
814
|
|
|
767
815
|
def get_endpoint_config(config, endpoint):
|
MediLink/MediLink_ClaimStatus.py
CHANGED
|
@@ -21,9 +21,10 @@ start_date_str = start_date.strftime('%m/%d/%Y')
|
|
|
21
21
|
billing_provider_tin = config['MediLink_Config'].get('billing_provider_tin')
|
|
22
22
|
|
|
23
23
|
# Define the list of payer_id's to iterate over
|
|
24
|
-
payer_ids = ['87726']
|
|
25
|
-
# Allowed payer id's for UHC
|
|
26
|
-
# payer_ids = ['87726', '03432', '96385', '95467', '86050', '86047', '95378', '
|
|
24
|
+
payer_ids = ['87726'] # Default Value
|
|
25
|
+
# Allowed payer id's for UHC 87726, 03432, 96385, 95467, 86050, 86047, 95378, 37602. This api does not support payerId 06111.
|
|
26
|
+
# payer_ids = ['87726', '03432', '96385', '95467', '86050', '86047', '95378', '37602']
|
|
27
|
+
# Oddly enough, the API is completely ignoring the payerId parameter and returning the exact same dataset for all payer IDs.
|
|
27
28
|
|
|
28
29
|
# Initialize the API client
|
|
29
30
|
client = MediLink_API_v3.APIClient()
|