Private Sub cmdTranslate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTranslate.Click
'This is just an example program to demonstrate how to translate an EDI 835 file
'in VB .NET using the Framework EDI .NET hybrid component
Dim oEdiDoc As ediDocument
Dim oSchema As ediSchema
Dim oSchemas As ediSchemas
Dim oSegment As ediDataSegment
Dim i As Integer
Dim sPath As String
Dim sEntity As String
Dim sQlfr As String
Dim sLXID As String
Dim sSefFile As String
Dim sEdiFile As String
Dim nArea As Integer
Dim sSegmentID As String
Dim sLoopSection As String
Dim sValue As String
Me.Cursor = Cursors.WaitCursor
sPath = AppDomain.CurrentDomain.BaseDirectory
sSefFile = "835_X091.SEF"
sEdiFile = "835.x12"
'instantiate edi document object
oEdiDoc = New ediDocument
'change the cursor type to forward to improve speed performance
oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly
'disable internal standard reference library to be memory effiecient
oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = False
'Loads SEF file
oEdiDoc.ImportSchema(sPath & sSefFile, 0)
'Load EDI file
oEdiDoc.LoadEdi(sPath & sEdiFile)
'Gets first segment
oSegment = oEdiDoc.FirstDataSegment
'iterate through all the segments in the EDI file
Do While Not oSegment Is Nothing
nArea = oSegment.Area
sSegmentID = oSegment.ID
sLoopSection = oSegment.LoopSection
If nArea = 0 Then
If sLoopSection = "" Then
If sSegmentID = "ISA" Then
sValue = oSegment.DataElementValue(1) 'Authorization Information Qualifier
sValue = oSegment.DataElementValue(2) 'Authorization Information
sValue = oSegment.DataElementValue(3) 'Security Information Qualifier
sValue = oSegment.DataElementValue(4) 'Security Information
sValue = oSegment.DataElementValue(5) 'Interchange ID Qualifier
sValue = oSegment.DataElementValue(6) 'Interchange Sender ID
sValue = oSegment.DataElementValue(7) 'Interchange ID Qualifier
sValue = oSegment.DataElementValue(8) 'Interchange Receiver ID
sValue = oSegment.DataElementValue(9) 'Interchange Date
sValue = oSegment.DataElementValue(10) 'Interchange Time
sValue = oSegment.DataElementValue(11) 'Interchange Control Standards Identifier
sValue = oSegment.DataElementValue(12) 'Interchange Control Version Number
sValue = oSegment.DataElementValue(13) 'Interchange Control Number
sValue = oSegment.DataElementValue(14) 'Acknowledgment Requested
sValue = oSegment.DataElementValue(15) 'Usage Indicator
sValue = oSegment.DataElementValue(16) 'Component Element Separator
ElseIf sSegmentID = "GS" Then
sValue = oSegment.DataElementValue(1) 'Functional Identifier Code
sValue = oSegment.DataElementValue(2) 'Application Sender's Code
sValue = oSegment.DataElementValue(3) 'Application Receiver's Code
sValue = oSegment.DataElementValue(4) 'Date
sValue = oSegment.DataElementValue(5) 'Time
sValue = oSegment.DataElementValue(6) 'Group Control Number
sValue = oSegment.DataElementValue(7) 'Responsible Agency Code
sValue = oSegment.DataElementValue(8) 'Version / Release / Industry Identifier Code
End If 'sSegmentID
End If 'sLoopID
ElseIf nArea = 1 Then
If sLoopSection = "" Then
If sSegmentID = "ST" Then
sValue = oSegment.DataElementValue(1) 'Transaction Set Identifier Code
sValue = oSegment.DataElementValue(2) 'Transaction Set Control Number
ElseIf sSegmentID = "BPR" Then
If oSegment.DataElementValue(1) = "C" Then
sValue = oSegment.DataElementValue(2) 'Monetary Amount
sValue = oSegment.DataElementValue(3) 'Credit/Debit Flag Code
sValue = oSegment.DataElementValue(4) 'Payment Method Code
sValue = oSegment.DataElementValue(5) 'Payment Format Code
sValue = oSegment.DataElementValue(6) '(DFI) ID Number Qualifier
ListBox1.Items.Add("BankFromABA: " & oSegment.DataElementValue(7)) '(DFI) Identification Number
sValue = oSegment.DataElementValue(8) 'Account Number Qualifier
ListBox1.Items.Add("BankFromAccountNo: " & oSegment.DataElementValue(9)) 'Account Number
ListBox1.Items.Add("InsFedTaxID: " & oSegment.DataElementValue(10)) 'Originating Company Identifier
sValue = oSegment.DataElementValue(11) 'Originating Company Supplemental Code
sValue = oSegment.DataElementValue(12) '(DFI) ID Number Qualifier
ListBox1.Items.Add("BankToABA: " & oSegment.DataElementValue(13)) '(DFI) Identification Number
sValue = oSegment.DataElementValue(14) 'Account Number Qualifier
ListBox1.Items.Add("BankToAccountNo: " & oSegment.DataElementValue(15)) 'Account Number
ListBox1.Items.Add("TransferDate: " & oSegment.DataElementValue(16)) 'Date
End If
ElseIf sSegmentID = "TRN" Then
If oSegment.DataElementValue(1) = "1" Then
ListBox1.Items.Add("BankFromAccountNo: " & oSegment.DataElementValue(2))
ListBox1.Items.Add("InsFedTaxID: " & oSegment.DataElementValue(3))
End If
ElseIf sSegmentID = "DTM" Then
sValue = oSegment.DataElementValue(1) 'Date/Time Qualifier
ListBox1.Items.Add("TransferDate: " & oSegment.DataElementValue(2))
End If
ElseIf sLoopSection = "N1" Then
If sSegmentID = "N1" Then
sEntity = oSegment.DataElementValue(1) 'get loop entity qualifier to identity each N1 loop instances
End If
If sEntity = "PR" Then 'payer information
If sSegmentID = "N1" Then
sValue = oSegment.DataElementValue(1) ' Entity Identifier Code (98)
ListBox1.Items.Add("InsName: " & oSegment.DataElementValue(2)) ' Name (93)
sValue = oSegment.DataElementValue(3) ' Identification Code Qualifier (66)
sValue = oSegment.DataElementValue(4) ' Identification Code (67)
sValue = oSegment.DataElementValue(5) ' Entity Relationship Code (706)
sValue = oSegment.DataElementValue(6) ' Entity Identifier Code (98)
ElseIf sSegmentID = "N3" Then
ListBox1.Items.Add("InsAddr: " & oSegment.DataElementValue(1)) ' Address Information (166)
sValue = oSegment.DataElementValue(2) ' Address Information (166)
ElseIf sSegmentID = "N4" Then
ListBox1.Items.Add("InsCity: " & oSegment.DataElementValue(1)) ' City Name (19)
ListBox1.Items.Add("InsState: " & oSegment.DataElementValue(2)) ' State or Province Code (156)
ListBox1.Items.Add("InsZip: " & oSegment.DataElementValue(3)) ' Postal Code (116)
sValue = oSegment.DataElementValue(4) ' Country Code (26)
sValue = oSegment.DataElementValue(5) ' Location Qualifier (309)
sValue = oSegment.DataElementValue(6) ' Location Identifier (310)
ElseIf sSegmentID = "REF" Then
If oSegment.DataElementValue(1) = "2U" Then
ListBox1.Items.Add("InsMedIntID: " & oSegment.DataElementValue(2)) ' Reference Identification (127)
sValue = oSegment.DataElementValue(3) ' Description (352)
sValue = oSegment.DataElementValue(4, 1) ' Reference Identification Qualifier (128)
sValue = oSegment.DataElementValue(4, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(4, 3) ' Reference Identification Qualifier (128)
sValue = oSegment.DataElementValue(4, 4) ' Reference Identification (127)
sValue = oSegment.DataElementValue(4, 5) ' Reference Identification Qualifier (128)
sValue = oSegment.DataElementValue(4, 6) ' Reference Identification (127)
End If
End If
ElseIf sEntity = "PE" Then 'payee information
If sSegmentID = "N1" Then
sValue = oSegment.DataElementValue(1) ' Entity Identifier Code (98)
ListBox1.Items.Add("HospName: " & oSegment.DataElementValue(2)) ' Name (93)
sValue = oSegment.DataElementValue(3) ' Identification Code Qualifier (66)
ListBox1.Items.Add("HospProviderNo: " & oSegment.DataElementValue(4)) ' Identification Code (67)
sValue = oSegment.DataElementValue(5) ' Entity Relationship Code (706)
sValue = oSegment.DataElementValue(6) ' Entity Identifier Code (98)
End If
End If 'sEntity
End If 'sLoopSection
ElseIf nArea = 2 Then
If sSegmentID = "LX" Then
sLXID = oSegment.DataElementValue(1)
End If
If sLXID = "961221" Then
If sLoopSection = "LX" Then
If sSegmentID = "TS3" Then
ListBox1.Items.Add("HospProviderNo (LX): " & oSegment.DataElementValue(1))
ListBox1.Items.Add("InFacilityType: " & oSegment.DataElementValue(2))
ListBox1.Items.Add("InpatientClaim: " & oSegment.DataElementValue(4))
ListBox1.Items.Add("InTotalCharges: " & oSegment.DataElementValue(5))
ListBox1.Items.Add("InPaidAmount: " & oSegment.DataElementValue(9))
ListBox1.Items.Add("InAdjustment: " & oSegment.DataElementValue(11))
ElseIf sSegmentID = "TS2" Then
ListBox1.Items.Add("DiagRelatedGroupAmnt: " & oSegment.DataElementValue(1))
ListBox1.Items.Add("FedSpecAmnt: " & oSegment.DataElementValue(2))
ListBox1.Items.Add("DisproportionShareAmnt: " & oSegment.DataElementValue(4))
ListBox1.Items.Add("CapitalAmnt: " & oSegment.DataElementValue(5))
ListBox1.Items.Add("IndirectMedEduAmnt: " & oSegment.DataElementValue(6))
End If
ElseIf sLoopSection = "LX;CLP" Then
If sSegmentID = "CLP" Then
ListBox1.Items.Add("InSubmitter: " & oSegment.DataElementValue(1)) ' Claim Submitter's Identifier (1028)
sValue = oSegment.DataElementValue(2) ' Claim Status Code (1029)
ListBox1.Items.Add("InTotalCharges: " & oSegment.DataElementValue(3)) ' Monetary Amount (782)
ListBox1.Items.Add("InPaidAmount: " & oSegment.DataElementValue(4)) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(5) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(6) ' Claim Filing Indicator Code (1032)
ListBox1.Items.Add("PayerClaimControlNo: " & oSegment.DataElementValue(7)) ' Reference Identification (127)
ListBox1.Items.Add("InFacilityType: " & oSegment.DataElementValue(8)) ' Facility Code Value (1331)
ListBox1.Items.Add("InpatientClaim: " & oSegment.DataElementValue(9)) ' Claim Frequency Type Code (1325)
sValue = oSegment.DataElementValue(10) ' Patient Status Code (1352)
sValue = oSegment.DataElementValue(11) ' Diagnosis Related Group (DRG) Code (1354)
sValue = oSegment.DataElementValue(12) ' Quantity (380)
sValue = oSegment.DataElementValue(13) ' Percent (954)
ElseIf sSegmentID = "CAS" Then
If oSegment.DataElementValue(1) = "CO" Then
sValue = oSegment.DataElementValue(2) ' Claim Adjustment Reason Code (1034)
ListBox1.Items.Add("InAdjustment: " & oSegment.DataElementValue(3))
sValue = oSegment.DataElementValue(4) ' Quantity (380)
End If
ElseIf sSegmentID = "NM1" Then
sValue = oSegment.DataElementValue(1) ' Entity Identifier Code (98)
sValue = oSegment.DataElementValue(2) ' Entity Type Qualifier (1065)
ListBox1.Items.Add("InLastname: " & oSegment.DataElementValue(3)) ' Name Last or Organization Name (1035)
ListBox1.Items.Add("InFirstname: " & oSegment.DataElementValue(4)) ' Name First (1036)
ListBox1.Items.Add("InMiddlename: " & oSegment.DataElementValue(5)) ' Name Middle (1037)
sValue = oSegment.DataElementValue(6) ' Name Prefix (1038)
sValue = oSegment.DataElementValue(7) ' Name Suffix (1039)
sValue = oSegment.DataElementValue(8) ' Identification Code Qualifier (66)
ListBox1.Items.Add("InHIC: " & oSegment.DataElementValue(9)) ' Identification Code (67)
sValue = oSegment.DataElementValue(10) ' Entity Relationship Code (706)
sValue = oSegment.DataElementValue(11) ' Entity Identifier Code (98)
ElseIf sSegmentID = "MIA" Then
If Val(oSegment.DataElementValue(1)) = 0 Then
ListBox1.Items.Add("InPaidAmount: " & oSegment.DataElementValue(7))
End If
ElseIf sSegmentID = "DTM" Then
If oSegment.DataElementValue(1) = "232" Then
ListBox1.Items.Add("InHospFrom: " & oSegment.DataElementValue(2))
ElseIf oSegment.DataElementValue(1) = "233" Then
ListBox1.Items.Add("InHospTo: " & oSegment.DataElementValue(2))
End If
End If
End If
ElseIf sLXID = "961213" Then
If sLoopSection = "LX" Then
If sSegmentID = "TS3" Then
ListBox1.Items.Add("HospProviderNo (TS3): " & oSegment.DataElementValue(1))
ListBox1.Items.Add("OutFacilityType: " & oSegment.DataElementValue(2))
ListBox1.Items.Add("OutTotalCharges: " & oSegment.DataElementValue(4))
ListBox1.Items.Add("OutTotalCharges: " & oSegment.DataElementValue(5))
ListBox1.Items.Add("OutPaidAmount: " & oSegment.DataElementValue(6))
ListBox1.Items.Add("InPaidAmount: " & oSegment.DataElementValue(9))
ListBox1.Items.Add("OutAdjustment: " & oSegment.DataElementValue(11))
End If
ElseIf sLoopSection = "LX;CLP" Then
If sSegmentID = "CLP" Then
ListBox1.Items.Add("OutSubmitter: " & oSegment.DataElementValue(1))
ListBox1.Items.Add("OutTotalCharges: " & oSegment.DataElementValue(3))
ListBox1.Items.Add("OutPaidAmount: " & oSegment.DataElementValue(4))
ListBox1.Items.Add("OutFacilityType: " & oSegment.DataElementValue(8))
ListBox1.Items.Add("OutpatientClaim: " & oSegment.DataElementValue(9))
ElseIf sSegmentID = "CAS" Then
If oSegment.DataElementValue(1) = "CO" Then
ListBox1.Items.Add("OutAdjustment: " & oSegment.DataElementValue(3))
End If
ElseIf sSegmentID = "NM1" Then
ListBox1.Items.Add("OutLastname: " & oSegment.DataElementValue(3))
ListBox1.Items.Add("OutFirstname: " & oSegment.DataElementValue(4))
ListBox1.Items.Add("OutMiddlename: " & oSegment.DataElementValue(5))
If oSegment.DataElementValue(8) = "HN" Then
ListBox1.Items.Add("OutHIC: " & oSegment.DataElementValue(9))
End If
ElseIf sSegmentID = "MIA" Then
If Val(oSegment.DataElementValue(1)) = 0 Then
ListBox1.Items.Add("InPaidAmount: " & oSegment.DataElementValue(7))
End If
ElseIf sSegmentID = "DTM" Then
ListBox1.Items.Add("OutServiceDate: " & oSegment.DataElementValue(2))
End If
End If
End If
ElseIf nArea = 3 Then
If sLoopSection = "" Then
If sSegmentID = "PLB" Then
sValue = oSegment.DataElementValue(1) ' Reference Identification (127)
ListBox1.Items.Add("HospProviderNo (PLB): " & oSegment.DataElementValue(2)) ' Date (373)
sValue = oSegment.DataElementValue(3, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(3, 2) ' Reference Identification (127)
ListBox1.Items.Add("CapitalPassThru: " & oSegment.DataElementValue(4)) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(5, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(5, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(6) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(7, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(7, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(8) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(9, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(9, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(10) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(11, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(11, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(12) ' Monetary Amount (782)
sValue = oSegment.DataElementValue(13, 1) ' Adjustment Reason Code (426)
sValue = oSegment.DataElementValue(13, 2) ' Reference Identification (127)
sValue = oSegment.DataElementValue(14) ' Monetary Amount (782)
End If
End If
End If
'Get next segment
'Use the set method of the object to dispose of the previous instance of the object before instantiation
oSegment.Set(oSegment, oSegment.Next) 'oSegment = oSegment.Next
Loop
Me.Cursor = Cursors.Default
MsgBox("Done")
cmdTranslate.Enabled = False
End Sub