hccinfhir 0.0.4__tar.gz → 0.0.6__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.
Files changed (44) hide show
  1. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/PKG-INFO +80 -5
  2. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/README.md +79 -4
  3. hccinfhir-0.0.6/hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv +6697 -0
  4. hccinfhir-0.0.6/hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv +6725 -0
  5. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/datamodels.py +37 -20
  6. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/filter.py +2 -4
  7. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/hccinfhir.py +52 -45
  8. hccinfhir-0.0.6/hccinfhir/model_calculate.py +95 -0
  9. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/model_dx_to_cc.py +8 -24
  10. hccinfhir-0.0.6/hccinfhir/utils.py +51 -0
  11. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/pyproject.toml +1 -1
  12. hccinfhir-0.0.4/hccinfhir/model_calculate.py +0 -50
  13. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/.gitignore +0 -0
  14. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/LICENSE +0 -0
  15. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/__init__.py +0 -0
  16. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/data/__init__.py +0 -0
  17. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/data/ra_coefficients_2025.csv +0 -0
  18. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/data/ra_dx_to_cc_2025.csv +0 -0
  19. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv +0 -0
  20. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/data/ra_hierarchies_2025.csv +0 -0
  21. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/extractor.py +0 -0
  22. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/extractor_837.py +0 -0
  23. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/extractor_fhir.py +0 -0
  24. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/model_coefficients.py +0 -0
  25. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/model_demographics.py +0 -0
  26. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/model_hierarchies.py +0 -0
  27. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/model_interactions.py +0 -0
  28. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/__init__.py +0 -0
  29. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_0.txt +0 -0
  30. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_1.txt +0 -0
  31. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_10.txt +0 -0
  32. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_11.txt +0 -0
  33. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_2.txt +0 -0
  34. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_3.txt +0 -0
  35. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_4.txt +0 -0
  36. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_5.txt +0 -0
  37. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_6.txt +0 -0
  38. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_7.txt +0 -0
  39. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_8.txt +0 -0
  40. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_837_9.txt +0 -0
  41. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_eob_1.json +0 -0
  42. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_eob_2.json +0 -0
  43. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/hccinfhir/samples/sample_eob_200.ndjson +0 -0
  44. {hccinfhir-0.0.4 → hccinfhir-0.0.6}/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.4
3
+ Version: 0.0.6
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,75 @@ result = calculate_raf(
109
112
  )
110
113
  ```
111
114
 
112
- ### 4. Running HCC on FHIR data
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
+ )
129
+
130
+ # Define beneficiary demographics
131
+ demographics = {
132
+ age=67,
133
+ sex='F'
134
+ }
116
135
 
117
- hcc_processor = HCCInFHIR()
136
+ # Method 1: Process FHIR EOB resources
137
+ raf_result = hcc_processor.run(eob_list, demographics)
118
138
 
119
- result = hcc_processor.run(eob_list, demographic_data)
139
+ # Method 2: Process service level data
140
+ service_data = [{
141
+ "procedure_code": "99214",
142
+ "claim_diagnosis_codes": ["E11.9", "I10"],
143
+ "claim_type": "71",
144
+ "service_date": "2024-01-15"
145
+ }]
146
+ raf_result = hcc_processor.run_from_service_data(service_data, demographics)
147
+
148
+ # Method 3: Direct diagnosis processing
149
+ diagnosis_codes = ['E119', 'I509']
150
+ raf_result = hcc_processor.calculate_from_diagnosis(diagnosis_codes, demographics)
151
+
152
+ # RAF Result contains:
153
+ print(f"Risk Score: {raf_result['risk_score']}")
154
+ print(f"HCC List: {raf_result['hcc_list']}")
155
+ print(f"CC to Diagnosis Mapping: {raf_result['cc_to_dx']}")
156
+ print(f"Applied Coefficients: {raf_result['coefficients']}")
157
+ print(f"Applied Interactions: {raf_result['interactions']}")
120
158
  ```
121
159
 
160
+ The HCCInFHIR class provides three main processing methods:
161
+
162
+ 1. `run(eob_list, demographics)`: Process FHIR ExplanationOfBenefit resources
163
+ - Extracts service data from FHIR resources
164
+ - Applies filtering rules if enabled
165
+ - Calculates RAF scores using the specified model
166
+
167
+ 2. `run_from_service_data(service_data, demographics)`: Process standardized service data
168
+ - Accepts pre-formatted service level data
169
+ - Validates data structure using Pydantic models
170
+ - Applies filtering and calculates RAF scores
171
+
172
+ 3. `calculate_from_diagnosis(diagnosis_codes, demographics)`: Direct diagnosis processing
173
+ - Processes raw diagnosis codes without service context
174
+ - Useful for quick RAF calculations or validation
175
+ - Bypasses service-level filtering
176
+
177
+ Each method returns a RAFResult containing:
178
+ - Final risk score
179
+ - List of HCCs
180
+ - Mapping of condition categories to diagnosis codes
181
+ - Applied coefficients and interactions
182
+ - Processed service level data (when applicable)
183
+
122
184
  ## Testing
123
185
  ```bash
124
186
  $ python3 -m hatch shell
@@ -230,8 +292,21 @@ FROM ra_coefficients
230
292
  WHERE eff_last_date > '2025-01-01';
231
293
  ```
232
294
 
295
+ `ra_eligible_cpt_hcpcs_2025.csv`
296
+ ```sql
297
+ SELECT DISTINCT cpt_hcpcs_code
298
+ FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
299
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
300
+ ```
301
+
233
302
  ## Contributing
234
303
  Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
235
304
 
305
+ ## Publishing (only for those maintainers...)
306
+ ```bash
307
+ $ python3 -m hatch build
308
+ $ python3 -m hatch publish
309
+ ```
310
+
236
311
  ## License
237
312
  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,75 @@ result = calculate_raf(
95
98
  )
96
99
  ```
97
100
 
98
- ### 4. Running HCC on FHIR data
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
+ )
115
+
116
+ # Define beneficiary demographics
117
+ demographics = {
118
+ age=67,
119
+ sex='F'
120
+ }
102
121
 
103
- hcc_processor = HCCInFHIR()
122
+ # Method 1: Process FHIR EOB resources
123
+ raf_result = hcc_processor.run(eob_list, demographics)
104
124
 
105
- result = hcc_processor.run(eob_list, demographic_data)
125
+ # Method 2: Process service level data
126
+ service_data = [{
127
+ "procedure_code": "99214",
128
+ "claim_diagnosis_codes": ["E11.9", "I10"],
129
+ "claim_type": "71",
130
+ "service_date": "2024-01-15"
131
+ }]
132
+ raf_result = hcc_processor.run_from_service_data(service_data, demographics)
133
+
134
+ # Method 3: Direct diagnosis processing
135
+ diagnosis_codes = ['E119', 'I509']
136
+ raf_result = hcc_processor.calculate_from_diagnosis(diagnosis_codes, demographics)
137
+
138
+ # RAF Result contains:
139
+ print(f"Risk Score: {raf_result['risk_score']}")
140
+ print(f"HCC List: {raf_result['hcc_list']}")
141
+ print(f"CC to Diagnosis Mapping: {raf_result['cc_to_dx']}")
142
+ print(f"Applied Coefficients: {raf_result['coefficients']}")
143
+ print(f"Applied Interactions: {raf_result['interactions']}")
106
144
  ```
107
145
 
146
+ The HCCInFHIR class provides three main processing methods:
147
+
148
+ 1. `run(eob_list, demographics)`: Process FHIR ExplanationOfBenefit resources
149
+ - Extracts service data from FHIR resources
150
+ - Applies filtering rules if enabled
151
+ - Calculates RAF scores using the specified model
152
+
153
+ 2. `run_from_service_data(service_data, demographics)`: Process standardized service data
154
+ - Accepts pre-formatted service level data
155
+ - Validates data structure using Pydantic models
156
+ - Applies filtering and calculates RAF scores
157
+
158
+ 3. `calculate_from_diagnosis(diagnosis_codes, demographics)`: Direct diagnosis processing
159
+ - Processes raw diagnosis codes without service context
160
+ - Useful for quick RAF calculations or validation
161
+ - Bypasses service-level filtering
162
+
163
+ Each method returns a RAFResult containing:
164
+ - Final risk score
165
+ - List of HCCs
166
+ - Mapping of condition categories to diagnosis codes
167
+ - Applied coefficients and interactions
168
+ - Processed service level data (when applicable)
169
+
108
170
  ## Testing
109
171
  ```bash
110
172
  $ python3 -m hatch shell
@@ -216,8 +278,21 @@ FROM ra_coefficients
216
278
  WHERE eff_last_date > '2025-01-01';
217
279
  ```
218
280
 
281
+ `ra_eligible_cpt_hcpcs_2025.csv`
282
+ ```sql
283
+ SELECT DISTINCT cpt_hcpcs_code
284
+ FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
285
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
286
+ ```
287
+
219
288
  ## Contributing
220
289
  Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
221
290
 
291
+ ## Publishing (only for those maintainers...)
292
+ ```bash
293
+ $ python3 -m hatch build
294
+ $ python3 -m hatch publish
295
+ ```
296
+
222
297
  ## License
223
298
  Apache License 2.0