· Jan 27, 2017

EDI 837 Parsing

I wanted to parse an EDI 837 X12 document to extract a value from CLM segments.  We tried with the below DTL and did not get it working. Appreciate any ideas. 

<transform sourceClass='EnsLib.EDI.X12.Document' targetClass='Test.Request.EDIX12ClaimSegments' sourceDocType='HIPAA_5010:837I' targetDocType='HIPAA_5010:CLM' create='new' language='objectscript' >
<assign value='source.{loop2000A().loop2000B().loop2300().CLM:ClaimSubmittersIdentifier}' property='target.ClaimInvoiceNo' action='set' />

Discussion (1)0
Log in or sign up to continue

You need to provide subscript values for the three loops.

This will give you the 1st member of each collection:


It's likely that in a real DTL you'll want to loop over each collection, because there will probably be multiple claims in the message.  Use ForEach to do that:

<foreach property='source.{loop2000A()}' key='k2000A' >
    <foreach property='source.{loop2000A(k2000A).loop2000B()}' key='k2000B' >
        <foreach property='source.{loop2000A(k2000A).loop2000B(k2000B).loop2300()}' key='k2300' >
            <assign value='source.{loop2000A(k2000A).loop2000B(k2000B).loop2300(k2300).CLM:ClaimSubmittersIdentifier}' property='target.ClaimInvoiceNo' action='set' />


Note that the way I have that now you'll end up with the last ClaimInvoiceNo in your target.  You'll need to adjust to make sure you process each of them.