hccinfhir 0.0.4__tar.gz → 0.0.5__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.
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/PKG-INFO +85 -5
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/README.md +84 -4
- hccinfhir-0.0.5/hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv +6697 -0
- hccinfhir-0.0.5/hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv +6725 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/datamodels.py +20 -3
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/filter.py +2 -4
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/hccinfhir.py +52 -45
- hccinfhir-0.0.5/hccinfhir/model_calculate.py +95 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/model_dx_to_cc.py +8 -24
- hccinfhir-0.0.5/hccinfhir/utils.py +51 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/pyproject.toml +1 -1
- hccinfhir-0.0.4/hccinfhir/model_calculate.py +0 -50
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/.gitignore +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/LICENSE +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/__init__.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/data/__init__.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/data/ra_coefficients_2025.csv +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/data/ra_dx_to_cc_2025.csv +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/data/ra_hierarchies_2025.csv +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/extractor.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/extractor_837.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/extractor_fhir.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/model_coefficients.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/model_demographics.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/model_hierarchies.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/model_interactions.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/__init__.py +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_0.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_1.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_10.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_11.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_2.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_3.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_4.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_5.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_6.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_7.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_8.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_837_9.txt +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_eob_1.json +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_eob_2.json +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_eob_200.ndjson +0 -0
- {hccinfhir-0.0.4 → hccinfhir-0.0.5}/hccinfhir/samples/sample_eob_3.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: hccinfhir
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: HCC Algorithm for FHIR Resources
|
|
5
5
|
Project-URL: Homepage, https://github.com/mimilabs/hccinfhir
|
|
6
6
|
Project-URL: Issues, https://github.com/mimilabs/hccinfhir/issues
|
|
@@ -20,6 +20,9 @@ A Python library for extracting standardized service-level data from FHIR Explan
|
|
|
20
20
|
- Support for both BCDA (Blue Button 2.0) and standard FHIR R4 formats
|
|
21
21
|
- Pydantic models for type safety and data validation
|
|
22
22
|
- Standardized Service Level Data (SLD) output format
|
|
23
|
+
- Multiple HCC model support (V22, V24, V28, ESRD V21, ESRD V24, RxHCC V08)
|
|
24
|
+
- Flexible input options: FHIR EOBs, service data, or direct diagnosis codes
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
## Installation
|
|
25
28
|
```bash
|
|
@@ -109,16 +112,80 @@ result = calculate_raf(
|
|
|
109
112
|
)
|
|
110
113
|
```
|
|
111
114
|
|
|
112
|
-
### 4.
|
|
115
|
+
### 4. HCCInFHIR Class
|
|
116
|
+
The main processor class that integrates extraction, filtering, and calculation components:
|
|
113
117
|
|
|
114
118
|
```python
|
|
115
|
-
from hccinfhir import HCCInFHIR
|
|
119
|
+
from hccinfhir.hccinfhir import HCCInFHIR
|
|
120
|
+
from hccinfhir.datamodels import Demographics
|
|
121
|
+
|
|
122
|
+
# Initialize with custom configuration
|
|
123
|
+
hcc_processor = HCCInFHIR(
|
|
124
|
+
filter_claims=True, # Enable claim filtering
|
|
125
|
+
model_name="CMS-HCC Model V28", # Choose HCC model version
|
|
126
|
+
proc_filtering_filename="ra_eligible_cpt_hcpcs_2025.csv", # CPT/HCPCS filtering rules
|
|
127
|
+
dx_cc_mapping_filename="ra_dx_to_cc_2025.csv" # Diagnosis to CC mapping
|
|
128
|
+
)
|
|
116
129
|
|
|
117
|
-
|
|
130
|
+
# Define beneficiary demographics
|
|
131
|
+
demographics = Demographics(
|
|
132
|
+
age=67,
|
|
133
|
+
sex='F',
|
|
134
|
+
dual_elgbl_cd='00', # Not dual eligible
|
|
135
|
+
orec='0', # Old age
|
|
136
|
+
crec='0', # Current old age
|
|
137
|
+
new_enrollee=False,
|
|
138
|
+
snp=False
|
|
139
|
+
)
|
|
118
140
|
|
|
119
|
-
|
|
141
|
+
# Method 1: Process FHIR EOB resources
|
|
142
|
+
raf_result = hcc_processor.run(eob_list, demographics)
|
|
143
|
+
|
|
144
|
+
# Method 2: Process service level data
|
|
145
|
+
service_data = [{
|
|
146
|
+
"procedure_code": "99214",
|
|
147
|
+
"claim_diagnosis_codes": ["E11.9", "I10"],
|
|
148
|
+
"claim_type": "71",
|
|
149
|
+
"service_date": "2024-01-15"
|
|
150
|
+
}]
|
|
151
|
+
raf_result = hcc_processor.run_from_service_data(service_data, demographics)
|
|
152
|
+
|
|
153
|
+
# Method 3: Direct diagnosis processing
|
|
154
|
+
diagnosis_codes = ['E119', 'I509']
|
|
155
|
+
raf_result = hcc_processor.calculate_from_diagnosis(diagnosis_codes, demographics)
|
|
156
|
+
|
|
157
|
+
# RAF Result contains:
|
|
158
|
+
print(f"Risk Score: {raf_result['risk_score']}")
|
|
159
|
+
print(f"HCC List: {raf_result['hcc_list']}")
|
|
160
|
+
print(f"CC to Diagnosis Mapping: {raf_result['cc_to_dx']}")
|
|
161
|
+
print(f"Applied Coefficients: {raf_result['coefficients']}")
|
|
162
|
+
print(f"Applied Interactions: {raf_result['interactions']}")
|
|
120
163
|
```
|
|
121
164
|
|
|
165
|
+
The HCCInFHIR class provides three main processing methods:
|
|
166
|
+
|
|
167
|
+
1. `run(eob_list, demographics)`: Process FHIR ExplanationOfBenefit resources
|
|
168
|
+
- Extracts service data from FHIR resources
|
|
169
|
+
- Applies filtering rules if enabled
|
|
170
|
+
- Calculates RAF scores using the specified model
|
|
171
|
+
|
|
172
|
+
2. `run_from_service_data(service_data, demographics)`: Process standardized service data
|
|
173
|
+
- Accepts pre-formatted service level data
|
|
174
|
+
- Validates data structure using Pydantic models
|
|
175
|
+
- Applies filtering and calculates RAF scores
|
|
176
|
+
|
|
177
|
+
3. `calculate_from_diagnosis(diagnosis_codes, demographics)`: Direct diagnosis processing
|
|
178
|
+
- Processes raw diagnosis codes without service context
|
|
179
|
+
- Useful for quick RAF calculations or validation
|
|
180
|
+
- Bypasses service-level filtering
|
|
181
|
+
|
|
182
|
+
Each method returns a RAFResult containing:
|
|
183
|
+
- Final risk score
|
|
184
|
+
- List of HCCs
|
|
185
|
+
- Mapping of condition categories to diagnosis codes
|
|
186
|
+
- Applied coefficients and interactions
|
|
187
|
+
- Processed service level data (when applicable)
|
|
188
|
+
|
|
122
189
|
## Testing
|
|
123
190
|
```bash
|
|
124
191
|
$ python3 -m hatch shell
|
|
@@ -230,8 +297,21 @@ FROM ra_coefficients
|
|
|
230
297
|
WHERE eff_last_date > '2025-01-01';
|
|
231
298
|
```
|
|
232
299
|
|
|
300
|
+
`ra_eligible_cpt_hcpcs_2025.csv`
|
|
301
|
+
```sql
|
|
302
|
+
SELECT DISTINCT cpt_hcpcs_code
|
|
303
|
+
FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
|
|
304
|
+
WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
|
|
305
|
+
```
|
|
306
|
+
|
|
233
307
|
## Contributing
|
|
234
308
|
Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
|
|
235
309
|
|
|
310
|
+
## Publishing (only for those maintainers...)
|
|
311
|
+
```bash
|
|
312
|
+
$ hatch build
|
|
313
|
+
$ hatch publish
|
|
314
|
+
```
|
|
315
|
+
|
|
236
316
|
## License
|
|
237
317
|
Apache License 2.0
|
|
@@ -6,6 +6,9 @@ A Python library for extracting standardized service-level data from FHIR Explan
|
|
|
6
6
|
- Support for both BCDA (Blue Button 2.0) and standard FHIR R4 formats
|
|
7
7
|
- Pydantic models for type safety and data validation
|
|
8
8
|
- Standardized Service Level Data (SLD) output format
|
|
9
|
+
- Multiple HCC model support (V22, V24, V28, ESRD V21, ESRD V24, RxHCC V08)
|
|
10
|
+
- Flexible input options: FHIR EOBs, service data, or direct diagnosis codes
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
## Installation
|
|
11
14
|
```bash
|
|
@@ -95,16 +98,80 @@ result = calculate_raf(
|
|
|
95
98
|
)
|
|
96
99
|
```
|
|
97
100
|
|
|
98
|
-
### 4.
|
|
101
|
+
### 4. HCCInFHIR Class
|
|
102
|
+
The main processor class that integrates extraction, filtering, and calculation components:
|
|
99
103
|
|
|
100
104
|
```python
|
|
101
|
-
from hccinfhir import HCCInFHIR
|
|
105
|
+
from hccinfhir.hccinfhir import HCCInFHIR
|
|
106
|
+
from hccinfhir.datamodels import Demographics
|
|
107
|
+
|
|
108
|
+
# Initialize with custom configuration
|
|
109
|
+
hcc_processor = HCCInFHIR(
|
|
110
|
+
filter_claims=True, # Enable claim filtering
|
|
111
|
+
model_name="CMS-HCC Model V28", # Choose HCC model version
|
|
112
|
+
proc_filtering_filename="ra_eligible_cpt_hcpcs_2025.csv", # CPT/HCPCS filtering rules
|
|
113
|
+
dx_cc_mapping_filename="ra_dx_to_cc_2025.csv" # Diagnosis to CC mapping
|
|
114
|
+
)
|
|
102
115
|
|
|
103
|
-
|
|
116
|
+
# Define beneficiary demographics
|
|
117
|
+
demographics = Demographics(
|
|
118
|
+
age=67,
|
|
119
|
+
sex='F',
|
|
120
|
+
dual_elgbl_cd='00', # Not dual eligible
|
|
121
|
+
orec='0', # Old age
|
|
122
|
+
crec='0', # Current old age
|
|
123
|
+
new_enrollee=False,
|
|
124
|
+
snp=False
|
|
125
|
+
)
|
|
104
126
|
|
|
105
|
-
|
|
127
|
+
# Method 1: Process FHIR EOB resources
|
|
128
|
+
raf_result = hcc_processor.run(eob_list, demographics)
|
|
129
|
+
|
|
130
|
+
# Method 2: Process service level data
|
|
131
|
+
service_data = [{
|
|
132
|
+
"procedure_code": "99214",
|
|
133
|
+
"claim_diagnosis_codes": ["E11.9", "I10"],
|
|
134
|
+
"claim_type": "71",
|
|
135
|
+
"service_date": "2024-01-15"
|
|
136
|
+
}]
|
|
137
|
+
raf_result = hcc_processor.run_from_service_data(service_data, demographics)
|
|
138
|
+
|
|
139
|
+
# Method 3: Direct diagnosis processing
|
|
140
|
+
diagnosis_codes = ['E119', 'I509']
|
|
141
|
+
raf_result = hcc_processor.calculate_from_diagnosis(diagnosis_codes, demographics)
|
|
142
|
+
|
|
143
|
+
# RAF Result contains:
|
|
144
|
+
print(f"Risk Score: {raf_result['risk_score']}")
|
|
145
|
+
print(f"HCC List: {raf_result['hcc_list']}")
|
|
146
|
+
print(f"CC to Diagnosis Mapping: {raf_result['cc_to_dx']}")
|
|
147
|
+
print(f"Applied Coefficients: {raf_result['coefficients']}")
|
|
148
|
+
print(f"Applied Interactions: {raf_result['interactions']}")
|
|
106
149
|
```
|
|
107
150
|
|
|
151
|
+
The HCCInFHIR class provides three main processing methods:
|
|
152
|
+
|
|
153
|
+
1. `run(eob_list, demographics)`: Process FHIR ExplanationOfBenefit resources
|
|
154
|
+
- Extracts service data from FHIR resources
|
|
155
|
+
- Applies filtering rules if enabled
|
|
156
|
+
- Calculates RAF scores using the specified model
|
|
157
|
+
|
|
158
|
+
2. `run_from_service_data(service_data, demographics)`: Process standardized service data
|
|
159
|
+
- Accepts pre-formatted service level data
|
|
160
|
+
- Validates data structure using Pydantic models
|
|
161
|
+
- Applies filtering and calculates RAF scores
|
|
162
|
+
|
|
163
|
+
3. `calculate_from_diagnosis(diagnosis_codes, demographics)`: Direct diagnosis processing
|
|
164
|
+
- Processes raw diagnosis codes without service context
|
|
165
|
+
- Useful for quick RAF calculations or validation
|
|
166
|
+
- Bypasses service-level filtering
|
|
167
|
+
|
|
168
|
+
Each method returns a RAFResult containing:
|
|
169
|
+
- Final risk score
|
|
170
|
+
- List of HCCs
|
|
171
|
+
- Mapping of condition categories to diagnosis codes
|
|
172
|
+
- Applied coefficients and interactions
|
|
173
|
+
- Processed service level data (when applicable)
|
|
174
|
+
|
|
108
175
|
## Testing
|
|
109
176
|
```bash
|
|
110
177
|
$ python3 -m hatch shell
|
|
@@ -216,8 +283,21 @@ FROM ra_coefficients
|
|
|
216
283
|
WHERE eff_last_date > '2025-01-01';
|
|
217
284
|
```
|
|
218
285
|
|
|
286
|
+
`ra_eligible_cpt_hcpcs_2025.csv`
|
|
287
|
+
```sql
|
|
288
|
+
SELECT DISTINCT cpt_hcpcs_code
|
|
289
|
+
FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
|
|
290
|
+
WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
|
|
291
|
+
```
|
|
292
|
+
|
|
219
293
|
## Contributing
|
|
220
294
|
Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
|
|
221
295
|
|
|
296
|
+
## Publishing (only for those maintainers...)
|
|
297
|
+
```bash
|
|
298
|
+
$ hatch build
|
|
299
|
+
$ hatch publish
|
|
300
|
+
```
|
|
301
|
+
|
|
222
302
|
## License
|
|
223
303
|
Apache License 2.0
|