hccinfhir 0.2.4__py3-none-any.whl → 0.2.5__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
@@ -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.lower() if city else None
623
- member.state = state.lower() if state else None
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hccinfhir
3
- Version: 0.2.4
3
+ Version: 0.2.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
@@ -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=LNk94V3ez8f1J4Y8PXxNgHslVfwNQoJCl0SO4etgxs4,15593
3
+ hccinfhir/datamodels.py,sha256=u-KICO7ODOo8GCsZ0JmyhPauL-irQ9aVjNaiGiVHdks,17592
4
4
  hccinfhir/defaults.py,sha256=aKdXPhf9bYUzpGvXM1GIXZaKxqkKInt3v9meLB9fWog,1394
5
5
  hccinfhir/extractor.py,sha256=xL9c2VT-e2I7_c8N8j4Og42UEgVuCzyn9WFp3ntM5Ro,1822
6
- hccinfhir/extractor_834.py,sha256=gXbSQJOAdQiOub2LHUYX4Eb7ABKL0WC5r0-ZX1pe70k,29579
6
+ hccinfhir/extractor_834.py,sha256=H5756zwjkZN9nXlGHr_V63VgNjQEjIB7nqaoBYazAR8,29526
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
@@ -55,7 +55,7 @@ hccinfhir/sample_files/sample_eob_1.json,sha256=_NGSVR2ysFpx-DcTvyga6dFCzhQ8Vi9f
55
55
  hccinfhir/sample_files/sample_eob_2.json,sha256=FcnJcx0ApOczxjJ_uxVLzCep9THfNf4xs9Yf7hxk8e4,1769
56
56
  hccinfhir/sample_files/sample_eob_200.ndjson,sha256=CxpjeQ1DCMUzZILaM68UEhfxO0p45YGhDDoCZeq8PxU,1917986
57
57
  hccinfhir/sample_files/sample_eob_3.json,sha256=4BW4wOMBEEU9RDfJR15rBEvk0KNHyuMEh3e055y87Hc,2306
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,,
58
+ hccinfhir-0.2.5.dist-info/METADATA,sha256=fjqK-VAKUQ_zblUqz4p8qddjSZje16tYVnPGEYyzw4Q,37381
59
+ hccinfhir-0.2.5.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
60
+ hccinfhir-0.2.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
61
+ hccinfhir-0.2.5.dist-info/RECORD,,