I frequently get the following messages;
Message: Hierarchical Loop 21 expects Parent ID 31 which did not occur preceding it.
Message: Hierarchical Loop 14 expects Parent ID 44 which did not occur preceding it.
Message: Hierarchical Loop 14 expects Parent ID 28 which did not occur preceding it.
They are followed by a message saying I can change these to warnings, if I want.
Before I change these to a warning, I would like to work with the vendor providing the data and if they have a problem with their software, see if they can identify and correct it. In order to do that I need to be able to translate these messages into something
they might understand (as well as me).
Is there something that I can reference that will translate these messages into ANSI 837/5010 terminology?
Sep 18, 2013 at 10:45 PM
Edited Sep 19, 2013 at 11:21 AM
See here for spec on HL:
The hieriarchical loop defines a unique section in a transaction (between ST and SE) segments. A transaction doesn't have to have hierarchical loops, but if it does the ID of each must be unique within the transaction and all segments following the HL segment
is assumed to be part of that loop until another HL segment is encountered.
The 1st element in the HL segment is its ID, but the second element is it's parent ID and must point to another HL in the transaction.
Though it is not a hard and fast rule that the parent ID occurs before it, this is typically how it works: each HL is sequential numbered and the child HLs appear after the parent HL.
The fact that the parent ID has a higher number than the ID is suspect. This could still be a valid file if the HL segment 31 actually does occur after the HL 21. You can check the file for this first. Most likely, the file is invalid and perhaps that just
reversed the ID and parent ID. The fact that you have Loop 14 throwing an exception that it has parent 44 and parent 28 is also suspect. The loop should only have one parent, thus it's hierarchical.
Dannie, thanks again for your timely help and patience with a dilettante.
I am working on a program that will generate readable output for these files that have issues. I think I would like to create HTML. I was going to use your example (converted to VB of course);
var htmlService = new X12HtmlTransformationService(new X12EdiParsingService(suppressComments: false));
Stream ediFile = new FileStream("c:\\5010_Example1_HealthInsurance.txt", FileMode.Open, FileAccess.Read);
string html = htmlService.Transform(new StreamReader(ediFile).ReadToEnd());
Is there a way of passing the parameter to convert the errors into warnings to X12HtmlTransformationService? so that I would get HTML that looks reasonable for a file with these types of syntax errors?
I have a second question regarding the HTML generation program I am trying to write. How do I pass the "encoding" parameter? Some of my files are UNICODE, and some are UTF8. Here is my code so far;
Dim strArgument As String
Dim aryArgument As Array
Dim strInputFile As String = ""
Dim strOutputFile As String = ""
For Each strArgument In Environment.GetCommandLineArgs()
aryArgument = strArgument.Split("=")
Select Case aryArgument(0).ToString.ToLower
strInputFile = aryArgument(1)
strOutputFile = aryArgument(1)
If strOutputFile = "" _
strOutputFile = strInputFile.Substring(0, strInputFile.LastIndexOf(".")) & ".html"
Dim fsTemp As FileStream = New FileStream(strInputFile, FileMode.Open)
Dim strHeader(106) As Byte
fsTemp.Read(strHeader, 0, 106)
fsTemp = Nothing
Dim bolChunkified As Boolean = False
If strHeader(105) <> 13 And strHeader(105) <> 10 _
For i = 0 To 104
bolChunkified = (bolChunkified Or (strHeader(i) = 10 Or strHeader(i) = 13))
Dim encoding As Text.Encoding
Dim strEncoding As String
If (strHeader(1) = 0 And strHeader(3) = 0 And strHeader(5) = 0) _
encoding = Text.Encoding.Unicode
strEncoding = "UNICODE"
encoding = Text.Encoding.UTF8
strEncoding = "UTF8"
Dim inStream As FileStream
inStream = New FileStream(strInputFile, FileMode.Open, FileAccess.Read)
Dim rdrTemp As StreamReader = New StreamReader(inStream)
Dim strTemp As String = rdrTemp.ReadToEnd
inStream = Nothing
If bolChunkified _
strTemp = Replace(Replace(strTemp, vbCr, ""), vbLf, "")
Dim baTemp As Byte()
baTemp = Text.Encoding.UTF8.GetBytes(strTemp)
Dim memStream As New MemoryStream(baTemp)
Dim htmlService = New X12HtmlTransformationService(New X12EdiParsingService(suppressComments:=False))
Dim strHTML As String = htmlService.Transform(New StreamReader(memStream).ReadToEnd())
Dim objWriter As New System.IO.StreamWriter(strOutputFile)
It bombs saying "First segment must start with ISA" because the file I am trying to process is UNICODE. I have the code to identify if it is unicode, but I don't know how to get it to the parser.
Dannie, is what I am trying to do (get an HTML view of a file with syntax errors) reasonable?
Dannie, Is there a way to produce the HTML version of the ANSI-837 file using your API with the following conditions?
A) The incoming file is unicode, not utf-8.
B) The file has syntax errors, specifically Loop Hierarchy errors.
If there is documentation that I can read that defines how to call the API to do what I need, I will gladly read it, just tell me where to go:)