hccinfhir 0.2.4__tar.gz → 0.2.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.
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/PKG-INFO +1 -1
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/datamodels.py +61 -2
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/extractor_834.py +2 -2
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/pyproject.toml +1 -1
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/.gitignore +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/LICENSE +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/README.md +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/__init__.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/constants.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/__init__.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/hcc_is_chronic.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/hcc_is_chronic_without_esrd_model.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ph_race_and_ethnicity_cdc_v1.3.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_coefficients_2025.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_coefficients_2026.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_dx_to_cc_2025.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_dx_to_cc_2026.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2023.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2024.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2025.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_eligible_cpt_hcpcs_2026.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_hierarchies_2025.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_hierarchies_2026.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/data/ra_labels_2026.csv +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/defaults.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/extractor.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/extractor_837.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/extractor_fhir.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/filter.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/hccinfhir.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_calculate.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_coefficients.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_demographics.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_dx_to_cc.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_hierarchies.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/model_interactions.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/__init__.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_01.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_02.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_03.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_04.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_05.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_834_06.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_0.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_1.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_10.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_11.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_12.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_2.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_3.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_4.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_5.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_6.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_7.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_8.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_837_9.txt +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_eob_1.json +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_eob_2.json +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_eob_200.ndjson +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/sample_files/sample_eob_3.json +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/samples.py +0 -0
- {hccinfhir-0.2.4 → hccinfhir-0.2.5}/hccinfhir/utils.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
|
-
from typing import List, Optional, Literal, Dict, Set, TypedDict, Union
|
|
2
|
+
from typing import List, Optional, Literal, Dict, Set, TypedDict, Union, Any
|
|
3
|
+
from datetime import date
|
|
3
4
|
|
|
4
5
|
# Define Model Name literal type
|
|
5
6
|
ModelName = Literal[
|
|
@@ -203,6 +204,21 @@ class HCPCoveragePeriod(BaseModel):
|
|
|
203
204
|
hcp_status: Optional[str] = None
|
|
204
205
|
aid_codes: Optional[str] = None # REF*CE composite
|
|
205
206
|
|
|
207
|
+
def model_dump_with_dates(self, **kwargs) -> Dict[str, Any]:
|
|
208
|
+
"""Return dict with date fields as date objects instead of strings.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
**kwargs: Additional arguments passed to model_dump()
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
Dict with start_date and end_date as date objects (if present)
|
|
215
|
+
"""
|
|
216
|
+
data = self.model_dump(**kwargs)
|
|
217
|
+
for field in ('start_date', 'end_date'):
|
|
218
|
+
if data.get(field):
|
|
219
|
+
data[field] = date.fromisoformat(data[field])
|
|
220
|
+
return data
|
|
221
|
+
|
|
206
222
|
|
|
207
223
|
class EnrollmentData(BaseModel):
|
|
208
224
|
"""
|
|
@@ -372,4 +388,47 @@ class EnrollmentData(BaseModel):
|
|
|
372
388
|
amount: Optional[float] = None
|
|
373
389
|
|
|
374
390
|
# HCP History
|
|
375
|
-
hcp_history: List[HCPCoveragePeriod] = []
|
|
391
|
+
hcp_history: List[HCPCoveragePeriod] = []
|
|
392
|
+
|
|
393
|
+
def model_dump_with_dates(self, **kwargs) -> Dict[str, Any]:
|
|
394
|
+
"""Return dict with date fields as date objects instead of strings.
|
|
395
|
+
|
|
396
|
+
Converts all YYYY-MM-DD string date fields to date objects.
|
|
397
|
+
Also converts dates in nested hcp_history items.
|
|
398
|
+
|
|
399
|
+
Args:
|
|
400
|
+
**kwargs: Additional arguments passed to model_dump()
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
Dict with date fields as date objects (if present)
|
|
404
|
+
|
|
405
|
+
Example:
|
|
406
|
+
>>> enrollment = extract_enrollment_834(content)[0]
|
|
407
|
+
>>> data = enrollment.model_dump_with_dates()
|
|
408
|
+
>>> isinstance(data['dob'], date) # True
|
|
409
|
+
"""
|
|
410
|
+
data = self.model_dump(**kwargs)
|
|
411
|
+
|
|
412
|
+
# EnrollmentData date fields
|
|
413
|
+
date_fields = (
|
|
414
|
+
'report_date',
|
|
415
|
+
'dob',
|
|
416
|
+
'death_date',
|
|
417
|
+
'coverage_start_date',
|
|
418
|
+
'coverage_end_date',
|
|
419
|
+
'fame_card_issue_date',
|
|
420
|
+
'fame_redetermination_date',
|
|
421
|
+
'fame_death_date',
|
|
422
|
+
)
|
|
423
|
+
for field in date_fields:
|
|
424
|
+
if data.get(field):
|
|
425
|
+
data[field] = date.fromisoformat(data[field])
|
|
426
|
+
|
|
427
|
+
# Convert dates in hcp_history items
|
|
428
|
+
if data.get('hcp_history'):
|
|
429
|
+
for hcp in data['hcp_history']:
|
|
430
|
+
for field in ('start_date', 'end_date'):
|
|
431
|
+
if hcp.get(field):
|
|
432
|
+
hcp[field] = date.fromisoformat(hcp[field])
|
|
433
|
+
|
|
434
|
+
return data
|
|
@@ -619,8 +619,8 @@ def parse_834_enrollment(segments: List[List[str]], source: str = None, report_d
|
|
|
619
619
|
# Strip state suffix from city if embedded
|
|
620
620
|
if city and state and city.upper().endswith(' ' + state.upper()):
|
|
621
621
|
city = city[:-len(state)-1].strip()
|
|
622
|
-
member.city = city
|
|
623
|
-
member.state = state
|
|
622
|
+
member.city = city
|
|
623
|
+
member.state = state
|
|
624
624
|
member.zip = get_segment_value(segment, 3)
|
|
625
625
|
# County code
|
|
626
626
|
if len(segment) > 6 and segment[5] == 'CY' and not member.fame_county_id:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|