hccinfhir 0.1.0__tar.gz → 0.1.2__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 (52) hide show
  1. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/PKG-INFO +102 -24
  2. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/README.md +101 -23
  3. hccinfhir-0.1.2/hccinfhir/__init__.py +47 -0
  4. hccinfhir-0.1.2/hccinfhir/data/ra_coefficients_2026.csv +8414 -0
  5. hccinfhir-0.1.2/hccinfhir/data/ra_dx_to_cc_2026.csv +58986 -0
  6. hccinfhir-0.1.2/hccinfhir/data/ra_eligible_cpt_hcpcs_2026.csv +6748 -0
  7. hccinfhir-0.1.2/hccinfhir/data/ra_hierarchies_2026.csv +725 -0
  8. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/datamodels.py +4 -2
  9. hccinfhir-0.1.2/hccinfhir/filter.py +39 -0
  10. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/hccinfhir.py +6 -5
  11. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_calculate.py +20 -3
  12. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_coefficients.py +3 -1
  13. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_demographics.py +8 -0
  14. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_dx_to_cc.py +1 -1
  15. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_hierarchies.py +26 -22
  16. hccinfhir-0.1.2/hccinfhir/sample_utils.py +252 -0
  17. hccinfhir-0.1.2/hccinfhir/samples.py +252 -0
  18. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/pyproject.toml +1 -1
  19. hccinfhir-0.1.0/hccinfhir/__init__.py +0 -1
  20. hccinfhir-0.1.0/hccinfhir/filter.py +0 -41
  21. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/.gitignore +0 -0
  22. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/LICENSE +0 -0
  23. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/__init__.py +0 -0
  24. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/hcc_is_chronic.csv +0 -0
  25. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_coefficients_2025.csv +0 -0
  26. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_dx_to_cc_2025.csv +0 -0
  27. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv +0 -0
  28. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv +0 -0
  29. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv +0 -0
  30. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/data/ra_hierarchies_2025.csv +0 -0
  31. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/extractor.py +0 -0
  32. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/extractor_837.py +0 -0
  33. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/extractor_fhir.py +0 -0
  34. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/model_interactions.py +0 -0
  35. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/__init__.py +0 -0
  36. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_0.txt +0 -0
  37. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_1.txt +0 -0
  38. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_10.txt +0 -0
  39. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_11.txt +0 -0
  40. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_2.txt +0 -0
  41. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_3.txt +0 -0
  42. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_4.txt +0 -0
  43. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_5.txt +0 -0
  44. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_6.txt +0 -0
  45. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_7.txt +0 -0
  46. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_8.txt +0 -0
  47. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_837_9.txt +0 -0
  48. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_eob_1.json +0 -0
  49. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_eob_2.json +0 -0
  50. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_eob_200.ndjson +0 -0
  51. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/samples/sample_eob_3.json +0 -0
  52. {hccinfhir-0.1.0 → hccinfhir-0.1.2}/hccinfhir/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hccinfhir
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
@@ -69,6 +69,34 @@ result = calculate_raf(
69
69
 
70
70
  For more details on the SLD format, see the `datamodels.py` file.
71
71
 
72
+ ## Sample Data
73
+
74
+ The package includes comprehensive sample data for testing and demonstration purposes:
75
+
76
+ ```python
77
+ from hccinfhir import (
78
+ get_eob_sample,
79
+ get_eob_sample_list,
80
+ get_837_sample,
81
+ get_837_sample_list,
82
+ list_available_samples
83
+ )
84
+
85
+ # Get individual EOB samples (cases 1, 2, or 3)
86
+ eob_data = get_eob_sample(1)
87
+
88
+ # Get multiple EOB samples (up to 200 available)
89
+ eob_list = get_eob_sample_list(limit=10)
90
+
91
+ # Get 837 claim samples (cases 0 through 11)
92
+ claim_data = get_837_sample(0)
93
+
94
+ # Get information about available samples
95
+ info = list_available_samples()
96
+ ```
97
+
98
+ For detailed usage examples, see the `examples/sample_data_usage.py` file.
99
+
72
100
  ## Core Components
73
101
 
74
102
  ### 1. Extractor Module
@@ -182,10 +210,12 @@ Each method returns a RAFResult containing:
182
210
  - Processed service level data (when applicable)
183
211
 
184
212
  ## Testing
213
+
214
+ After installing `hatch`
185
215
  ```bash
186
- $ python3 -m hatch shell
187
- $ python3 -m pip install -e .
188
- $ python3 -m pytest tests/*
216
+ $ hatch shell
217
+ $ pip install -e .
218
+ $ pytest tests/*
189
219
  ```
190
220
 
191
221
  ## Dependencies
@@ -267,45 +297,93 @@ $ python3 -m pytest tests/*
267
297
 
268
298
  ## Data Files
269
299
 
270
- `ra_dx_to_cc_mapping_2025.csv`
300
+ `ra_dx_to_cc_mapping_2026.csv`
271
301
  ```sql
272
- SELECT diagnosis_code, cc, model_name
273
- FROM ra_dx_to_cc_mapping
274
- WHERE year = 2025 and model_type = 'Initial';
302
+ WITH latest_years AS (
303
+ SELECT
304
+ model_name,
305
+ MAX(year) as latest_year
306
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping
307
+ WHERE model_type = 'Initial'
308
+ AND year <= 2026 -- Don't go beyond 2026
309
+ GROUP BY model_name
310
+ )
311
+ SELECT
312
+ r.diagnosis_code,
313
+ r.cc,
314
+ r.model_name
315
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping r
316
+ INNER JOIN latest_years l
317
+ ON r.model_name = l.model_name
318
+ AND r.year = l.latest_year
319
+ WHERE r.model_type = 'Initial'
320
+ ORDER BY r.model_name, r.diagnosis_code;
275
321
  ```
276
322
 
277
- `ra_hierarchies_2025.csv`
323
+ `ra_hierarchies_2026.csv`
278
324
  ```sql
279
- SELECT cc_parent,
280
- cc_child,
281
- model_domain,
282
- model_version,
283
- model_fullname
284
- FROM ra_hierarchies
285
- WHERE eff_last_date > '2025-01-01';
325
+ WITH latest_dates AS (
326
+ SELECT
327
+ model_domain,
328
+ model_version,
329
+ model_fullname,
330
+ MAX(eff_last_date) as latest_eff_last_date
331
+ FROM mimi_ws_1.cmspayment.ra_hierarchies
332
+ GROUP BY model_domain, model_version, model_fullname
333
+ )
334
+ SELECT
335
+ r.cc_parent,
336
+ r.cc_child,
337
+ r.model_domain,
338
+ r.model_version,
339
+ r.model_fullname
340
+ FROM mimi_ws_1.cmspayment.ra_hierarchies r
341
+ INNER JOIN latest_dates l
342
+ ON r.model_domain = l.model_domain
343
+ AND r.model_version = l.model_version
344
+ AND r.model_fullname = l.model_fullname
345
+ AND r.eff_last_date = l.latest_eff_last_date
346
+ ORDER BY r.model_domain, r.model_version, r.model_fullname, r.cc_parent, r.cc_child;
286
347
  ```
287
348
 
288
- `ra_coefficients_2025.csv`
349
+ `ra_coefficients_2026.csv`
289
350
  ```sql
290
- SELECT coefficient, value, model_domain, model_version
291
- FROM ra_coefficients
292
- WHERE eff_last_date > '2025-01-01';
351
+ WITH preferred_records AS (
352
+ SELECT
353
+ model_domain,
354
+ model_version,
355
+ MAX(eff_last_date) as latest_eff_last_date
356
+ FROM mimi_ws_1.cmspayment.ra_coefficients
357
+ GROUP BY model_domain, model_version
358
+ )
359
+ SELECT
360
+ r.coefficient,
361
+ r.value,
362
+ r.model_domain,
363
+ r.model_version
364
+ FROM mimi_ws_1.cmspayment.ra_coefficients r
365
+ INNER JOIN preferred_records p
366
+ ON r.model_domain = p.model_domain
367
+ AND r.model_version = p.model_version
368
+ AND r.eff_last_date = p.latest_eff_last_date
369
+ ORDER BY r.model_domain, r.model_version, r.coefficient;
293
370
  ```
294
371
 
295
- `ra_eligible_cpt_hcpcs_2025.csv`
372
+ `ra_eligible_cpt_hcpcs_2026.csv`
296
373
  ```sql
297
374
  SELECT DISTINCT cpt_hcpcs_code
298
375
  FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
299
- WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
376
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2025;
300
377
  ```
301
378
 
302
379
  ## Contributing
303
380
  Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
304
381
 
305
382
  ## Publishing (only for those maintainers...)
383
+ Inside the hatch
306
384
  ```bash
307
- $ python3 -m hatch build
308
- $ python3 -m hatch publish
385
+ $ hatch build
386
+ $ hatch publish
309
387
  ```
310
388
 
311
389
  ## License
@@ -55,6 +55,34 @@ result = calculate_raf(
55
55
 
56
56
  For more details on the SLD format, see the `datamodels.py` file.
57
57
 
58
+ ## Sample Data
59
+
60
+ The package includes comprehensive sample data for testing and demonstration purposes:
61
+
62
+ ```python
63
+ from hccinfhir import (
64
+ get_eob_sample,
65
+ get_eob_sample_list,
66
+ get_837_sample,
67
+ get_837_sample_list,
68
+ list_available_samples
69
+ )
70
+
71
+ # Get individual EOB samples (cases 1, 2, or 3)
72
+ eob_data = get_eob_sample(1)
73
+
74
+ # Get multiple EOB samples (up to 200 available)
75
+ eob_list = get_eob_sample_list(limit=10)
76
+
77
+ # Get 837 claim samples (cases 0 through 11)
78
+ claim_data = get_837_sample(0)
79
+
80
+ # Get information about available samples
81
+ info = list_available_samples()
82
+ ```
83
+
84
+ For detailed usage examples, see the `examples/sample_data_usage.py` file.
85
+
58
86
  ## Core Components
59
87
 
60
88
  ### 1. Extractor Module
@@ -168,10 +196,12 @@ Each method returns a RAFResult containing:
168
196
  - Processed service level data (when applicable)
169
197
 
170
198
  ## Testing
199
+
200
+ After installing `hatch`
171
201
  ```bash
172
- $ python3 -m hatch shell
173
- $ python3 -m pip install -e .
174
- $ python3 -m pytest tests/*
202
+ $ hatch shell
203
+ $ pip install -e .
204
+ $ pytest tests/*
175
205
  ```
176
206
 
177
207
  ## Dependencies
@@ -253,45 +283,93 @@ $ python3 -m pytest tests/*
253
283
 
254
284
  ## Data Files
255
285
 
256
- `ra_dx_to_cc_mapping_2025.csv`
286
+ `ra_dx_to_cc_mapping_2026.csv`
257
287
  ```sql
258
- SELECT diagnosis_code, cc, model_name
259
- FROM ra_dx_to_cc_mapping
260
- WHERE year = 2025 and model_type = 'Initial';
288
+ WITH latest_years AS (
289
+ SELECT
290
+ model_name,
291
+ MAX(year) as latest_year
292
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping
293
+ WHERE model_type = 'Initial'
294
+ AND year <= 2026 -- Don't go beyond 2026
295
+ GROUP BY model_name
296
+ )
297
+ SELECT
298
+ r.diagnosis_code,
299
+ r.cc,
300
+ r.model_name
301
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping r
302
+ INNER JOIN latest_years l
303
+ ON r.model_name = l.model_name
304
+ AND r.year = l.latest_year
305
+ WHERE r.model_type = 'Initial'
306
+ ORDER BY r.model_name, r.diagnosis_code;
261
307
  ```
262
308
 
263
- `ra_hierarchies_2025.csv`
309
+ `ra_hierarchies_2026.csv`
264
310
  ```sql
265
- SELECT cc_parent,
266
- cc_child,
267
- model_domain,
268
- model_version,
269
- model_fullname
270
- FROM ra_hierarchies
271
- WHERE eff_last_date > '2025-01-01';
311
+ WITH latest_dates AS (
312
+ SELECT
313
+ model_domain,
314
+ model_version,
315
+ model_fullname,
316
+ MAX(eff_last_date) as latest_eff_last_date
317
+ FROM mimi_ws_1.cmspayment.ra_hierarchies
318
+ GROUP BY model_domain, model_version, model_fullname
319
+ )
320
+ SELECT
321
+ r.cc_parent,
322
+ r.cc_child,
323
+ r.model_domain,
324
+ r.model_version,
325
+ r.model_fullname
326
+ FROM mimi_ws_1.cmspayment.ra_hierarchies r
327
+ INNER JOIN latest_dates l
328
+ ON r.model_domain = l.model_domain
329
+ AND r.model_version = l.model_version
330
+ AND r.model_fullname = l.model_fullname
331
+ AND r.eff_last_date = l.latest_eff_last_date
332
+ ORDER BY r.model_domain, r.model_version, r.model_fullname, r.cc_parent, r.cc_child;
272
333
  ```
273
334
 
274
- `ra_coefficients_2025.csv`
335
+ `ra_coefficients_2026.csv`
275
336
  ```sql
276
- SELECT coefficient, value, model_domain, model_version
277
- FROM ra_coefficients
278
- WHERE eff_last_date > '2025-01-01';
337
+ WITH preferred_records AS (
338
+ SELECT
339
+ model_domain,
340
+ model_version,
341
+ MAX(eff_last_date) as latest_eff_last_date
342
+ FROM mimi_ws_1.cmspayment.ra_coefficients
343
+ GROUP BY model_domain, model_version
344
+ )
345
+ SELECT
346
+ r.coefficient,
347
+ r.value,
348
+ r.model_domain,
349
+ r.model_version
350
+ FROM mimi_ws_1.cmspayment.ra_coefficients r
351
+ INNER JOIN preferred_records p
352
+ ON r.model_domain = p.model_domain
353
+ AND r.model_version = p.model_version
354
+ AND r.eff_last_date = p.latest_eff_last_date
355
+ ORDER BY r.model_domain, r.model_version, r.coefficient;
279
356
  ```
280
357
 
281
- `ra_eligible_cpt_hcpcs_2025.csv`
358
+ `ra_eligible_cpt_hcpcs_2026.csv`
282
359
  ```sql
283
360
  SELECT DISTINCT cpt_hcpcs_code
284
361
  FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
285
- WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2024;
362
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2025;
286
363
  ```
287
364
 
288
365
  ## Contributing
289
366
  Join us at [mimilabs](https://mimilabs.ai/signup). Reference data available in MIMILabs data lakehouse.
290
367
 
291
368
  ## Publishing (only for those maintainers...)
369
+ Inside the hatch
292
370
  ```bash
293
- $ python3 -m hatch build
294
- $ python3 -m hatch publish
371
+ $ hatch build
372
+ $ hatch publish
295
373
  ```
296
374
 
297
375
  ## License
@@ -0,0 +1,47 @@
1
+ """
2
+ HCCInFHIR - HCC Algorithm for FHIR Resources
3
+
4
+ A Python library for processing FHIR EOB resources and calculating HCC risk scores.
5
+ """
6
+
7
+ # Main classes
8
+ from .hccinfhir import HCCInFHIR
9
+ from .extractor import extract_sld, extract_sld_list
10
+ from .filter import apply_filter
11
+ from .model_calculate import calculate_raf
12
+ from .datamodels import Demographics, ServiceLevelData, RAFResult, ModelName
13
+
14
+ # Sample data functions
15
+ from .sample_utils import (
16
+ SampleData,
17
+ get_eob_sample,
18
+ get_eob_sample_list,
19
+ get_837_sample,
20
+ get_837_sample_list,
21
+ list_available_samples
22
+ )
23
+
24
+ __version__ = "0.1.2"
25
+ __author__ = "Yubin Park"
26
+ __email__ = "yubin.park@mimilabs.ai"
27
+
28
+ __all__ = [
29
+ # Main classes
30
+ "HCCInFHIR",
31
+ "extract_sld",
32
+ "extract_sld_list",
33
+ "apply_filter",
34
+ "calculate_raf",
35
+ "Demographics",
36
+ "ServiceLevelData",
37
+ "RAFResult",
38
+ "ModelName",
39
+
40
+ # Sample data
41
+ "SampleData",
42
+ "get_eob_sample",
43
+ "get_eob_sample_list",
44
+ "get_837_sample",
45
+ "get_837_sample_list",
46
+ "list_available_samples"
47
+ ]