procedure TForm1.cmdTranslateClick(Sender: TObject);
        // This is just an example to show how to translate a HIPAA 837 4010 X096 EDI X12 file 
        // in Delphi with Framework EDI component

        var
           oEdiDoc : IediDocument;
           oSchemas : IediSchemas;
           oSegment : IediDataSegment;

           sPath : string;
           sHlEntity : string;
           sNm1Entity : string;
           sQlfr : string;
           sSefFile : string;
           sEdiFile : string;
           sSegmentID : string;
           nArea : integer;
           sLoopSection : string;
           sValue : string;


        begin
           cmdTranslate.Enabled := False;

           sPath := Trim(GetCurrentDir) + '\';'
           sSefFile := '837_X096.SEF';
           sEdiFile := '837_X096.X12';

           //instantiate edi document object
           oEdiDoc := CoediDocument.Create();

           //Change cursor type to forwardonly to improve performance
           oEdiDoc.CursorType := 1;     //forwardOnly

           //disable internal standard reference library
           oSchemas := oEdiDoc.GetSchemas;
           oSchemas.EnableStandardReference := False;

           //Load SEF file
           oEdidoc.LoadSchema(sPath + sSefFile,0);

           //Load EDI file
           oEdiDoc.LoadEdi(sPath + sEdiFile);

           //traverse through all segements in the EDI file

           //get first data segment
           oSegment := oEdiDoc.FirstDataSegment as IediDataSegment;
           while oSegment <> Nil do begin 

                //identify segments by their area, the loop section they are in, and their segment id
              nArea := oSegment.Area;
              sLoopSection := oSegment.LoopSection;
              sSegmentID := oSegment.ID;

              if nArea = 0 then begin
                if sSegmentID = 'ISA' then begin
                   //map data elements of ISA here
                   sValue := oSegment.DataElementValue[13,0];  //Interchange Control Number
                   ShowMessage('Interchange Control Number = ' + sValue);
                end
                else if sSegmentID = 'GS' then begin
                   //map data elements of GS here
                   sValue := oSegment.DataElementValue[6,0];   //Group Control Number
                   ShowMessage('Group Control Number = ' + sValue);
                end;

              end
              else if nArea = 1 then begin
                 if sLoopSection = '' then begin
                    if sSegmentID = 'ST' then begin
                        //map data elements of ST here
                        sValue := oSegment.DataElementValue[2,0];   //Transaction Set Control Number
                        ShowMessage('Transaction Set Control Number = ' + sValue);
                    end
                    else if sSegmentID = 'BHT' then begin
                        //map data elements of BHT here
                        sValue := oSegment.DataElementValue[3,0];   //reference id
                        ShowMessage('reference id = ' + sValue);
                        sValue := oSegment.DataElementValue[4,0];   //date
                    end;
                 end
                 else if sLoopSection = 'NM1' then begin
                    if sSegmentID = 'NM1' then begin    //get entity id of NM1 loop
                       sNm1Entity := oSegment.DataElementValue[1,0];
                    end;
                    if sNm1Entity = '41' then begin  //SUBMITTER
                       if sSegmentID = 'NM1' then begin
                          sValue := oSegment.DataElementValue[3,0];
                          ShowMessage('Submitter Name = ' + sValue);
                          sValue := oSegment.DataElementValue[9,0];
                       end
                       else if sSegmentID = 'PER' then begin
                          sValue := oSegment.DataElementValue[2,0];   //Contact Name
                          sValue := oSegment.DataElementValue[4,0];   //Telephone Number
                       end;
                    end
                    else if sNm1Entity = '40' then begin  //RECEIVER
                       if sSegmentID = 'NM1' then begin
                          sValue := oSegment.DataElementValue[3,0];
                          ShowMessage('Receiver Name = ' + sValue);
                          sValue := oSegment.DataElementValue[9,0];
                       end;
                    end;
                 end;
              end
              else if nArea = 2 then begin
                 if (sLoopSection = 'HL') and (sSegmentID = 'HL') then begin    //get entity id of HL loop
                    sHlEntity := oSegment.DataElementValue[3,0];
                 end;
                 if sHlEntity = '20' then begin //BILLING POVIDER
                    if sLoopSection = 'HL' then begin
                    end
                    else if sLoopSection = 'HL;NM1' then begin
                       if sSegmentID = 'NM1' then begin
                          sNm1Entity := oSegment.DataElementValue[1,0];
                       end;
                       if sNm1Entity = '85' then begin  //BILLING PROVIDER NAME
                          if sSegmentID = 'NM1' then begin
                             sValue := oSegment.DataElementValue[3,0];
                             ShowMessage('Billing Provider Name = ' + sValue);
                             sValue := oSegment.DataElementValue[9,0];
                          end
                          else if sSegmentID = 'N3' then begin  //ADDRESS
                             sValue := oSegment.DataElementValue[1,0];
                          end
                          else if sSegmentID = 'N4' then begin  //CITY STATE ZIP
                             sValue := oSegment.DataElementValue[1,0];
                             sValue := oSegment.DataElementValue[2,0];
                             sValue := oSegment.DataElementValue[3,0];
                          end
                          else if sSegmentID = 'REF' then begin
                          end;  //sSegmentID
                       end;  //sNm1Entity
                    end;   //sLoopSection
                 end
                 else if sHlEntity = '22' then begin  //SUBSCRIBER
                    if sLoopSection = 'HL' then begin
                       if sSegmentID = 'SBR' then begin
                       end;
                    end
                    else if sLoopSection = 'HL;NM1' then begin
                       if sSegmentID = 'NM1' then begin
                          sNm1Entity := oSegment.DataElementValue[1,0];
                       end;
                       if sNm1Entity = 'IL' then begin  //SUBSCRIBER NAME
                          if sSegmentID = 'NM1' then begin
                             sValue := oSegment.DataElementValue[3,0];  //LASTNAME
                             sValue := oSegment.DataElementValue[4,0];  //FIRSTNAME
                             ShowMessage('Patient Firstname = ' + sValue);
                             sValue := oSegment.DataElementValue[5,0];  //MIDDLE INITIAL
                             sValue := oSegment.DataElementValue[9,0];  //ID NO
                          end
                          else if sSegmentID = 'N3' then begin
                             sValue := oSegment.DataElementValue[1,0];  //ADDRESS
                          end
                          else if sSegmentID = 'N4' then begin
                             sValue := oSegment.DataElementValue[1,0];  //CITY
                             sValue := oSegment.DataElementValue[2,0];  //STATE
                             sValue := oSegment.DataElementValue[3,0];  //ZIP
                          end
                          else if sSegmentID = 'DMG' then begin
                             sValue := oSegment.DataElementValue[2,0];  //DOB
                             sValue := oSegment.DataElementValue[3,0];  //SEX
                          end;
                       end
                       else if sNm1Entity = 'PR' then begin  //PAYER
                          if sSegmentID = 'NM1' then begin
                             sValue := oSegment.DataElementValue[3,0];  //NAME
                             sValue := oSegment.DataElementValue[9,0];  //ID NO
                          end;
                       end;  //sNm1Entity
                    end
                    else if sLoopSection = 'HL;CLM' then begin
                       if sSegmentID = 'CLM' then begin
                          sValue := oSegment.DataElementValue[1,0];  //PATIENT ACCOUNT NO.
                          ShowMessage('Patient Account No. = ' + sValue);
                          sValue := oSegment.DataElementValue[2,0];  //TOTAL CHARGES
                       end
                       else if sSegmentID = 'DTP' then begin  //DATE OF STATEMENT
                          if oSegment.DataElementValue[1,0] = '434' then begin
                             sValue := oSegment.DataElementValue[3,0]
                          end;
                       end
                       else if sSegmentID = 'CL1' then begin
                       end
                       else if sSegmentID = 'HI' then begin
                          sQlfr := oSegment.DataElementValue[1,1];
                          if sQlfr = 'BK' then begin  //PRINCIPAL DIAGNOSIS
                          end
                          else if sQlfr = 'BF' then begin  //OTHER DIAGNOSIS
                          end
                          else if sQlfr = 'BQ' then begin  //OTHER PROCEDURE INFO
                          end
                          else if sQlfr = 'BH' then begin  //OCCURENCE INFO
                          end
                          else if sQlfr = 'BE' then begin  //VALUE INFO
                          end
                          else if sQlfr = 'BG' then begin  //CONDITION INFO
                          end;
                       end;
                    end
                    else if sLoopSection = 'HL;CLM;SBR' then begin
                       if sSegmentID = 'SBR' then begin  //SUBSCRIBER INFORMATION
                       end
                       else if sSegmentID = 'DMG' then begin  //DEMOGRAPHIC
                          sValue := oSegment.DataElementValue[2,0];  //DOB
                          sValue := oSegment.DataElementValue[3,0];  //SEX
                       end;
                    end
                    else if sLoopSection = 'HL;CLM;SBR;NM1' then begin
                       if sSegmentID = 'NM1' then begin
                          sNm1Entity := oSegment.DataElementValue[1,0];
                       end;
                       if sNm1Entity = 'IL' then begin
                          if sSegmentID = 'NM1' then begin
                             sValue := oSegment.DataElementValue[3,0];  //LASTNAME
                             sValue := oSegment.DataElementValue[4,0];  //FIRSTNAME
                             sValue := oSegment.DataElementValue[5,0];  //MIDDLENAME
                             sValue := oSegment.DataElementValue[9,0];  //ID NO.
                          end
                          else if sSegmentID = 'N3' then begin
                              sValue := oSegment.DataElementValue[1,0];  //ADDRESS
                          end
                          else if sSegmentID = 'N4' then begin  //CITY STATE ZIP
                          end;
                       end
                       else if sNm1Entity = 'PR' then begin  //PAYER NAME
                       end;
                    end
                    else if sLoopSection = 'HL;CLM;LX' then begin
                       if sSegmentID = 'LX' then begin  //SERVICE LINE NUMBER
                       end
                       else if sSegmentID = 'SV2' then begin  //INSTITUTIONAL SERVICE LINE
                          sValue := oSegment.DataElementValue[1,0];
                          sValue := oSegment.DataElementValue[2,2];
                          sValue := oSegment.DataElementValue[3,0];
                          sValue := oSegment.DataElementvalue[5,0];
                       end
                       else if sSegmentID = 'DTP' then begin  //SERVICE LINE DATE
                       end;
                    end;   //sLoopSection
                 end;  //sHlEntity
              end
              else if nArea = 3 then begin
              end;  //nArea

              //get next segment
              oSegment := oSegment.Next as IediDataSegment;
           end;

           ShowMessage('Translate done');
           cmdTranslate.Enabled := true;

    end;

    Click here to download a trial version of the Framework EDI