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

Parsing 271 response records using X12Parser

May 24, 2012 at 12:32 PM

Can you please tell me what is the best way of parsing 271 response records? I need to parse and take out each elements. One way I have used is first serializing to XML and put it into 'XPathDocument'. Then use 'XPathNavigator' to query the required element. My worry here is, performance. Is there a better way of doing?

Jul 12, 2013 at 9:24 PM
Hi,

Did you ever receive any answers for your question?

I'm no expert, I've just recently started using this library myself and I'm working directly with the EligibilityBenefitDocument object which is returned from EligibilityTransformationService.Transform271ToBenefitResponse(Stream stream) method.

I am actually at the stage of saving this data now and I am curious as to what you have come up with. Below is just some code I am using to test this now;
//.......other using statements
using OopFactory.X12.Transformations;
using OopFactory.X12.Hipaa.Eligibility.Services;
using OopFactory.X12.Hipaa.Eligibility;
using OopFactory.X12.Parsing;

namespace EdiServices.Service.InsuranceServices
{
  public class EligibilityRequestService 
  {
 
    public JObject RunTransaction(int idOfRecordToConvertTo270)
    {
        //some calls to db or w/e to help create appropriate 270 Request using idOfRecordToConvertTo270
        //.......
        //make call to clearinghouse etc to pass 270 Request and get ediFile response as string
        //.......
        //convert string to stream
        byte[] byteArray = Encoding.UTF8.GetBytes(ediFileString);
        MemoryStream ediFile = new MemoryStream(byteArray);

        //make call to EligibilityTransformationService.Transform271ToBenefitResponse(ediFile) method and get EligibilityBenefitDocument
        EligibilityTransformationService service = new EligibilityTransformationService();
        EligibilityBenefitDocument benefitDoc = service.Transform271ToBenefitResponse(ediFile);

        //Extract Subscriber info
        var subscriberInformation = benefitDoc.EligibilityBenefitResponses[0].Subscriber;
        string dob = subscriberInformation.DateOfBirth.Value.ToString("MM/dd/yyyy");
        Console.WriteLine(dob);

         //Benefit Information
       List<EligibilityBenefitInformation> benefitInfos = benefitDoc.EligibilityBenefitResponses[0].BenefitInfos;
       for( int i=0; i < benefitInfos.Count; i++ ) 
       {
         Console.WriteLine(benefitInfos[i].InfoType !=null ? benefitInfos[i].InfoType.Code : String.Empty); // "C"
         Console.WriteLine(benefitInfos[i].InfoType.Description); //"Deductible"
         Console.WriteLine(benefitInfos[i].Amount); // 0    
         Console.WriteLine(benefitInfos[i].CoverageLevel !=null ? benefitInfos[i].CoverageLevel.Code : String.Empty); // "IND"
         Console.WriteLine(benefitInfos[i].CoverageLevel !=null ? benefitInfos[i].CoverageLevel.Description : String.Empty); // "Individual"
       }

       ediFile.Flush();
       ediFile.Close();

        //you'd probably want to pass benefitDoc to _SaveEligibilityDocumentDetails(benefitDoc) or w/e    
        //but for this example return benefitDoc as JObject to ApiController or something
       return JObject.FromObject(benefitDoc);
      }
   }
   //Some other methods for this service................
}
Jan 7, 2014 at 8:06 AM
You reply is of much use. In case some mandatory information is missing in request, then the response will have some error/message information with reason code and the missing information details. So how to parse a response with reject reason code and other message details

Advance Thanks,
Ravi
Jan 7, 2014 at 4:28 PM
I'm glad it is helpful. Here is a snippet that I use to check if there is an error code;
private bool _ResponseContainsErrorCode(EligibilityBenefitResponse response)
{
    bool containsErrorCode = false;
    
    //Loop through benefit response
    for (int i = 0; i < response.BenefitInfos.Count; i++)
    {
        //Check if any InfoType.Code == "v" which is error code
        if (response.BenefitInfos[i].InfoType.Code.ToLower() == "v")
        {
          containsErrorCode = true;
        }
    }
    
    return containsErrorCode;
}
You can gain access to the messages for this error code by checking the Messages array inside each response.BenefitInfos[i] (i.e., response.BenefitInfos[i].Messages).

For example;
    ...
    //Loop through benefit response
    for (int i = 0; i < response.BenefitInfos.Count; i++)
    {
        //Check if any InfoType.Code == "v" which is error code
        if (response.BenefitInfos[i].InfoType.Code.ToLower() == "v")
        {
           if(response.BenefitInfos[i].Messages.Count > 0)
           {
              //Do something with the messages
              List<string> messages = response.BenefitInfos[i].Messages;
              foreach(string message in messages)
              {
                 System.Console.WriteLine(message);
              }
           }
        }
    }
   ...
Let me know if you have further questions.
Tim