This project has moved. For the latest updates, please go here.

unbundling 837 question

Developer
Jul 27, 2011 at 9:03 PM

I'm unbundling 837p files at the 2300 loop and converting to XML.  In the resulting XML the 2300 loop ends up as a child of Loop 2000B "SUBSCRIBER HIERARCHICAL LOOP" 85% of the time.  The xpath statement to get to the claim amount node, for example, is ./FunctionGroup/Transaction/HierarchicalLoop/HierarchicalLoop/Loop[@LoopId='2300']/CLM/CLM02

The problem is the other 15% of the time loop 2300 ends up a whole hierarchical loop level down as a child of loop 2000C "PATIENT HIERARCHICAL LOOP".  So to get to the same claim amount node xpath would be ./FunctionGroup/Transaction/HierarchicalLoop/HierarchicalLoop/HierarchicalLoop/Loop[@LoopId='2300']/CLM/CLM02

Is this supposed to be the case?  If so, is there a rule that determines when this will occur?

The problem is that the way I'm parsing the XML, I'm iterating on the lowest loop level available above 2300.  I thought this was 2000B, but now that 2000C has shown up, it's thrown a wrench into the process.  I can upload a deidentified 837 if that would help.

Thanks!

Coordinator
Jul 31, 2011 at 4:00 AM

Yes I am familiar with the scenario that you are speaking off.  The HL04 element of the subscriber hierarchical loop will actually indicates whether their is a patient hierarchical loop, but that probably doesn't help you any.  I will create a more complete document page with an example but here is a quick one to show how I would flatten this out so the resulting flat file includes all claims in the order they appear in the file:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="text" indent="yes"/>

  <xsl:template match="@* | node()">
      <xsl:apply-templates select="@* | node()"/>
  </xsl:template>
  
  <xsl:template match="ISA">
    <xsl:text>Billing Provider Name, Billing Provider ID, Subscriber Name, Patient Name, Patient Control Number, Total Claim Charge Amount&#x0A;</xsl:text>
  </xsl:template>
  
  <xsl:template match="Loop[@LoopId='2300']">
    <xsl:choose>
      <xsl:when test="../@LoopId = '2000B'">
        <xsl:call-template name="BillingProvider">
          <xsl:with-param name="HLoop" select="../../."/>
        </xsl:call-template>
        <xsl:call-template name="Subscriber">
          <xsl:with-param name="HLoop" select="../."/>
        </xsl:call-template>
        <xsl:call-template name="PatientName">
          <xsl:with-param name="Loop" select="../Loop[@LoopId='2010BA']"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="BillingProvider">
          <xsl:with-param name="HLoop" select="../../../."/>
        </xsl:call-template>
        <xsl:call-template name="Subscriber">
          <xsl:with-param name="HLoop" select="../../."/>
        </xsl:call-template>
        <xsl:call-template name="PatientName">
          <xsl:with-param name="Loop" select="../Loop[@LoopId='2010CA']"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:value-of select="CLM/CLM01"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="CLM/CLM02"/>
    <xsl:text>&#x0A;</xsl:text>
  </xsl:template>

  <xsl:template name="BillingProvider">
    <xsl:param name="HLoop"/>
    <xsl:value-of select="$HLoop/Loop[@LoopId='2010AA']/NM1/NM103"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="$HLoop/Loop[@LoopId='2010AA']/NM1/NM109"/>
    <xsl:text>,</xsl:text>
  </xsl:template>

  <xsl:template name="Subscriber">
    <xsl:param name="HLoop"/>
    <xsl:text>"</xsl:text>
    <xsl:value-of select="$HLoop/Loop[@LoopId='2010BA']/NM1/NM104"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="$HLoop/Loop[@LoopId='2010BA']/NM1/NM103"/>
    <xsl:text>",</xsl:text>
  </xsl:template>
  <xsl:template name="PatientName">
    <xsl:param name="Loop"/>
    <xsl:text>"</xsl:text>
    <xsl:value-of select="$Loop/NM1/NM104"/>
    <xsl:text>, </xsl:text>
    <xsl:value-of select="$Loop/NM1/NM103"/>
    <xsl:text>",</xsl:text>
  </xsl:template>
</xsl:stylesheet>

This can found in changeset "9360" here: http://x12parser.codeplex.com/SourceControl/changeset/view/9360#150731

Developer
Aug 2, 2011 at 4:26 PM

So it sounds like that extra loop occurrence is within the 837 spec?  Good to know.

Thanks for the XSLT, I'll see if I can figure out how to use it. :)

In the mean time, I built in a check in my workflow to evaluate the node: /Interchange/FunctionGroup/Transaction/HierarchicalLoop/HierarchicalLoop/HL/HL04 for every claim. If it's value is greater than 0 then I know loop 2000C occurs in the claim and I adjust extraction accordingly.

Sep 2, 2011 at 3:28 PM

Just to state it from a different point of view other than the from the HL04, the Claim Loop appears under the Subscriber Loop IF the Subscriber is the Patient.  If the Subscriber is the patient, there is no Patient Loop.  If the Subscriber is not the patient, the Claim Loop appears under the Patient Loop.

Example:

    1. I am the subscriber, the claim is for me, Claim Loop Shows up under the Subscriber Loop, there is no Patient Loop.

    2. I am the subscriber, the claim is for my son, the Claim Loop Shows up under the Patient Loop.