Mule's X12 Connector - Integrate & Handle EDI Files

Mule's X12 Connector - Integrate & Handle EDI Files
Mule's X12 Connector - Integrate & Handle EDI Files

EDI (Electronic Data Interchange) 

EDI is the electronic interchange of business information using a standardized format- a process which allows one company to send information to another company electronically rather than with paper. 

Multiple EDI standards are presently employed. 

  • ANSI X12 
  • EDIFACT 
  • HIPAA 

This article will explore the process of parsing an X12 EDI document and transforming it into an XML document. The selected tool for handling X12 data in this context is the X12 Connector - Mule 4, obtained from Anypoint Exchange. 

ANSI X12 

ANSI X12, denoting American National Standards Institute X12, represents the U.S. EDI standard initiated in 1979 under the oversight of the ANSI subsidiary Accredited Standards Committee (ASC).

X12 Connector in mule 

Read (x12:read): This operation involves converting an input stream of EDI text into the organized structure of maps and lists representing the EDI data. 

Write (x12:write): This operation reverses the process by transforming the structured maps and lists of EDI data into an EDI text stream. 

Write batch (x12:write-batch): This operation focuses on consolidating multiple individual EDI messages created and collected over a specific duration, merging them into a cohesive batch.

Steps to follow

  • Create a project and import X12 Connector.
  • Launch Anypoint Studio and start a new project.
  • Use the Search in Exchange feature within the new project to import the X12 Connector - Mule 4 directly from Exchange into your Studio workspace. 
Search in Exchange

Click Add Account in the dialog box to input your Anypoint platform credentials if they're not saved yet. 

Once your Anypoint platform credentials are entered, you'll be connected to Anypoint Exchange via Anypoint Studio. Then, follow by typing x12 as indicated in the image, select X12 Connector - Mule 4, click Add, and finally, complete the process by clicking Finish.

Adding X12 from Exchange

The X12 Connector - Mule 4 has been successfully integrated into your studio directly from the Exchange platform. 

Sample EDI file

You can download sample EDI file for testing purposes, here we use sample 837 claim EDI file. https://www.betterhealthtogether.org/s/CHPW_Claimdata.txt, That file looks like, 

To download different samples use the link https://www.betterhealthtogether.org/bold-solutions-content/companion-guides-xsd87
  • Build a mule flow designed to read X12 data, then parse and convert it into XML format.
  • Construct a Mule flow comprising the following processors:
  • X12 Read processor: This component is responsible for reading the EDI payload received from the Listener. 
X12 Connector

 The X12_EDI_Configuration are, 

X12 Configuration

Utilize the Transform Message processor to take the output generated by X12 Read and convert it into an XML payload. 

Transformation Flow

Run the mule flow in studio either in run or debug mode. 

X12 Payload
XML Payload
  • Use Postman (or any tool of your choice) to test the above REST API flow. Screenshot is given below. 
  • In Body section, enter the EDI payload of any type and invoke the mule flow running in the Anypoint studio. 
  • The X12 Processor parses the data and returns the data as a Java Object. 
  • Using a Transform Message processor, as seen above, the object is converted into XML format. In general, the output of X12-Read may be transformed into any other data format (e.g., JSON) that the application must work with.
  • The screenshot below shows the input EDI and output XML after it is transformed.
API Response

To Be Continued - X12 Write

In Conclusion, In the flow we saw, it's easy to change and manage EDI data into different types using the X12 Connector. In real situations where there are lots of EDI transactions in files, we handle them together in batches. We use a method where each transaction is separately checked and prepared using the EDI X12 Read Processor before we do more work on them. 

After the X12-Read processor deals with the EDI data and finishes working on the transactions, sometimes we need to change the response back to EDI. To do this, we create a specific type of Java Object that matches the format we expect. Then, we use the X12 - Write processor. It takes this special object and turns the data into EDI format, which we can use as our response.

In upcoming blogs, we will explore the X12 Write processor in detail.

Mulecraft Footer