hccinfhir 0.2.1__py3-none-any.whl → 0.2.3__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.
hccinfhir/datamodels.py CHANGED
@@ -93,6 +93,22 @@ PrefixOverride = Literal[
93
93
  "Rx_NE_LTI_", # New Enrollee, Long-Term Institutionalized
94
94
  ]
95
95
 
96
+ class HCCDetail(BaseModel):
97
+ """
98
+ Detailed information about an HCC category.
99
+
100
+ Attributes:
101
+ hcc: HCC code (e.g., "18", "85")
102
+ label: Human-readable description (e.g., "Diabetes with Chronic Complications")
103
+ is_chronic: Whether this HCC is considered a chronic condition
104
+ coefficient: The coefficient value applied for this HCC in the RAF calculation
105
+ """
106
+ hcc: str = Field(..., description="HCC code (e.g., '18', '85')")
107
+ label: Optional[str] = Field(None, description="Human-readable HCC description")
108
+ is_chronic: bool = Field(False, description="Whether this HCC is a chronic condition")
109
+ coefficient: Optional[float] = Field(None, description="Coefficient value for this HCC")
110
+
111
+
96
112
  class ServiceLevelData(BaseModel):
97
113
  """
98
114
  Represents standardized service-level data extracted from healthcare claims.
@@ -167,6 +183,7 @@ class RAFResult(BaseModel):
167
183
  risk_score_hcc: float = Field(..., description="HCC conditions risk score")
168
184
  risk_score_payment: float = Field(..., description="Payment RAF score (adjusted for MACI, normalization, and frailty)")
169
185
  hcc_list: List[str] = Field(default_factory=list, description="List of active HCC categories")
186
+ hcc_details: List[HCCDetail] = Field(default_factory=list, description="Detailed HCC information with labels and chronic status")
170
187
  cc_to_dx: Dict[str, Set[str]] = Field(default_factory=dict, description="Condition categories mapped to diagnosis codes")
171
188
  coefficients: Dict[str, float] = Field(default_factory=dict, description="Applied model coefficients")
172
189
  interactions: Dict[str, float] = Field(default_factory=dict, description="Disease interaction coefficients")
@@ -178,22 +195,64 @@ class RAFResult(BaseModel):
178
195
 
179
196
  model_config = {"extra": "forbid", "validate_assignment": True}
180
197
 
198
+ class HCPCoveragePeriod(BaseModel):
199
+ """A single HCP (Health Care Plan) coverage period from HD loop"""
200
+ start_date: Optional[str] = None
201
+ end_date: Optional[str] = None
202
+ hcp_code: Optional[str] = None
203
+ hcp_status: Optional[str] = None
204
+ aid_codes: Optional[str] = None # REF*CE composite
205
+
206
+
181
207
  class EnrollmentData(BaseModel):
182
208
  """
183
209
  Enrollment and demographic data extracted from 834 transactions.
184
210
 
185
211
  Focus: Extract data needed for risk adjustment and Medicaid coverage tracking.
212
+ Supports California DHCS Medi-Cal 834 format with FAME fields.
186
213
 
187
214
  Attributes:
188
- member_id: Unique identifier for the member
189
- mbi: Medicare Beneficiary Identifier
190
- medicaid_id: Medicaid/Medi-Cal ID number
215
+ # Header Info
216
+ source: Interchange sender ID (ISA06)
217
+ report_date: Transaction date (GS04)
218
+
219
+ # Identifiers
220
+ member_id: Unique identifier for the member (REF*0F)
221
+ mbi: Medicare Beneficiary Identifier (REF*6P)
222
+ medicaid_id: Medicaid/Medi-Cal ID number (REF*23)
223
+ hic: Medicare HICN (REF*F6)
224
+ cin: Client Index Number from REF*3H
225
+ cin_check_digit: CIN check digit from REF*3H
226
+
227
+ # Name
228
+ first_name: Member first name (NM104)
229
+ last_name: Member last name (NM103)
230
+ middle_name: Member middle name (NM105)
231
+
232
+ # Demographics
191
233
  dob: Date of birth (YYYY-MM-DD)
192
234
  age: Calculated age
193
235
  sex: Member sex (M/F)
194
- maintenance_type: 001=Change, 021=Add, 024=Cancel, 025=Reinstate
236
+ race: Race/ethnicity code (DMG05)
237
+ language: Preferred language (LUI02)
238
+ death_date: Date of death if applicable
239
+
240
+ # Address
241
+ address_1: Street address line 1 (N301)
242
+ address_2: Street address line 2 (N302)
243
+ city: City (N401)
244
+ state: State code (N402)
245
+ zip: Postal code (N403)
246
+ phone: Phone number (PER04)
247
+
248
+ # Coverage tracking
249
+ maintenance_type: 001=Change, 021=Add, 024=Cancel, 025=Reinstate (INS03)
250
+ maintenance_reason_code: Maintenance reason (INS04)
251
+ benefit_status_code: A=Active, C=COBRA, etc. (INS05)
195
252
  coverage_start_date: Coverage effective date
196
- coverage_end_date: Coverage termination date (critical for Medicaid loss detection)
253
+ coverage_end_date: Coverage termination date
254
+
255
+ # Medicaid/Medicare Status
197
256
  has_medicare: Member has Medicare coverage
198
257
  has_medicaid: Member has Medicaid coverage
199
258
  dual_elgbl_cd: Dual eligibility status code ('00','01'-'08')
@@ -201,25 +260,75 @@ class EnrollmentData(BaseModel):
201
260
  is_partial_benefit_dual: Partial Benefit Dual (uses CPA_/CPD_ prefix)
202
261
  medicare_status_code: QMB, SLMB, QI, QDWI, etc.
203
262
  medi_cal_aid_code: California Medi-Cal aid code
263
+ medi_cal_eligibility_status: Medi-Cal eligibility status from REF*6O
264
+
265
+ # CA DHCS / FAME Specific
266
+ fame_county_id: FAME county ID (REF*ZX or N4*CY)
267
+ case_number: Case number (REF*1L)
268
+ fame_card_issue_date: FAME card issue date
269
+ fame_redetermination_date: FAME redetermination date (REF*17)
270
+ fame_death_date: FAME death date
271
+ primary_aid_code: Primary AID code (REF*RB)
272
+ carrier_code: Carrier code
273
+ fed_contract_number: Federal contract number
274
+ client_reporting_cat: Client reporting category
275
+ res_addr_flag: Residential address flag from REF*6O
276
+ reas_add_ind: Reason address indicator from REF*6O
277
+ res_zip_deliv_code: Residential zip delivery code
278
+
279
+ # Risk Adjustment Fields
204
280
  orec: Original Reason for Entitlement Code
205
281
  crec: Current Reason for Entitlement Code
206
282
  snp: Special Needs Plan enrollment
207
283
  low_income: Low Income Subsidy (Part D)
208
284
  lti: Long-Term Institutionalized
209
285
  new_enrollee: New enrollee status (<= 3 months)
286
+
287
+ # HCP (Health Care Plan) Info
288
+ hcp_code: Current HCP code (HD04 first part)
289
+ hcp_status: Current HCP status (HD04 second part)
290
+ amount: Premium or cost share amount
291
+
292
+ # HCP History (multiple coverage periods)
293
+ hcp_history: List of historical HCP coverage periods
210
294
  """
295
+ # Header Info
296
+ source: Optional[str] = None
297
+ report_date: Optional[str] = None
298
+
211
299
  # Identifiers
212
300
  member_id: Optional[str] = None
213
301
  mbi: Optional[str] = None
214
302
  medicaid_id: Optional[str] = None
303
+ hic: Optional[str] = None
304
+ cin: Optional[str] = None
305
+ cin_check_digit: Optional[str] = None
306
+
307
+ # Name
308
+ first_name: Optional[str] = None
309
+ last_name: Optional[str] = None
310
+ middle_name: Optional[str] = None
215
311
 
216
312
  # Demographics
217
313
  dob: Optional[str] = None
218
314
  age: Optional[int] = None
219
315
  sex: Optional[str] = None
316
+ race: Optional[str] = None
317
+ language: Optional[str] = None
318
+ death_date: Optional[str] = None
319
+
320
+ # Address
321
+ address_1: Optional[str] = None
322
+ address_2: Optional[str] = None
323
+ city: Optional[str] = None
324
+ state: Optional[str] = None
325
+ zip: Optional[str] = None
326
+ phone: Optional[str] = None
220
327
 
221
328
  # Coverage tracking
222
329
  maintenance_type: Optional[str] = None
330
+ maintenance_reason_code: Optional[str] = None
331
+ benefit_status_code: Optional[str] = None
223
332
  coverage_start_date: Optional[str] = None
224
333
  coverage_end_date: Optional[str] = None
225
334
 
@@ -231,6 +340,21 @@ class EnrollmentData(BaseModel):
231
340
  is_partial_benefit_dual: bool = False
232
341
  medicare_status_code: Optional[str] = None
233
342
  medi_cal_aid_code: Optional[str] = None
343
+ medi_cal_eligibility_status: Optional[str] = None
344
+
345
+ # CA DHCS / FAME Specific
346
+ fame_county_id: Optional[str] = None
347
+ case_number: Optional[str] = None
348
+ fame_card_issue_date: Optional[str] = None
349
+ fame_redetermination_date: Optional[str] = None
350
+ fame_death_date: Optional[str] = None
351
+ primary_aid_code: Optional[str] = None
352
+ carrier_code: Optional[str] = None
353
+ fed_contract_number: Optional[str] = None
354
+ client_reporting_cat: Optional[str] = None
355
+ res_addr_flag: Optional[str] = None
356
+ reas_add_ind: Optional[str] = None
357
+ res_zip_deliv_code: Optional[str] = None
234
358
 
235
359
  # Risk Adjustment Fields
236
360
  orec: Optional[str] = None
@@ -238,4 +362,12 @@ class EnrollmentData(BaseModel):
238
362
  snp: bool = False
239
363
  low_income: bool = False
240
364
  lti: bool = False
241
- new_enrollee: bool = False
365
+ new_enrollee: bool = False
366
+
367
+ # HCP Info
368
+ hcp_code: Optional[str] = None
369
+ hcp_status: Optional[str] = None
370
+ amount: Optional[str] = None
371
+
372
+ # HCP History
373
+ hcp_history: List[HCPCoveragePeriod] = []
hccinfhir/defaults.py CHANGED
@@ -15,7 +15,8 @@ from hccinfhir.utils import (
15
15
  load_hierarchies,
16
16
  load_is_chronic,
17
17
  load_coefficients,
18
- load_proc_filtering
18
+ load_proc_filtering,
19
+ load_labels
19
20
  )
20
21
 
21
22
  # Load all default data files once at module import time
@@ -29,3 +30,4 @@ hierarchies_default: Dict[Tuple[str, ModelName], Set[str]] = load_hierarchies('r
29
30
  is_chronic_default: Dict[Tuple[str, ModelName], bool] = load_is_chronic('hcc_is_chronic.csv')
30
31
  coefficients_default: Dict[Tuple[str, ModelName], float] = load_coefficients('ra_coefficients_2026.csv')
31
32
  proc_filtering_default: Set[str] = load_proc_filtering('ra_eligible_cpt_hcpcs_2026.csv')
33
+ labels_default: Dict[Tuple[str, ModelName], str] = load_labels('ra_labels_2026.csv')