fix(sp41): thread canonical envelope into Pipeline-A 837P

The previous _serialize_pipeline_a emitted a placeholder envelope:
billing_provider=BillingProvider(name='REBILL PROVIDER', npi='0000000000')
with no tax_id, no address, no Subscriber address, no real payer name,
and no submitter contact block. Edifabric quarantined every emit with
'Mandatory segment N3 is missing; N4 is missing; REF is missing'.

This fix pulls the canonical envelope constants from
cyclone.rebill.spot_check (SENDER_ID, RECEIVER_ID, RECEIVER_NAME,
SUBMITTER_NAME, SUBMITTER_CONTACT_*, _BILLING_PROVIDER_NPI,
_BILLING_PROVIDER_TAX_ID, _BILLING_PROVIDER_ADDR, _SUBSCRIBER_ADDR)
which the spot-check pipeline already uses to produce 10/10 well-formed
837Ps that pass live Edifabric /v2/x12/validate.

Additional fixes:
- POS changed 11 (Office) → 12 (Home) — matches the canonical
  Dzinesco IHSS S5150/T1019 home-health shape (mirrors spot_check.py).
- Subscriber gets dob, gender, address so NM1*IL → N3/N4 emit.
- Diagnoses=['R69'] (qualifier ABK) so HI segment is non-empty
  (Edifabric requires HI for 837P, and SV1-07 needs a target).
- Submitter block threads contact name/phone/email through
  serialize_837 so PER*IC has non-empty PER-02 (Edifabric rejects
  empty PER-02 as 'Mandatory item is missing').

Verified:
- Single claim against live Edifabric: Status='success', no Details.
- Full backend suite: 1593 passed, 10 skipped, 0 failed.
- Spot-check driver suite (mock Edifabric): 2/2 passed.
- test_run_rebill_emits_real_files_for_pipeline_a updated for POS=12.
This commit is contained in:
cyclone
2026-07-08 08:48:50 -06:00
parent afd6cead06
commit ad6629c7ab
2 changed files with 69 additions and 10 deletions
+3 -2
View File
@@ -314,8 +314,9 @@ def test_run_rebill_emits_real_files_for_pipeline_a(tmp_path):
# Original claim_submit_id is preserved in CLM01 (anchors the
# frequency-7 replacement).
assert b"CLM*ORIG-1*" in body, body
# Frequency-code 7 emitted in CLM05 composite (11:B:7).
assert b"CLM*ORIG-1*100.00***11:B:7" in body, body
# Frequency-code 7 emitted in CLM05 composite (12:B:7 — Home POS
# is canonical for Dzinesco IHSS S5150/T1019 services).
assert b"CLM*ORIG-1*100.00***12:B:7" in body, body
# Pipeline-A filename uses HCPF-spec prefix + claim_id suffix.
assert a_path.name.startswith("tp11525703-837P-"), a_path.name