PDF documents are used by many organizations to both display and print health care claim forms like CMS-1500 and UB-04.   Fillable PDF documents, also called PDF forms, are used to allow users the both view and edit documents before saving or printing.  PDF forms are sometimes displayed directly in internet browsers.

EDI data from an 837 Professional EDI document, for example,  represents a health care claim and can be used to initially populate fields in PDF claim forms.  Users can then edit the fields, save or print the PDF claim as needed.

This blog will demonstrate how to take data from an 837 Professional EDI file and populate a fillable CMS-1500 PDF form.

Step 1 Loading the 837 Professional claim file into memory 

The first step is loading the 837 Professional  file into memory.  We’ll use EDIValidator to accomplish this.  Once the data is loaded we’ll use Typed Documents to get the data we need.

The Code

// Create a new instance of the EDIValidator
EDIValidator validate = new EDIValidator();

// Load 5010 837 Professional Rules
ediValidator.EDIRulesFile = “EDIFiles\\Rules_5010_837P_005010X222A1.Rules”;
// Specify the EDI file to load
ediValidator.EDIFile = “EDIFiles\\sampleEDIFile.txt”;

// Load and validate the EDI data

Step 2 Use Typed Documents to get the data we need

In the code below we want to get the billing provider name which goes into Box 33 of CMS-1500 claim forms.  This is the last box on the form.  We’re going to ignore Phone Number, Box 33a and Box 33b to keep things simple.

The Code

// Convert the loaded EDI data into a Typed Document
Typed5010Document doc = new Typed5010Document(ediValidator.EDILightWeightDocument);
// Get the data we need using the new Typed Documents API
NM1 billProvName = doc.MainSection.GetSegment(“INTERCHANGE HEADER/FUNCTIONAL GROUP/ST HEADER/2000A/2010AA/NM1“);
// Construct the billing provider name
String box33Data = billProvName.NameLastOrOrganizationName + ” ” + billProvName.FirstName + ” ” + billProvName.MiddleName;

Step 3  Use the information from Step 2 to fill the fillable CMS-1500 PDF form

How is this accomplished?  Each fillable PDF form has a collection of fields/value pairs that can be set.  We’ll use a free .Net library called iText.  iText allows us to get and set the fields.  Each fillable PDF form will have different names for their fields.  You should iterate over the fields and verify that you are setting the correct field.

In our example the field we want to set is called ‘doc_name’.

The Code

// Create a PdfReader and PdfWriter instance 

PdfReader reader = new PdfReader(“claim-form-cms-1500.pdf”);
PdfWriter writer = new PdfWriter(“FilledOutForm.pdf”);
PdfDocument pdfDoc = new PdfDocument(reader, writer);
// Get the form fields
var form = PdfAcroForm.GetAcroForm(pdfDoc, true);

var fields = form.GetFormFields();

// Specify the EDI file to load
fields[“doc_name”] = box33Data;

// Close the document

That’s it.  We’ve just loaded an EDI document into memory and used it’s data to populate a fillable CMS-1500 PDF form.  Let’s verify by opening the new PDF document ‘FilledOutForm.pdf’


The CMS-1500 PDF document is still editable and allows the users to make any necessary changes.

Now that was easy!

Take Charge Of EDI

RDPCrystal EDI Library