feat(sp32): _content_keys_match prefers typed NPI columns over raw_json fallback

This commit is contained in:
Nora
2026-07-02 17:08:09 -06:00
parent c4bc118557
commit de77f19d9d
3 changed files with 67 additions and 23 deletions
+6 -13
View File
@@ -146,9 +146,8 @@ def make_claim(db_session):
claim_id=None
`state=None` defaults to ``ClaimState.SUBMITTED`` so existing tests
that omit it keep behaving. `rendering_provider_npi` is stored as
a transient attribute (no ORM column) for ``_content_keys_match``
to read via ``getattr``.
that omit it keep behaving. `rendering_provider_npi` is wired through
the real ``Claim.rendering_provider_npi`` column (SP32 migration 0019).
"""
def _make(
patient_control_number: str,
@@ -171,10 +170,8 @@ def make_claim(db_session):
charge_amount=total_charge,
state=state if state is not None else _CS.SUBMITTED,
matched_remittance_id=matched_remittance_id,
rendering_provider_npi=rendering_provider_npi,
)
# Transient attribute — read by reconcile._content_keys_match
# via getattr; the Claim ORM has no rendering_provider_npi column.
c.rendering_provider_npi = rendering_provider_npi
db_session.add(c)
db_session.flush()
return c
@@ -191,9 +188,8 @@ def make_remit(db_session):
service_date, remit_id=None
`total_charge_amount` is mapped to ``Remittance.total_charge`` (real ORM
field). `rendering_provider_npi` is stored as a transient attribute for
``_content_keys_match`` to read via ``getattr`` (Remittance has no NPI
column; the parser reads it from raw_json in production).
field). `rendering_provider_npi` is wired through the real
``Remittance.rendering_provider_npi`` column (SP32 migration 0019).
"""
def _make(
payer_claim_control_number: str,
@@ -216,11 +212,8 @@ def make_remit(db_session):
received_at=datetime.now(timezone.utc),
service_date=service_date,
is_reversal=False,
rendering_provider_npi=rendering_provider_npi,
)
# Transient attribute — read by reconcile._content_keys_match via
# getattr. The Remittance ORM has no rendering_provider_npi column;
# the 835 parser reads it from raw_json in production.
r.rendering_provider_npi = rendering_provider_npi
db_session.add(r)
db_session.flush()
return r