EDI X12 Integration With MuleSoft

Author: Mohammed Shakir

Introduction

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.

EDI Standards

There are several EDI standards in use today

  • ANSI
  • EDIFACT
  • HIPAA
ANSI X12

ANSI X12 stands for American National Standards Institute X12 and refers to the American EDI (Electronic Data Interchange) standard developed back in 1979 by the ANSI subsidiary Accredited Standards Committee (ASC).

EDIFACT

EDIFACT stands for Electronic Data Interchange For Administration, Commerce and Transport. It’s the accepted EDI standard for international trade outside of the U.S. EDIFACT covers:

  • Syntax rules to structure data
  • Interactive exchange protocol (I-EDI)
  • Standard messages (document transaction sets) for multi-country and industry exchange
HIPAA

HIPAA EDI is a direct result of the U.S. passage of the Health Insurance Portability and            Accountability ACT (HIPAA), a law governing, among other things, the electronic exchange of healthcare data, including EDI documents, security, and data governance requirements.

  • HIPAA EDI covers the exchange of electronic documents between healthcare providers and health insurers.
EDI X12
X12 Message Types
  • 204 Motor Carrier Load Tender
  • 276 Claim Status Inquiry
  • 277 Claim Status Response
  • 383 Trading Partner Profile
  • 753 Request for Routing Instructions
  • 754 Routing Instructions
  • 810 Invoice
  • 861 Receiving Advice
  • 990 Load Tender Response
  • 997 Functional Acknowledgement
X12 Segments

To know more about segments you can refer the link below:

https://docs.oracle.com/cd/E19398-01/820-1275/agdaw/index.html

In order to get particular type of X12 EDI you can search in google,Below is the sample one for 204 Motor Carrier Load Tender

https://www.generalmills.com/~/media/Images/GMI/TradingPartners/NorthAmerica/SC_204_X12_4010_O60O61_Load_Tender.pdf?la=en

Sample 204 EDI File

 ISA*00**00**ZZ*BABELMENT*02*HLNF*171228*1508*U*00401*000000001*0*P*:~

GS*SM*MGACUMENT*HLNF*20171228*150809*1*X*004010~

ST*204*000010001~

B2**HLNF**HLNF0000T**PP~

B2A*00*LT~

L11*HLNF0058T*BM*Load ID~

NTE**~

N1*BT*Client Manager c/o Babelway Partner Technologies*93*LOC16~

N3*911 South Avenue~

N4*Atlanta*GA*30092*US~

S5*1*CL~

L11*HLNF0058T*CR*Load ID~

G62*37*20180103*I*0800~

G62*38*20180103*K*1630~

N1*SH*INDIANA COMPANY LLC*93*30441~

N4*BOSTON*MA*08180*US~

G61*IC*Peter*TE*800-685-0655~

L5**Metal Pieces***PLT*SN96*SI~

G62*53*20180104*G*0800~

G62*54*20180104*L*1700~

N1*CN*Davis Metal Works*93*30007~

N4*City Park*WI*611158212*US~

S5*3*CU~

L11*HLNF0058T*CR*Load ID~

SE*45*000010001~

GE*1*1~

IEA*1*000000001~                                  

 ESL Files

The Anypoint B2B Connectors use a YAML format called EDI Schema Language (ESL) to represent EDI schemas. Basic ESLs define the composition of EDI messages with structures, segments, composites, and elements

Components of an ESL Document
  • the EDI standard
  • the version of that standard
  • any combination structures, segments, composites, and element definitions
Sample 204.esl file
idStructure identifier
nameStructure name
classA class of structure that is equivalent to an X12 functional group identifier. This is ignored in EDIFACT structure definitions
idRefThe referenced segment ID.
positionThe segment position within the section. With the EDI convention these are numeric values that can include leading zeros, so these are quoted and handled as strings.
usageUsage code definition:C for ConditionalM for MandatoryO for OptionalU for Unused, the item should not appear at all in the data.I for Ignored, this can be present in data, as in the case of the HL segments it must be present, but is not visible for the user in metadata.
countmaximum repetition count value that can be a number or the special value >1 . This means any number of repeats. A count value of 1 is used if not specified.
X12 Connector in MuleSoft

There are 3 operations in X12 Connector

Read(<x12:read>) :Transform an input stream of EDI text into the maps and lists structure of the EDI data.

Write(<x12:write>) :Transform the maps and lists structure of EDI data into an EDI text stream.

Write batch(<x12:write-batch>) :Merge individual EDIFACT messages created and accumulated over a period of time.

X12 in Anypoint Studio

1.Open Anypoint Studio-> Click Search in Exchange->Click on Add Account if Anypoint Credentials are not configured->Type X12 and Add Modules in Studio

This is what you should get once you add X12 Module

Configuring X12 Connector
  • Once any operation is dragged and dropped into the canvas,the x12 Read Operation takes the configuration from the x12 jar below

Read an EDI File and convert it to required format(X12 Read)
  • X12 Read has empty configuration or default.
  • Drag and drop a listener and provide configuration
  • In Transform Message we have

%dw 2.0

output application/json

Payload

Save it and run the project

  • In postman or ARC,in body section select type as text and put an EDI File
Using Configuration

In x12 we cannot process a file multiple times, but for testing if you need to process the same file again you can enable the  Require Unique Interchanges  parameter to false.

Some other configurations are:
Allow unknown segments: Allow unknown segments in a transaction set. If false, a transaction containing any unknown segments is rejected; if true, unknown segments are ignored and the transaction is not rejected.
Enforce segment repeats: Enforce segment repetition count limits in a transaction set. If true, a transaction with a segment repeated too many times is rejected; if false, the transaction is not rejected. In either case the error is reported in 997/999 acknowledgments.
Store time-to-live: Minimum number of days to store interchange, group, and transaction set numbers for checking uniqueness.
Require unique groups: Enforce globally unique Group Control Numbers (GS06) for received functional groups.
Require unique interchanges: Require unique Interchange Control Numbers (ISA13) for received interchanges.
997 Acknowledgement(functional Acknowledgment):
– As a technical response, an EDI 997 confirms the receipt and acceptance of the main message.
– It can also state the approval or rejection of the previously submitted interchange and a detailed list of errors as a functional response.
– Location of 997 acknowledgement in EDI file is converted to JSON (Get it from X12 Read) in JSON File.Go to FunctionalAcksGenerated section  and then heading  section.
– Under the Parser tab you get an option to set acknowledge every transaction to true to generate 997 functional acknowledgement

Write to X12 EDI

Here we can convert java objects to an EDI file.

  • Drag and drop a listener and provide configuration
  • In EDI Json Transform Message give the payload with mime type as application/java
  • Note:If you have any datetime fields provide as DateTime after the value

  • In x12 configuration,you can provide the similar configuration as Read and then

 From Output EDI MIME Type select APPLICATION_EDIX12.

  • In EDI Data transform message add this:

%dw 2.0

output text/plain —

payload as String

Sample Code for x12 in Mule 4:

<?xml version=”1.0″ encoding=”UTF-8″?>

<mule xmlns:ee=”http://www.mulesoft.org/schema/mule/ee/core” xmlns:x12=”http://www.mulesoft.org/schema/mule/x12″

xmlns:http=”http://www.mulesoft.org/schema/mule/http”

xmlns=”http://www.mulesoft.org/schema/mule/core” xmlns:doc=”http://www.mulesoft.org/schema/mule/documentation” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd

http://www.mulesoft.org/schema/mule/x12 http://www.mulesoft.org/schema/mule/x12/current/mule-x12.xsd

http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd”>

<http:listener-config name=”HTTP_Listener_config” doc:name=”HTTP Listener config” doc:id=”59e38289-3477-41ad-a1f6-770f268b947c” >

<http:listener-connection host=”0.0.0.0″ port=”8081″ />

</http:listener-config>

<http:listener-config name=”HTTP_Listener_config1″ doc:name=”HTTP Listener config” doc:id=”636a3c3e-83b5-44d7-ac2f-9b18d5cabc30″ >

<http:listener-connection host=”0.0.0.0″ port=”8082″ />

</http:listener-config>

<x12:config name=”X12_EDI_Config” doc:name=”X12 EDI Config” doc:id=”95d45c26-488f-42aa-8834-edcf4bee6656″ requireUniqueInterchanges=”false” />

<http:listener-config name=”HTTP_Listener_config2″ doc:name=”HTTP Listener config” doc:id=”95c11d14-17af-4a94-9793-21d0eb61ad76″ >

<http:listener-connection host=”0.0.0.0″ port=”8083″ />

</http:listener-config>

<flow name=”ReadEDIData” doc:id=”f720d9aa-1881-4268-9f2f-e4f5dc012dc3″ >

<http:listener doc:name=”Listener” doc:id=”f6cfe56d-5c54-42b2-87b4-565ee9455543″ config-ref=”HTTP_Listener_config” path=”/read”/>

<x12:read doc:name=”X12 Read EDI” doc:id=”d3231aef-22bf-411e-a67e-44af962cbab7″ config-ref=”X12_EDI_Config”/>

<ee:transform doc:name=”EDI to JSON” doc:id=”0ddb3e58-9fbd-41e9-9c0c-a6b56778abde” >

<ee:message >

<ee:set-payload ><![CDATA[%dw 2.0

output application/json

payload]]></ee:set-payload>

</ee:message>

</ee:transform>

</flow>

<flow name=”WriteToEDI” doc:id=”c52946bc-2dbb-436b-a241-2d3415ced0ac” >

<http:listener doc:name=”WriteToED” doc:id=”5ba6ba2d-a40f-4e20-b28e-14976bc19587″ config-ref=”HTTP_Listener_config1″ path=”/write”/>

<ee:transform doc:name=”EDI Data” doc:id=”b52fa955-f700-454a-9cfb-ddab325150cb” >

<ee:message >

<ee:set-payload ><![CDATA[%dw 2.0

output application/json

{

    Delimiters: “*>U~”,

    TransactionSets: {

        “v004010”: {

             “204”: [{

                 “Interchange”: {

            “ISA12”: “00400”,

             “ISA05”: “ZZ”,

             “ISA08”: “123456789012345”,

             “ISA07”: “ZZ”,

             “ISA06”: “ABCDEFGHIJKLMNO”

            },

            “Group”: {

            “GS05”: 64020000,

            “GS07”: “X”,

“GS06”: 2100,

            “GS08”: “004010”,

            “GS01”: “SM”,

            “GS03”: “999999999”,

            “GS02”: “4405197800”

          },

           “SetHeader”: {

                        “ST01”: “204”,

                        “ST02”: “0001”

                    },

                    “Heading”: {

                        “020_B2”: {

                            “B206”: “PP”,

                            “B204”: “9999955559”,

                            “B202”: “XXXX”

                        },

                        “030_B2A”: {

                            “B2A01”: “04”

                        }

                    },

                     Detail: {

                      “0300_Loop”: [

                            {

                                “010_S5”: {

                                    “S504”: “L”,

                                    “S505”: 2444,

                                    “S502”: “CL”,

                                    “S503”: 27800,

                                    “S501”: 1,

                                    “S508”: “E”,

                                    “S506”: “CA”,

                                    “S507”: 1016

                                }, }]

                     }, 

                     “Summary”: {

                        “010_L3”: {

                            “L309”: 1016,

 “L311”: 2444,

                            “L310”: “E”,

                            “L302”: “G”,

                            “L301”: 27800,

                            “L312”: “L”

                        }

                    }}]}}

}]]></ee:set-payload>

</ee:message>

</ee:transform>

<x12:write doc:name=”Java To EDI” doc:id=”6fe604f8-ed75-442c-930f-083782b466bc” outputEdiMimeType=”APPLICATION_EDIX12″ config-ref=”X12_EDI_Config”/>

<ee:transform doc:name=”Transform Message” doc:id=”6a1586a3-5a32-48fd-bef0-8a9c2f68eb41″ >

<ee:message >

<ee:set-payload ><![CDATA[%dw 2.0

output text/plain

payload as String]]></ee:set-payload>

</ee:message>

</ee:transform>

</flow>

</mule>

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.