code wiki / (root) / nx_medbill_nsa.nx

nx_medbill_nsa.nx source

↩ module page · 75 lines · 5551 B

1// nx_medbill_nsa.nx -- ADV3 of the MEDICAL BILLING & PATIENT ADVOCACY ladder: classify a billing 2// SITUATION to the federal protection that actually applies, then render the matching letter. 3// Routes: 1 = NSA emergency (insured, emergency care from an out-of-network provider: balance billing 4// prohibited, cost sharing limited to in-network) · 2 = NSA facility (insured, non-emergency care from 5// an out-of-network provider AT an in-network facility: same protection) · 3 = PPDR (UNINSURED/self-pay 6// with a Good Faith Estimate, billed substantially in excess -- the federal Patient-Provider Dispute 7// Resolution process, 120-day window from the bill date) · 4 = standard dispute/appeal path (no 8// situation-specific federal shield; use the audit/dispute/appeal organs). The substantially-in-excess 9// THRESHOLD is caller data (federal figure today: $400 = 40000 cents), never hardcoded (#11). 10// Flags bundle (i64 array): [0]=emergency [1]=oon_provider [2]=in_network_facility [3]=insured [4]=has_gfe. 11// FAIL-SAFE: letters go to a caller buffer with placeholders; nothing is ever sent. Deadline math 12// reuses the appeal organ's exact leap-safe civil-days calendar (DRY). license_tier: ORIGINAL 13import "nx_syscalls.nx" 14import "nx_medbill_appeal.nx" 15 16func nsa_classify(flags: *i64, over_cents: i64, threshold: i64) -> i64 { 17 if flags[3] == 1 { 18 if flags[0] == 1 { if flags[1] == 1 { return 1 } } 19 if flags[1] == 1 { if flags[2] == 1 { return 2 } } 20 } 21 if flags[3] == 0 { if flags[4] == 1 { if over_cents >= threshold { return 3 } } } 22 return 4 23} 24 25func nsa_n(out: *u8, off: i64, v0: i64) -> i64 { 26 if v0 == 0 { out[off] = 48 as u8; return off + 1 } 27 var v: i64 = v0 28 var o: i64 = off 29 if v < 0 { out[o] = 45 as u8; o = o + 1; v = 0 - v } 30 let t: *u8 = sys_mmap(24) 31 var k: i64 = 0 32 while v > 0 { t[k] = (48 + (v % 10)) as u8; v = v / 10; k = k + 1 } 33 while k > 0 { k = k - 1; out[o] = t[k]; o = o + 1 } 34 return o 35} 36func nsa_money(out: *u8, off: i64, cents: i64) -> i64 { 37 var o: i64 = off 38 out[o] = 36 as u8 39 o = o + 1 40 o = nsa_n(out, o, cents / 100) 41 out[o] = 46 as u8 42 o = o + 1 43 o = mba_n2(out, o, cents % 100) 44 return o 45} 46 47// Render the route-specific letter. Route 3 computes the PPDR window (bill date + 120 days) inline. 48func nsa_letter(route: i64, over_cents: i64, bill_ymd: i64, out: *u8) -> i64 { 49 var o: i64 = 0 50 if route == 1 { 51 o = mba_cat(out, o, "To: [PROVIDER NAME] Billing Department (copy: [INSURANCE PLAN NAME])\nRe: Account [ACCOUNT NUMBER] - Patient [PATIENT NAME]\nSubject: Balance billing prohibited - emergency services (No Surprises Act)\n\nThe charges on this account are for EMERGENCY services furnished by an out-of-network provider. Under the No Surprises Act, balance billing for emergency services is prohibited and my cost sharing is limited to the in-network amount. Please issue a corrected bill reflecting in-network cost sharing only, and reprocess the claim with my health plan accordingly. Do not pursue collection of any amount above my in-network cost sharing.\n\nSincerely,\n[PATIENT NAME]\n\x00" as *u8) 52 out[o] = 0 as u8 53 return o 54 } 55 if route == 2 { 56 o = mba_cat(out, o, "To: [PROVIDER NAME] Billing Department (copy: [INSURANCE PLAN NAME])\nRe: Account [ACCOUNT NUMBER] - Patient [PATIENT NAME]\nSubject: Balance billing prohibited - out-of-network provider at an in-network facility (No Surprises Act)\n\nThe charges on this account are for services furnished by an out-of-network provider at an IN-NETWORK facility. Under the No Surprises Act, my cost sharing for such services is limited to the in-network amount unless a valid, timely notice-and-consent waiver applies, which it does not for these services. Please issue a corrected bill reflecting in-network cost sharing only and reprocess the claim with my health plan.\n\nSincerely,\n[PATIENT NAME]\n\x00" as *u8) 57 out[o] = 0 as u8 58 return o 59 } 60 if route == 3 { 61 let deadline: i64 = mba_add_days(bill_ymd, 120) 62 o = mba_cat(out, o, "To: [PROVIDER NAME] Billing Department\nRe: Account [ACCOUNT NUMBER] - Patient [PATIENT NAME]\nSubject: Billed amount substantially exceeds the Good Faith Estimate\n\nI am uninsured/self-pay and received a Good Faith Estimate for these services. The billed amount exceeds that estimate by " as *u8) 63 o = nsa_money(out, o, over_cents) 64 o = mba_cat(out, o, ", which meets the federal threshold for the Patient-Provider Dispute Resolution process. I intend to initiate PPDR with the federal dispute-resolution entity within 120 days of the bill date (your " as *u8) 65 o = mba_date(out, o, bill_ymd) 66 o = mba_cat(out, o, " bill; window through " as *u8) 67 o = mba_date(out, o, deadline) 68 o = mba_cat(out, o, ") unless we resolve this directly first. Please respond within 10 business days with either a corrected bill consistent with the estimate or an itemized justification of the difference. Please pause collection activity while this dispute is open.\n\nSincerely,\n[PATIENT NAME]\n\x00" as *u8) 69 out[o] = 0 as u8 70 return o 71 } 72 o = mba_cat(out, o, "No situation-specific federal shield applies to these facts. Use the standard path: decode and audit the itemized bill (review), reconcile it against the EOB, send a cited dispute letter (letter), appeal any insurance denial (appeal), and screen for hospital financial assistance (charity).\n\x00" as *u8) 73 out[o] = 0 as u8 74 return o 75}