hccinfhir 0.1.4__tar.gz → 0.1.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.
Files changed (50) hide show
  1. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/PKG-INFO +93 -11
  2. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/README.md +92 -10
  3. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/__init__.py +1 -1
  4. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_calculate.py +5 -1
  5. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/pyproject.toml +1 -1
  6. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/.gitignore +0 -0
  7. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/LICENSE +0 -0
  8. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/__init__.py +0 -0
  9. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/hcc_is_chronic.csv +0 -0
  10. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_coefficients_2025.csv +0 -0
  11. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_coefficients_2026.csv +0 -0
  12. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_dx_to_cc_2025.csv +0 -0
  13. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_dx_to_cc_2026.csv +0 -0
  14. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv +0 -0
  15. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv +0 -0
  16. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv +0 -0
  17. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2026.csv +0 -0
  18. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_hierarchies_2025.csv +0 -0
  19. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/data/ra_hierarchies_2026.csv +0 -0
  20. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/datamodels.py +0 -0
  21. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/extractor.py +0 -0
  22. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/extractor_837.py +0 -0
  23. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/extractor_fhir.py +0 -0
  24. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/filter.py +0 -0
  25. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/hccinfhir.py +0 -0
  26. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_coefficients.py +0 -0
  27. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_demographics.py +0 -0
  28. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_dx_to_cc.py +0 -0
  29. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_hierarchies.py +0 -0
  30. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/model_interactions.py +0 -0
  31. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/__init__.py +0 -0
  32. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_0.txt +0 -0
  33. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_1.txt +0 -0
  34. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_10.txt +0 -0
  35. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_11.txt +0 -0
  36. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_12.txt +0 -0
  37. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_2.txt +0 -0
  38. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_3.txt +0 -0
  39. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_4.txt +0 -0
  40. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_5.txt +0 -0
  41. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_6.txt +0 -0
  42. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_7.txt +0 -0
  43. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_8.txt +0 -0
  44. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_837_9.txt +0 -0
  45. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_eob_1.json +0 -0
  46. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_eob_2.json +0 -0
  47. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_eob_200.ndjson +0 -0
  48. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/sample_files/sample_eob_3.json +0 -0
  49. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/samples.py +0 -0
  50. {hccinfhir-0.1.4 → hccinfhir-0.1.5}/hccinfhir/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hccinfhir
3
- Version: 0.1.4
3
+ Version: 0.1.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
@@ -60,12 +60,12 @@ print(f"HCCs: {result.hcc_list}")
60
60
  HCCInFHIR supports three primary data sources for HCC risk adjustment calculations:
61
61
 
62
62
  ### 1. **CMS Encounter Data Records (EDRs)**
63
- - **Input**: X12 837 envelope files (text format) + demographic data from payers
63
+ - **Input**: X12 837 5010 transaction files (text format) + demographic data from payers
64
64
  - **Use Case**: Medicare Advantage plans processing encounter data for CMS submissions
65
65
  - **Output**: Risk scores with detailed HCC mappings and interactions
66
66
 
67
67
  ### 2. **Clearinghouse 837 Claims**
68
- - **Input**: X12 837 institutional/professional claim files + patient demographics
68
+ - **Input**: X12 837 5010 institutional/professional claim files + patient demographics
69
69
  - **Use Case**: Health plans and providers calculating risk scores from claims data
70
70
  - **Output**: Service-level analysis with filtering and risk score calculations
71
71
 
@@ -579,17 +579,99 @@ except ModelNotFoundError as e:
579
579
  print(f"Model configuration error: {e}")
580
580
  ```
581
581
 
582
- ## 🧪 Testing
582
+ ### Custom Valuesets
583
+
584
+ Users can generate custom and more specific valuesets using the mimilabs data lakehouse.
585
+
586
+ For example, the valuesets in the package are created as follows:
587
+
588
+ `ra_dx_to_cc_mapping_2026.csv`
589
+ ```sql
590
+ WITH latest_years AS (
591
+ SELECT
592
+ model_name,
593
+ MAX(year) as latest_year
594
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping
595
+ WHERE model_type = 'Initial'
596
+ AND year <= 2026 -- Don't go beyond 2026
597
+ GROUP BY model_name
598
+ )
599
+ SELECT
600
+ r.diagnosis_code,
601
+ r.cc,
602
+ r.model_name
603
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping r
604
+ INNER JOIN latest_years l
605
+ ON r.model_name = l.model_name
606
+ AND r.year = l.latest_year
607
+ WHERE r.model_type = 'Initial'
608
+ ORDER BY r.model_name, r.diagnosis_code;
609
+ ```
610
+
611
+ `ra_hierarchies_2026.csv`
612
+ ```sql
613
+ WITH latest_dates AS (
614
+ SELECT
615
+ model_domain,
616
+ model_version,
617
+ model_fullname,
618
+ MAX(eff_last_date) as latest_eff_last_date
619
+ FROM mimi_ws_1.cmspayment.ra_hierarchies
620
+ GROUP BY model_domain, model_version, model_fullname
621
+ )
622
+ SELECT
623
+ r.cc_parent,
624
+ r.cc_child,
625
+ r.model_domain,
626
+ r.model_version,
627
+ r.model_fullname
628
+ FROM mimi_ws_1.cmspayment.ra_hierarchies r
629
+ INNER JOIN latest_dates l
630
+ ON r.model_domain = l.model_domain
631
+ AND r.model_version = l.model_version
632
+ AND r.model_fullname = l.model_fullname
633
+ AND r.eff_last_date = l.latest_eff_last_date
634
+ ORDER BY r.model_domain, r.model_version, r.model_fullname, r.cc_parent, r.cc_child;
635
+ ```
636
+
637
+
638
+ `ra_coefficients_2026.csv`
639
+ ```sql
640
+ WITH preferred_records AS (
641
+ SELECT
642
+ model_domain,
643
+ model_version,
644
+ MAX(eff_last_date) as latest_eff_last_date
645
+ FROM mimi_ws_1.cmspayment.ra_coefficients
646
+ GROUP BY model_domain, model_version
647
+ )
648
+ SELECT
649
+ r.coefficient,
650
+ r.value,
651
+ r.model_domain,
652
+ r.model_version
653
+ FROM mimi_ws_1.cmspayment.ra_coefficients r
654
+ INNER JOIN preferred_records p
655
+ ON r.model_domain = p.model_domain
656
+ AND r.model_version = p.model_version
657
+ AND r.eff_last_date = p.latest_eff_last_date
658
+ ORDER BY r.model_domain, r.model_version, r.coefficient;
659
+ ```
660
+
661
+ `ra_eligible_cpt_hcpcs_2026.csv`
662
+ ```sql
663
+ SELECT DISTINCT cpt_hcpcs_code
664
+ FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
665
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2025;
666
+ ```
583
667
 
584
- ```bash
585
- # Install development dependencies
586
- pip install -e ".[dev]"
587
668
 
588
- # Run tests
589
- pytest tests/
669
+ ## 🧪 Testing
590
670
 
591
- # Run with coverage
592
- pytest --cov=hccinfhir tests/
671
+ ```bash
672
+ $ hatch shell
673
+ $ pip install -e .
674
+ $ pytest tests/*
593
675
  ```
594
676
 
595
677
  ## 📄 License
@@ -46,12 +46,12 @@ print(f"HCCs: {result.hcc_list}")
46
46
  HCCInFHIR supports three primary data sources for HCC risk adjustment calculations:
47
47
 
48
48
  ### 1. **CMS Encounter Data Records (EDRs)**
49
- - **Input**: X12 837 envelope files (text format) + demographic data from payers
49
+ - **Input**: X12 837 5010 transaction files (text format) + demographic data from payers
50
50
  - **Use Case**: Medicare Advantage plans processing encounter data for CMS submissions
51
51
  - **Output**: Risk scores with detailed HCC mappings and interactions
52
52
 
53
53
  ### 2. **Clearinghouse 837 Claims**
54
- - **Input**: X12 837 institutional/professional claim files + patient demographics
54
+ - **Input**: X12 837 5010 institutional/professional claim files + patient demographics
55
55
  - **Use Case**: Health plans and providers calculating risk scores from claims data
56
56
  - **Output**: Service-level analysis with filtering and risk score calculations
57
57
 
@@ -565,17 +565,99 @@ except ModelNotFoundError as e:
565
565
  print(f"Model configuration error: {e}")
566
566
  ```
567
567
 
568
- ## 🧪 Testing
568
+ ### Custom Valuesets
569
+
570
+ Users can generate custom and more specific valuesets using the mimilabs data lakehouse.
571
+
572
+ For example, the valuesets in the package are created as follows:
573
+
574
+ `ra_dx_to_cc_mapping_2026.csv`
575
+ ```sql
576
+ WITH latest_years AS (
577
+ SELECT
578
+ model_name,
579
+ MAX(year) as latest_year
580
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping
581
+ WHERE model_type = 'Initial'
582
+ AND year <= 2026 -- Don't go beyond 2026
583
+ GROUP BY model_name
584
+ )
585
+ SELECT
586
+ r.diagnosis_code,
587
+ r.cc,
588
+ r.model_name
589
+ FROM mimi_ws_1.cmspayment.ra_dx_to_cc_mapping r
590
+ INNER JOIN latest_years l
591
+ ON r.model_name = l.model_name
592
+ AND r.year = l.latest_year
593
+ WHERE r.model_type = 'Initial'
594
+ ORDER BY r.model_name, r.diagnosis_code;
595
+ ```
596
+
597
+ `ra_hierarchies_2026.csv`
598
+ ```sql
599
+ WITH latest_dates AS (
600
+ SELECT
601
+ model_domain,
602
+ model_version,
603
+ model_fullname,
604
+ MAX(eff_last_date) as latest_eff_last_date
605
+ FROM mimi_ws_1.cmspayment.ra_hierarchies
606
+ GROUP BY model_domain, model_version, model_fullname
607
+ )
608
+ SELECT
609
+ r.cc_parent,
610
+ r.cc_child,
611
+ r.model_domain,
612
+ r.model_version,
613
+ r.model_fullname
614
+ FROM mimi_ws_1.cmspayment.ra_hierarchies r
615
+ INNER JOIN latest_dates l
616
+ ON r.model_domain = l.model_domain
617
+ AND r.model_version = l.model_version
618
+ AND r.model_fullname = l.model_fullname
619
+ AND r.eff_last_date = l.latest_eff_last_date
620
+ ORDER BY r.model_domain, r.model_version, r.model_fullname, r.cc_parent, r.cc_child;
621
+ ```
622
+
623
+
624
+ `ra_coefficients_2026.csv`
625
+ ```sql
626
+ WITH preferred_records AS (
627
+ SELECT
628
+ model_domain,
629
+ model_version,
630
+ MAX(eff_last_date) as latest_eff_last_date
631
+ FROM mimi_ws_1.cmspayment.ra_coefficients
632
+ GROUP BY model_domain, model_version
633
+ )
634
+ SELECT
635
+ r.coefficient,
636
+ r.value,
637
+ r.model_domain,
638
+ r.model_version
639
+ FROM mimi_ws_1.cmspayment.ra_coefficients r
640
+ INNER JOIN preferred_records p
641
+ ON r.model_domain = p.model_domain
642
+ AND r.model_version = p.model_version
643
+ AND r.eff_last_date = p.latest_eff_last_date
644
+ ORDER BY r.model_domain, r.model_version, r.coefficient;
645
+ ```
646
+
647
+ `ra_eligible_cpt_hcpcs_2026.csv`
648
+ ```sql
649
+ SELECT DISTINCT cpt_hcpcs_code
650
+ FROM mimi_ws_1.cmspayment.ra_eligible_cpt_hcpcs
651
+ WHERE is_included = 'yes' AND YEAR(mimi_src_file_date) = 2025;
652
+ ```
569
653
 
570
- ```bash
571
- # Install development dependencies
572
- pip install -e ".[dev]"
573
654
 
574
- # Run tests
575
- pytest tests/
655
+ ## 🧪 Testing
576
656
 
577
- # Run with coverage
578
- pytest --cov=hccinfhir tests/
657
+ ```bash
658
+ $ hatch shell
659
+ $ pip install -e .
660
+ $ pytest tests/*
579
661
  ```
580
662
 
581
663
  ## 📄 License
@@ -21,7 +21,7 @@ from .samples import (
21
21
  list_available_samples
22
22
  )
23
23
 
24
- __version__ = "0.1.2"
24
+ __version__ = "0.1.5"
25
25
  __author__ = "Yubin Park"
26
26
  __email__ = "yubin.park@mimilabs.ai"
27
27
 
@@ -83,9 +83,11 @@ def calculate_raf(diagnosis_codes: List[str],
83
83
  coefficients = apply_coefficients(demographics, hcc_set, interactions, model_name)
84
84
 
85
85
  hcc_chronic = set()
86
+ interactions_chronic = {}
86
87
  for hcc in hcc_set:
87
88
  if is_chronic_mapping.get((hcc, model_name), False):
88
89
  hcc_chronic.add(hcc)
90
+ interactions_chronic = apply_interactions(demographics, hcc_chronic, model_name)
89
91
 
90
92
  demographic_interactions = {}
91
93
  for key, value in interactions.items():
@@ -104,11 +106,13 @@ def calculate_raf(diagnosis_codes: List[str],
104
106
  model_name)
105
107
  coefficients_chronic_only = apply_coefficients(demographics,
106
108
  hcc_chronic,
107
- demographic_interactions,
109
+ interactions_chronic,
108
110
  model_name)
109
111
 
110
112
  # Calculate risk scores
113
+ print(f"Coefficients: {coefficients}")
111
114
  risk_score = sum(coefficients.values())
115
+ print(f"Risk Score: {risk_score}")
112
116
  risk_score_demographics = sum(coefficients_demographics.values())
113
117
  risk_score_chronic_only = sum(coefficients_chronic_only.values()) - risk_score_demographics
114
118
  risk_score_hcc = risk_score - risk_score_demographics
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hccinfhir"
7
- version = "0.1.4"
7
+ version = "0.1.5"
8
8
  authors = [
9
9
  { name="Yubin Park", email="yubin.park@mimilabs.ai" },
10
10
  ]
File without changes
File without changes
File without changes
File without changes