837 Health Care Claim (007040)

This is the standard X12 007040 spec, with 14 loops and 126 segment positions, as OpenEDI JSON, an ediFabric C# template and an ediFabric Native model. To change it for a trading partner, customize it in the EDI Spec Builder.

Loading the spec…
The spec as an OpenAPI 3 schema with x-openedi-* extensions, for ediFabric Native, ediFabric Cloud and the EDI Spec Builder. Download OpenEDI (208 KB) Generate classes
The ediFabric .NET template, class TS837. It needs the common segments, composites and codes of X12 007040, one download for every transaction in the version. Download C# (2 KB) Common files (233 KB)
The intermediary model ediFabric Native loads with set_map. Download Native (164 KB)

Use the 837 spec in your code

ediFabric .NET

Add the C# template and its common files to your project, or reference the template NuGet package, and read 837 files into TS837 objects. See ediFabric .NET.

ediFabric Native

Map version 007040 to the Native model with set_map, then parse 837 files to JSON from Python, Java, C or C#. See Convert between EDI and JSON.

OpenEDI

Select Customize in Spec Builder to copy the spec under your own name, change it for your partner, and parse files against it in EdiNation, ediFabric Native or ediFabric Cloud. Read about OpenEDI.

Generate 837 classes in Python, Java, Node.js, Go, Rust or C

ediFabric Native returns each 837 as JSON, with the property names of the OpenEDI schema. To work with that JSON as typed objects, generate classes from the OpenEDI file in your language and deserialize the JSON into TS837. Serialize the objects back to JSON to build EDI with ediFabric Native. The classes keep the loops, segments, lengths and code lists, but not the EDI data formats, so validate files with ediFabric Native. Read more in Generate a class from OpenEDI.

Python: datamodel-code-generator. Node.js: openapi-typescript. Java, Go, Rust and C: OpenAPI Generator.

837 structure

Loops and segments of the standard 837, with their usage and maximum repeats.

IDNameUsageMax use
STTransaction Set HeaderMandatory1
BHTBHTMandatory1
REFREFOptional3
Loop NM1NM1Optional10
NM1NM1Mandatory1
N2N2Optional2
N3N3Optional2
N4N4Optional1
REFREFOptional2
PERPEROptional2
Loop HLHLMandatory99999
HLHLMandatory1
PRVPRVOptional1
SBRSBROptional1
PATPATOptional1
DTPDTPOptional5
CURCUROptional1
Loop NM1NM1Optional10
NM1NM1Mandatory1
N2N2Optional2
N3N3Optional2
N4N4Optional1
DMGDMGOptional1
REFREFOptional20
PERPEROptional2
LUILUIOptional1
Loop CLMCLMOptional100
CLMCLMMandatory1
DTPDTPOptional150
CL1CL1Optional1
DN1DN1Optional1
DN2DN2Optional35
PWKPWKOptional10
CN1CN1Optional1
DSBDSBOptional1
URUROptional1
AMTAMTOptional40
REFREFOptional30
K3K3Optional10
NTENTEOptional20
CR1CR1Optional1
CR2CR2Optional1
CR3CR3Optional1
CR4CR4Optional3
CR5CR5Optional1
CR6CR6Optional1
CR8CR8Optional9
CRCCRCOptional100
HIHIOptional25
QTYQTYOptional10
HCPHCPOptional1
Loop CR7CR7Optional6
CR7CR7Mandatory1
HSDHSDOptional12
Loop NM1NM1Optional9
NM1NM1Mandatory1
PRVPRVOptional1
N2N2Optional2
N3N3Optional2
N4N4Optional1
REFREFOptional20
PERPEROptional2
Loop SBRSBROptional10
SBRSBRMandatory1
CASCASOptional99
RASRASOptional99
AMTAMTOptional15
DMGDMGOptional1
OIOIOptional1
MIAMIAOptional1
MOAMOAOptional1
HIHIOptional1
LQLQOptional99
Loop NM1NM1Optional10
NM1NM1Mandatory1
N2N2Optional2
N3N3Optional2
N4N4Optional1
PERPEROptional2
DTPDTPOptional9
REFREFOptional99999
Loop LXLXOptional99999
LXLXMandatory1
SV1SV1Optional1
SV2SV2Optional1
SV3SV3Optional1
TOOTOOOptional32
SV4SV4Optional1
SV5SV5Optional1
SV6SV6Optional1
SV7SV7Optional1
HIHIOptional25
PWKPWKOptional10
CR1CR1Optional1
CR2CR2Optional5
CR3CR3Optional1
CR4CR4Optional3
CR5CR5Optional1
CRCCRCOptional3
DTPDTPOptional15
QTYQTYOptional5
MEAMEAOptional20
CN1CN1Optional1
REFREFOptional30
AMTAMTOptional15
K3K3Optional10
NTENTEOptional10
PS1PS1Optional1
IMMIMMOptional99999
HSDHSDOptional1
HCPHCPOptional1
CR8CR8Optional99999
Loop LINLINOptional99999
LINLINMandatory1
CTPCTPOptional1
REFREFOptional1
SV4SV4Optional1
SV7SV7Optional1
Loop NM1NM1Optional10
NM1NM1Mandatory1
PRVPRVOptional1
N2N2Optional2
N3N3Optional2
N4N4Optional1
REFREFOptional20
PERPEROptional2
Loop SVDSVDOptional99999
SVDSVDMandatory1
CASCASOptional99
RASRASOptional99
DTPDTPOptional9
AMTAMTOptional20
LQLQOptional99
Loop LSLSOptional1
LSLSMandatory1
Loop LQLQMandatory99999
LQLQMandatory1
FRMFRMMandatory99
LELEMandatory1
SETransaction Set TrailerMandatory1