X12 837P N4 Segment Guide: Fields, Format, and Testing Gotchas
N3 gives you a street. N4 finishes the address. It's a short segment — three fields most people actually use — but it's also where a surprising number of synthetic test files quietly break, because city, state, and ZIP look independent on the page and aren't independent in reality.
N4 (Geographic Location) is the segment in an X12 837P claim that carries the city, state, and postal code for whatever address the preceding N3 segment started — typically the billing provider, the pay-to address, or the subscriber's address, depending on which loop the N4 sits inside.
The elements that actually matter in practice
Example
A synthetic N4 for a billing provider address in Denver, Colorado, with a five-digit ZIP code. No real provider location.
Where this trips people up
Synthetic data generators that pick city, state, and ZIP from three separate random lists will happily produce an N4 with a Texas ZIP code attached to a Massachusetts state abbreviation. Humans skim past this instantly, but a claim scrubber or payer-side edit that cross-checks ZIP-to-state ranges will reject the claim outright — and if your test suite never generates that mismatch, you won't find the rejection logic gap until a real typo does the same thing in production. The safer approach is to generate N401-N403 as a single correlated address record, not three independent random fields.