How to Handle NDC Codes in EDI 837 Claims
National Drug Codes (NDCs) appear in EDI 837 claim files whenever drugs, biologicals, or compound medications are billed. Get them wrong and you’re looking at claim rejections, delays, or — worse — silent denials that slip through validation only to hit a wall at the payer’s adjudication system.
This guide walks through exactly where NDC codes go in an 837 transaction, which segments carry them, what qualifier combinations matter, and how to validate your output before submission.
What Is an NDC Code?
An NDC (National Drug Code) is an 11-digit identifier assigned by the FDA to every commercially available drug product. It encodes the labeler, product, and trade package in a structured format:
Labeler (5 digits) - Product (4 digits) - Package (2 digits)
00006-0056-82
Payers require NDCs for drug-related service lines because they need to distinguish between branded vs. generic, dosage forms, and package sizes for accurate pricing and formulary validation. HCPCS J-codes alone aren’t always enough — many payers mandate the NDC to process drug claims correctly.
Where NDCs Go in an 837 Transaction
NDC codes are line-level data — they attach to individual service lines, not to the claim header. In X12 EDI, that means they live inside Loop 2400 (the Service Line loop), not Loop 2300 (the Claim loop).
The three segments you need to know:
| Segment | Purpose |
|---|---|
| LIN | Identifies the NDC code and qualifier |
| CTP | Communicates quantity, unit of measure, and unit price |
| REF | Carries the prescription/compound number when required |
These segments appear immediately after the SV1/SV2 segment for the service line in question.
The LIN Segment: Identifying the NDC
The LIN segment is the core carrier for the NDC. Here’s what a properly formed LIN looks like in raw X12:
LIN**N4*00006005682~
Breaking it down:
LIN— segment identifier- “ (empty) — assigned identification number (leave blank in most claim contexts)
N4— the qualifier that tells the payer “what follows is an NDC”00006005682— the 11-digit NDC (no hyphens, no spaces, zero-padded to 11 digits)
Zero-Padding: The #1 NDC Mistake
NDCs on drug packaging appear in 10-digit form with hyphens, e.g., 0006-0056-82 (5-4-2 or 5-3-3 format). In EDI, you must convert to 11 digits with no hyphens.
| Package Format | Raw NDC | EDI NDC |
|---|---|---|
| 5-4-2 | 00006-0056-82 | 00006005682 |
| 5-3-3 | 00006-056-082 | 00006056082 |
| 4-4-2 | 0006-0056-82 | 00060005682 |
Failing to zero-pad is one of the most common rejection causes for drug lines. Always normalize to 11 digits before inserting into EDI.
The CTP Segment: Quantity and Unit of Measure
Once you’ve identified the drug via LIN, you need to tell the payer how much was administered. That’s the CTP segment’s job.
CTP****12*ML~
Element positions:
CTP— segment ID- Positions 2 and 3 — price basis qualifiers (typically blank in claim context)
- Position 4 — unit price (blank here; pricing is on SV1/SV2)
12— quantity administeredML— unit of measure (milliliters in this example)
Common Unit of Measure Codes
| Code | Meaning |
|---|---|
UN | Unit |
ML | Milliliter |
GR | Gram |
F2 | International Unit |
ME | Milligram |
The unit of measure must match the quantity you’re billing. If you administered 2.5 mL of a drug, use 2.5 and ML. Mismatches between the CTP quantity and the SV1 units billed are a common audit flag.
A Complete Service Line with NDC
Here’s what a fully formed drug service line looks like inside Loop 2400, including the LIN and CTP segments:
LX*1~
SV1*HC:J0696:JW*48.50*UN*2**1~
DTP*472*D8*20260912~
LIN**N4*00069296005~
CTP****2*UN~
Walking through each line:
- LX*1 — service line number 1
- SV1 — professional service: HCPCS J0696 (Azithromycin), $48.50, 2 units billed
- DTP*472 — date of service: September 12, 2026
- LIN — NDC qualifier N4, code
00069296005(11 digits, zero-padded) - CTP — 2 units administered, unit of measure UN
This is the structure most commercial payers and Medicare expect for professional claims (837P). Medicaid payers may have additional requirements — check your state-specific companion guide.
NDCs on 837I (Institutional Claims)
For institutional claims, the structure is nearly identical but sits inside the SV2 line rather than SV1. Loop 2400 still owns the NDC segments.
LX*2~
SV2*0259*HC:J2001*100.00*UN*50**2~
DTP*472*D8*20260912~
LIN**N4*00641602825~
CTP****50*ML~
Notes for 837I:
- SV2 carries the revenue code (
0259— IV solutions) alongside the HCPCS - LIN and CTP follow the same structure as 837P
- Some payers require an additional
REFsegment for compound claims (see below)
REF Segment: Prescription Numbers and Compound IDs
For compound drugs or when a prescription number is required, the REF segment follows CTP:
REF*XZ*RX20260914001~
REF— segment IDXZ— qualifier meaning “Pharmacy Prescription Number”RX20260914001— the actual prescription or compound ID
Other REF qualifiers you may encounter for drug lines:
| Qualifier | Meaning |
|---|---|
XZ | Pharmacy Prescription Number |
VY | Pharmacy Order Number |
BUI | Batch Number |
Not all payers require REF for every drug line — but compound medications almost always do. Check the payer’s companion guide before submission.
NDC Qualifier: Always N4
One point worth hammering home: in EDI 837, the NDC qualifier is always N4. This is the X12 standard qualifier for NDC codes and is not interchangeable with other drug identification qualifiers like EN (EAN/UCC) or UK (UCC12).
If you’re building a claim generator or a translator, hardcode N4 for this position rather than accepting it as a configurable input — incorrect qualifiers cause silent payer rejections that are difficult to diagnose.
Loop Placement: Where to Put LIN/CTP Within 2400
The 837 transaction set specifies a precise order for segments within Loop 2400. LIN and CTP must appear after the service line date (DTP*472) and before any line-level notes (NTE):
LX
SV1 or SV2
DTP*472 ← service date
LIN ← NDC identifier
CTP ← quantity/UOM
REF ← prescription number (if required)
NTE ← line notes (if any)
PWK ← paperwork (if any)
Placing LIN before DTP or after NTE will cause structural validation errors in most clearinghouse systems. Validate your loop order before transmission.
Validation Checklist Before Submission
Before sending an 837 with NDC data, run through this checklist:
- NDC is exactly 11 digits, no hyphens, no spaces
- Zero-padding applied based on source format (5-4-2, 5-3-3, or 4-4-2)
- Qualifier in LIN is
N4 - CTP quantity matches the amount actually administered (not just billed)
- Unit of measure code is correct (UN vs. ML vs. GR)
- LIN/CTP appears after DTP*472, within Loop 2400
- REF included if compound or if payer companion guide requires it
- HCPCS code on SV1/SV2 cross-references the NDC (payer may validate)
Common Rejection Reasons for NDC Lines
Here are the most frequent failure modes, along with what to look for:
277CA Remark Code CO-B7 / CARC 4 — Authorization Required
Sometimes triggered when the NDC doesn’t match the payer’s formulary or when the product requires prior auth. Verify the drug tier and auth status before resubmission.
Claim-level rejection: “Invalid product/service ID”
Almost always a malformed NDC — wrong digit count, hyphens left in, or wrong qualifier. Re-extract the NDC from the source and normalize it.
Line-level rejection: “Unit of measure mismatch”
The quantity in CTP doesn’t align with the dosage billed in SV1. Review the drug’s package insert and match units precisely.
Clearinghouse rejection: “Segment sequence error in Loop 2400”
LIN or CTP is in the wrong position within the loop. Review your loop order and reorder segments per the 837 implementation guide.
Reading NDC Errors in a 277CA
When an NDC-related rejection comes back in a 277CA, look for it in the SVC loop (service line acknowledgment). The rejection code will appear in the STC segment:
SVC*HC:J0696**48.50**2~
STC*A0:520:PR***20260914~
QTY*QA*2~
STC*A0:520:PR— A0 = rejected status category, 520 = specific rejection code, PR = entity acknowledging- Use the 520 code to look up the specific reason in the ASC X12 277CA implementation guide or your clearinghouse’s error dictionary
Payer-Specific Rules to Watch
Medicare, Medicaid, and commercial payers each have quirks:
Medicare (CMS):
Requires NDC for drugs billed under Part B when a J-code is used. The NDC must match the actual product administered, not just any product with that J-code. CMS validates NDC-to-HCPCS crosswalk via their drug pricing files.
Medicaid:
Many state Medicaid programs require NDC on virtually every drug line, including oral medications dispensed in an inpatient setting. Requirements vary widely by state — always pull the state-specific companion guide.
Commercial Payers:
Vary enormously. Some require NDC only for injectables; others require it for all HCPCS J-codes. Some require it at the line level only when billing specific revenue codes.
When in doubt, include the NDC. Omitting it when a payer needs it causes rejections; including it when a payer doesn’t require it is generally harmless.
Summary
Handling NDC codes in EDI 837 claims comes down to three rules:
- Always normalize to 11 digits, no hyphens, qualifier N4
- LIN + CTP belong in Loop 2400, after DTP*472, in correct segment order
- Quantity and unit of measure in CTP must match what was actually administered
Get those three right and you’ll eliminate the vast majority of NDC-related rejections before they ever hit a clearinghouse.
Ready to work with EDI files in your browser? Try EDI Paisan free — no install required.