hccinfhir 0.2.2__py3-none-any.whl → 0.2.4__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.
@@ -0,0 +1 @@
1
+ ISA*00* *00* *ZZ*CADHCS_5010_834*30*999999991 *250124*1927*^*00501*000000001*0*P*:~GS*BE*CADHCS_5010_834*999999991*20250124*192730*10000001*X*005010X220A1~ST*834*0001*005010X220A1~BGN*00*DHCS834-DA-20250124-Sample PACE-001*20250124*19273000****2~QTY*TO*1~N1*P5*California Department of Health Care Services.........*FI*999999990~N1*IN*Sample PACE Inc.*FI*999999991~INS*Y*18*001*AI*A*E**AC~REF*0F*randomParticipantID~REF*1L*randomCIN1~REF*17*;;202501;~REF*23*4;20200101;;~REF*3H*19;10;randomCaseNum1;;~REF*6O*;W;Y;;60;~REF*ZZ*01051;41609;;;;30451;41651;;;~NM1*IL*1*randomLastName*randomFirstName*A~PER*IP**TE*randomPhone~N3*randomStreetAddress1~N4*LOS ANGELES CA*CA*90019**CY*19~DMG*D8*randomDoB*F**7~LUI*LD*SPA**7~HD*021**LTC*010;51~DTP*348*D8*20250101~DTP*349*D8*20250131~REF*17*N;;;;;;;;;;;;;1~REF*9V*9;9;0~REF*CE*10;401;;;;;;~REF*RB*10~REF*ZX*19~REF*ZZ*;;10~SE*29*0001~GE*1*10000001~IEA*1*000000001~
@@ -0,0 +1 @@
1
+ ISA*00* *00* *ZZ*CADHCS_5010_834*30*999999992 *250812*1936*^*00501*000000002*0*P*:~GS*BE*CADHCS_5010_834*999999992*20250812*193641*10000002*X*005010X220A1~ST*834*0001*005010X220A1~BGN*00*DHCS834-DA-20250812-Sample South LA PACE-957-001*20250812*19364100****2~QTY*TO*1~N1*P5*California Department of Health Care Services.........*FI*999999990~N1*IN*Sample South LA PACE Inc.*FI*999999992~INS*Y*18*001*AI*A*C**AC~REF*0F*randomMemberId~REF*1L*randomCIN2~REF*17*;;202508;~REF*23*2;20200201;;;~REF*3H*19;60;randomCaseNum2;;~REF*6O*;W;Y;;08;~REF*DX*H9999;006;20250201;;;~REF*F6*randomMbi~REF*QQ*;;202001;202001~REF*ZZ*95701;;;;;35201;;;;~NM1*IL*1*randomLastName*randomFirstName~PER*IP**TE*randomPhone~N3*randomAddress1~N4*LONG BEACH CA*CA*90813**CY*19~DMG*D8*randomDoB*F**7~LUI*LD*SPA**7~HD*021**LTC*957;01~DTP*348*D8*20250801~DTP*349*D8*20250831~REF*17*F;;;;;;;;;;;;;1~REF*9V*2;2;2~REF*CE*60;401;80;401;;;;~REF*RB*60~REF*ZX*19~REF*ZZ*;;10~SE*32*0001~GE*1*10000002~IEA*1*000000002~
@@ -0,0 +1 @@
1
+ ISA*00* *00* *ZZ*CADHCS_5010_834*30*999999992 *251022*2000*^*00501*000000003*0*P*:~GS*BE*CADHCS_5010_834*999999992*20251022*200019*10000003*X*005010X220A1~ST*834*0001*005010X220A1~BGN*00*DHCS834-DA-20251022-Sample South LA PACE-957-001*20251022*20001900****2~QTY*TO*1~N1*P5*California Department of Health Care Services.........*FI*999999990~N1*IN*Sample South LA PACE Inc.*FI*999999992~INS*Y*18*001*AI*A*C**AC~REF*0F*randomMemberId~REF*1L*randomCIN3~REF*17*202605;;202510;~REF*23*2;20200301;;;~REF*3H*19;16;randomCode;;08~REF*6O*;A;Y;;29;~REF*DX*H9999;001;20251101;;;~REF*F6*randomMbi~REF*QQ*;;202002;202002~REF*ZZ*95701;;;;;20101;;;;~NM1*IL*1*randomLastName*randomFirstName~PER*IP**TE*randomPhone~N3*randomAddress1~N4*LOS ANGELES CA*CA*90044**CY*19~DMG*D8*randomDoB*F**:RET:2054-5~HD*021**LTC*957;01~DTP*348*D8*20251001~DTP*349*D8*20251031~REF*17*F;;;;1~REF*9V*3;2;2~REF*CE*16;401;80;401;;;;~REF*RB*16~REF*ZX*19~REF*ZZ*;;10~SE*31*0001~GE*1*10000003~IEA*1*000000003~
@@ -0,0 +1 @@
1
+ ISA*00* *00* *ZZ*CADHCS_5010_834*30*999999992 *251023*1959*^*00501*000000004*0*P*:~GS*BE*CADHCS_5010_834*999999992*20251023*195928*10000004*X*005010X220A1~ST*834*0001*005010X220A1~BGN*00*DHCS834-DA-20251023-Sample South LA PACE-957-001*20251023*19592800****2~QTY*TO*1~N1*P5*California Department of Health Care Services.........*FI*999999990~N1*IN*Sample South LA PACE Inc.*FI*999999992~INS*Y*18*001*AI*A*C**AC~REF*0F*randomMemberId~REF*1L*randomCIN4~REF*17*202601;;202510;~REF*23*6;20200401;20200101;;~REF*3H*19;17;randomId1;;07~REF*6O*;W;Y;;19;~REF*DX*H9999;006;20230401;;;~REF*F6*randomId2~REF*QQ*;;202003;202003~REF*ZZ*957P4;;;;;;;;;~NM1*IL*1*randomLastName*randomFirstName~PER*IP**TE*randomPhone~N3*randomAddress1~N4*LONG BEACH CA*CA*90810**CY*19~DMG*D8*randomDoB*F**:RET:2135-2~HD*001**LTC*957;P4~DTP*348*D8*20251001~DTP*349*D8*20250930~AMT*R*1237~REF*17*F;;;;1~REF*9V*3;1;0~REF*CE*17;501;2K;691;;;;~REF*ZX*19~REF*ZZ*;;10~SE*31*0001~GE*1*10000004~IEA*1*000000004~
@@ -0,0 +1 @@
1
+ ISA*00* *00* *ZZ*CADHCS_5010_834*30*999999991 *250206*2008*^*00501*000000005*0*P*:~GS*BE*CADHCS_5010_834*999999991*20250206*200823*10000005*X*005010X220A1~ST*834*0001*005010X220A1~BGN*00*DHCS834-DA-20250206-Sample PACE-001*20250206*20082300****2~QTY*TO*2~N1*P5*California Department of Health Care Services.........*FI*999999990~N1*IN*Sample PACE Inc.*FI*999999991~INS*Y*18*001*AI*A*E**AC~REF*0F*randomMemberId~REF*1L*randomCIN5~REF*17*;;202502;~REF*23*3;20200501;;~REF*3H*19;60;randomCaseNum1;;~REF*6O*;A;Y;D;67;~REF*Q4*randomProviderId;~REF*ZZ*01059;;;;;010S1;;;;~NM1*IL*1*randomLName1*randomFName1~PER*IP**TE*randomPhone1~N3*randomFullAddress1~N4*LOS ANGELES CA*CA*90037**CY*19~DMG*D8*randomDoB1*F**:RET:2054-5~NM1*31*1~N3*randomAddress~N4*LOS ANGELES CA*CA*90037~HD*001**LTC*010;59~DTP*348*D8*20250201~DTP*349*D8*20250131~REF*17*N;;;;;;;;;;;;;1~REF*CE*60;001;80;891;;;;~REF*RB*60~REF*ZX*19~REF*ZZ*;;10~HD*021**LTC*010;S1~DTP*348*D8*20250101~DTP*349*D8*20250131~REF*17*N;;;;;;;;;;;;;1~REF*CE*60;401;80;891;;;;~REF*RB*60~REF*ZX*19~REF*ZZ*;;11~INS*Y*18*001*AI*A*C**AC~REF*0F*randomMemberId2~REF*1L*randomCIN6~REF*17*;;202502;~REF*23*9;20200601;;~REF*3H*19;10;randomCaseNum2;;~REF*6O*;A;Y;;25;~REF*DX*;;;S5617;D635;20240901~REF*F6*randomId1~REF*QQ*;;202004;202004~REF*ZZ*01001;;;;;30401;;;;~NM1*IL*1*randomLName2*randomFName2*M~PER*IP**TE*randomPhone2~N3*randomAddress2~N4*LOS ANGELES CA*CA*90029**CY*19~DMG*D8*randomDoB2*M**:RET:2135-2~HD*021**LTC*010;01~DTP*348*D8*20250201~DTP*349*D8*20250228~REF*17*D;;;;;;;;;;;;;1~REF*9V*2;2;2~REF*CE*10;401;9G;999;80;401;;~REF*RB*10~REF*ZX*19~REF*ZZ*;;10~SE*64*0001~GE*1*10000005~IEA*1*000000005~
hccinfhir/utils.py CHANGED
@@ -247,6 +247,46 @@ def load_coefficients(file_path: str) -> Dict[Tuple[str, ModelName], float]:
247
247
  return coefficients
248
248
 
249
249
 
250
+ def load_race_ethnicity(file_path: str = "ph_race_and_ethnicity_cdc_v1.3.csv") -> Dict[str, str]:
251
+ """
252
+ Load CDC race and ethnicity codes from CSV file.
253
+ Expected format: Concept Code,Hierarchical Property,Concept Name,...
254
+
255
+ Args:
256
+ file_path: Filename or path to the CSV file
257
+
258
+ Returns:
259
+ Dictionary mapping concept code to concept name
260
+
261
+ Raises:
262
+ FileNotFoundError: If file cannot be found
263
+ RuntimeError: If file cannot be loaded or parsed
264
+ """
265
+ mapping: Dict[str, str] = {}
266
+
267
+ try:
268
+ resolved_path = resolve_data_file(file_path)
269
+ with open(resolved_path, "r", encoding="utf-8", errors="replace") as file:
270
+ content = file.read()
271
+ except FileNotFoundError as e:
272
+ raise FileNotFoundError(f"Could not load race/ethnicity mapping: {e}")
273
+ except Exception as e:
274
+ raise RuntimeError(f"Error loading race/ethnicity file '{file_path}': {e}")
275
+
276
+ for line in content.splitlines()[1:]: # Skip header
277
+ try:
278
+ parts = line.split(',')
279
+ if len(parts) >= 3:
280
+ concept_code = parts[0].strip()
281
+ concept_name = parts[2].strip()
282
+ if concept_code and concept_name:
283
+ mapping[concept_code] = concept_name
284
+ except (ValueError, IndexError):
285
+ continue # Skip malformed lines
286
+
287
+ return mapping
288
+
289
+
250
290
  def load_labels(file_path: str) -> Dict[Tuple[str, ModelName], str]:
251
291
  """
252
292
  Load HCC labels from a CSV file.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hccinfhir
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -80,7 +80,7 @@ print(f"HCCs: {result.hcc_list}")
80
80
  - **Custom Data Files**: Full support for custom coefficients, mappings, and hierarchies
81
81
  - **Flexible File Resolution**: Absolute paths, relative paths, or bundled data files
82
82
  - **Type-Safe**: Built on Pydantic with full type hints
83
- - **Well-Tested**: 181 comprehensive tests covering all features
83
+ - **Well-Tested**: 189 comprehensive tests covering all features
84
84
 
85
85
  ## 📊 Data Sources & Use Cases
86
86
 
@@ -95,6 +95,7 @@ print(f"HCCs: {result.hcc_list}")
95
95
  - **Use Case**: Extract dual eligibility status, detect Medicaid coverage loss
96
96
  - **Features**: California DHCS aid code mapping, Medicare status codes, coverage tracking
97
97
  - **Output**: Demographics with accurate dual eligibility for risk calculations
98
+ - **Architecture**: See [834 Parsing Documentation](./README_PARSING834.md) for transaction structure and parsing logic
98
99
 
99
100
  ### 3. **FHIR ExplanationOfBenefit Resources**
100
101
  - **Input**: FHIR EOB from CMS Blue Button 2.0 / BCDA API
@@ -1037,8 +1038,8 @@ result = processor.run([eob], demographics) # Note: [eob] not eob
1037
1038
  claim = get_837_sample(0) # Cases 0-12 (returns string)
1038
1039
  claims = get_837_sample_list([0, 1, 2]) # Returns list
1039
1040
 
1040
- # X12 834 enrollment samples
1041
- enrollment_834 = get_834_sample(1) # Currently only case 1 available (returns string)
1041
+ # X12 834 enrollment samples (6 CA DHCS scenarios)
1042
+ enrollment_834 = get_834_sample(1) # Cases 1-6 available (returns string)
1042
1043
 
1043
1044
  # List all available samples
1044
1045
  info = list_available_samples()
@@ -1056,7 +1057,7 @@ hatch shell
1056
1057
  # Install in development mode
1057
1058
  pip install -e .
1058
1059
 
1059
- # Run all tests (181 tests)
1060
+ # Run all tests (189 tests)
1060
1061
  pytest tests/
1061
1062
 
1062
1063
  # Run specific test file
@@ -1073,6 +1074,7 @@ Apache License 2.0. See [LICENSE](LICENSE) for details.
1073
1074
  ## 📞 Support
1074
1075
 
1075
1076
  - **Claude Code Documentation**: [CLAUDE.md](./CLAUDE.md) - Comprehensive developer guide
1077
+ - **834 Parsing Architecture**: [README_PARSING834.md](./README_PARSING834.md) - X12 834 transaction structure and parsing logic
1076
1078
  - **Issues**: [GitHub Issues](https://github.com/mimilabs/hccinfhir/issues)
1077
1079
 
1078
1080
  ## 👥 Contributors
@@ -1,9 +1,9 @@
1
1
  hccinfhir/__init__.py,sha256=3aFYtjTklZJg3wIlnMJNgfDBaDCfKXVlYsacdsZ9L4I,1113
2
2
  hccinfhir/constants.py,sha256=C4Vyjtzgyd4Jm2I2X6cTYQZLe-jAMC8boUcy-7OXQDQ,8473
3
- hccinfhir/datamodels.py,sha256=X9ZHPCfxI12o88AFmeomzSxh5fA6tsDOAmTlXbdncJ8,11471
3
+ hccinfhir/datamodels.py,sha256=LNk94V3ez8f1J4Y8PXxNgHslVfwNQoJCl0SO4etgxs4,15593
4
4
  hccinfhir/defaults.py,sha256=aKdXPhf9bYUzpGvXM1GIXZaKxqkKInt3v9meLB9fWog,1394
5
5
  hccinfhir/extractor.py,sha256=xL9c2VT-e2I7_c8N8j4Og42UEgVuCzyn9WFp3ntM5Ro,1822
6
- hccinfhir/extractor_834.py,sha256=dIqovUOWm_7k_c6sUqTIzQua_kTQ8dLGy3-4-LECW3Y,18855
6
+ hccinfhir/extractor_834.py,sha256=gXbSQJOAdQiOub2LHUYX4Eb7ABKL0WC5r0-ZX1pe70k,29579
7
7
  hccinfhir/extractor_837.py,sha256=fGsvBTWIj9dsHLGGR67AdlYDSsFi5qnSVlTgwkL1f-E,15334
8
8
  hccinfhir/extractor_fhir.py,sha256=wUN3vTm1oTZ-KvfcDebnpQMxAC-7YlRKv12Wrv3p85A,8490
9
9
  hccinfhir/filter.py,sha256=j_yD2g6RBXVUV9trKkWzsQ35x3fRvfKUPvEXKUefI64,2007
@@ -15,10 +15,11 @@ hccinfhir/model_dx_to_cc.py,sha256=Yjc6xKI-jMXsbOzS_chc4NI15Bwagb7BwZZ8cKQaTbk,1
15
15
  hccinfhir/model_hierarchies.py,sha256=cboUnSHZZfOxA8QZKV4QIE-32duElssML32OqYT-65g,1542
16
16
  hccinfhir/model_interactions.py,sha256=g6jK27Xu8RQUHS3lk4sk2v6w6wqd52mdbGn0BsnR7Pk,21394
17
17
  hccinfhir/samples.py,sha256=2VSWS81cv9EnaHqK7sd6CjwG6FUI9E--5wHgD000REI,9952
18
- hccinfhir/utils.py,sha256=hQgHjuOcEQcnxemTZwqFBHWvLC5-C1Gup9cDXEYlZjE,10770
18
+ hccinfhir/utils.py,sha256=WQ2atW0CrdX7sAz_YRLeY4JD-CuH0o-WRusQ_xVVfgY,12152
19
19
  hccinfhir/data/__init__.py,sha256=SGiSkpGrnxbvtEFMMlk82NFHOE50hFXcgKwKUSuVZUg,45
20
20
  hccinfhir/data/hcc_is_chronic.csv,sha256=Bwd-RND6SdEsKP-assoBaXnjUJAuDXhSkwWlymux72Y,19701
21
21
  hccinfhir/data/hcc_is_chronic_without_esrd_model.csv,sha256=eVVI4_8mQNkiBiNO3kattfT_zfcV18XgmiltdzZEXSo,17720
22
+ hccinfhir/data/ph_race_and_ethnicity_cdc_v1.3.csv,sha256=5tw_ATN1mQWVUIahXZyIa5GOX-977PzfhNlGvm43tD8,146970
22
23
  hccinfhir/data/ra_coefficients_2025.csv,sha256=I0S2hoJlfig-D0oSFxy0b3Piv7m9AzOGo2CwR6bcQ9w,215191
23
24
  hccinfhir/data/ra_coefficients_2026.csv,sha256=0gfjGgVdIEWkBO01NaAbTLMzHCYINA0rf_zl8ojngCY,288060
24
25
  hccinfhir/data/ra_dx_to_cc_2025.csv,sha256=4N7vF6VZndkl7d3Fo0cGsbAPAZdCjAizSH8BOKsZNAo,1618924
@@ -32,6 +33,11 @@ hccinfhir/data/ra_hierarchies_2026.csv,sha256=A6ZQZb0rpRWrySBB_KA5S4PGtMxWuzB2gu
32
33
  hccinfhir/data/ra_labels_2026.csv,sha256=YstfP7s-3ZwjP4I_GYPPj3_yn-PQK3Q0Q_MVYZhsfjY,50248
33
34
  hccinfhir/sample_files/__init__.py,sha256=SGiSkpGrnxbvtEFMMlk82NFHOE50hFXcgKwKUSuVZUg,45
34
35
  hccinfhir/sample_files/sample_834_01.txt,sha256=J2HMXfY6fAFpV36rvLQ3QymRRS2TPqf3TQY6CNS7TrE,1627
36
+ hccinfhir/sample_files/sample_834_02.txt,sha256=vSvjM69kKfOW9e-8dvlO9zDcRPpOD7LmekLu68z4aB4,926
37
+ hccinfhir/sample_files/sample_834_03.txt,sha256=pD4UTUFCEHxKu3bz3ZZdWo5b8Y1UWTXAo7PmFjWsukU,999
38
+ hccinfhir/sample_files/sample_834_04.txt,sha256=1Cv8kN7At1ce60kXBGlMr5DhLMsuw2clnVDi02mvBJA,991
39
+ hccinfhir/sample_files/sample_834_05.txt,sha256=hjQ5SEgj0cCNZyWas1-sVL9gm8m3rC4R65JHIcbAPRk,993
40
+ hccinfhir/sample_files/sample_834_06.txt,sha256=oC3e4UMmmhVKXI8eB7SlLyJ8kZX4NemlzI_WGznO-48,1659
35
41
  hccinfhir/sample_files/sample_837_0.txt,sha256=eggrD259uHa05z2dfxWBpUDseSDp_AQcLyN_adpHyTw,5295
36
42
  hccinfhir/sample_files/sample_837_1.txt,sha256=E155MdemSDYoXokuTXUZ6Br_RGGedYv5t5dh-eMRmuk,1322
37
43
  hccinfhir/sample_files/sample_837_10.txt,sha256=zSJXI78vHAksA7FFQEVLvepefdpMM2_AexLyoDimV3Q,1129
@@ -49,7 +55,7 @@ hccinfhir/sample_files/sample_eob_1.json,sha256=_NGSVR2ysFpx-DcTvyga6dFCzhQ8Vi9f
49
55
  hccinfhir/sample_files/sample_eob_2.json,sha256=FcnJcx0ApOczxjJ_uxVLzCep9THfNf4xs9Yf7hxk8e4,1769
50
56
  hccinfhir/sample_files/sample_eob_200.ndjson,sha256=CxpjeQ1DCMUzZILaM68UEhfxO0p45YGhDDoCZeq8PxU,1917986
51
57
  hccinfhir/sample_files/sample_eob_3.json,sha256=4BW4wOMBEEU9RDfJR15rBEvk0KNHyuMEh3e055y87Hc,2306
52
- hccinfhir-0.2.2.dist-info/METADATA,sha256=PS0FbHZTjJ4ALMCISUyDf9h2hWCzNZvgThIVI8rdey0,37122
53
- hccinfhir-0.2.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
54
- hccinfhir-0.2.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
55
- hccinfhir-0.2.2.dist-info/RECORD,,
58
+ hccinfhir-0.2.4.dist-info/METADATA,sha256=wjhOKhD3HpfuCs69t-sBSrQn_kuNngbRaA2lLNuCTno,37381
59
+ hccinfhir-0.2.4.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
60
+ hccinfhir-0.2.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
61
+ hccinfhir-0.2.4.dist-info/RECORD,,