#!/usr/bin/perl -w use strict; use warnings; use XML::XPath; use MIME::Lite::TT; use File::Copy; #use Time::localTime; my $file = 'test.xml'; my $xp = XML::XPath->new(filename => $file); my $icncount = 1; my $transactioncount = 1; my $claimpaymentcount = 1; my $servicepaymentcount = 1; my $tm = (localtime); foreach my $InterchangeControlHeader ($xp->find('//InterchangeControlHeader')->get_nodelist){ print '=================================================================' . "\n"; print 'Batch X12 File: ' . $file . "\n"; print 'Reading Date: ' . $tm . "\n"; print 'User Id: Generated by MediClear' . "\n"; print 'Last Modified: N/A ' . "\n"; print '=================================================================' . "\n"; # print 'Functional Group Count: ' . $icncount . "\n"; # print 'ICN: ' . $InterchangeControlHeader->find('//@InterchangeControlNumber13')->string_value . "\n"; foreach my $Transaction835 ($xp->find('//Transaction835')->get_nodelist){ # print $transactioncount . ') ' . 'Transaction Set Control Number : ' . $Transaction835->find('TransactionSetHeader/@TransactionSetControlNumber2')->string_value . "\n"; print 'Check/EFT Amount: ' . $Transaction835->find('FinancialInformation/@TotalActualProviderPaymentAmount2')->string_value . "\n"; print 'Check/EFT Credit/Debit Type: ' . $Transaction835->find('FinancialInformation/@CreditorDebitFlagCode3')->string_value . "\n"; print 'Check/EFT Type: ' . $Transaction835->find('FinancialInformation/@PaymentMethodCode4')->string_value . "\n"; print 'Check/EFT Payment Date: ' . $Transaction835->find('FinancialInformation/@CheckIssueorEFTEffectiveDate16')->string_value . "\n"; print 'Check/EFT Number: ' . $Transaction835->find('ReassociationTraceNumber/@CheckorEFTTraceNumber2')->string_value . "\n"; print 'Production Date: ' . $Transaction835->find('ProductionDate/@ProductionDate2')->string_value . "\n"; print 'Payer Name: ' . $Transaction835->find('//PayerIdentificationLoop/PayerIdentification/@PayerName2')->string_value . "\n"; print 'Payer Address: ' . $Transaction835->find('//PayerIdentificationLoop/PayerAddress/@PayerAddressLine1')->string_value . " "; print $Transaction835->find('//PayerIdentificationLoop/PayerCity_State_ZIPCode/@PayerCityName1')->string_value . " "; print $Transaction835->find('//PayerIdentificationLoop/PayerCity_State_ZIPCode/@PayerStateCode2')->string_value . " "; print $Transaction835->find('//PayerIdentificationLoop/PayerCity_State_ZIPCode/@PayerPostalZoneorZIPCode3')->string_value . "\n"; print 'Payee Name: ' . $Transaction835->find('//PayeeIdentificationLoop/PayeeIdentification/@PayeeName2')->string_value . "\n"; print 'Payee ICN: ' . $Transaction835->find('//PayeeIdentificationLoop/PayeeIdentification/@PayeeIdentificationCode4')->string_value . "\n"; foreach my $ClaimPaymentInformationLoop ($xp->find('//ClaimPaymentInformationLoop')->get_nodelist){ print "\n"; print 'Invoice: ' . $ClaimPaymentInformationLoop->find('ClaimPaymentInformation/@PatientControlNumber1')->string_value . "\n"; print '------------------------------------' . "\n"; print 'Claim Status: ' . $ClaimPaymentInformationLoop->find('ClaimPaymentInformation/@ClaimStatusCode2')->string_value . "\n"; print 'Billed Amount: ' . $ClaimPaymentInformationLoop->find('ClaimPaymentInformation/@TotalClaimChargeAmount3')->string_value . "\n"; print 'Insurance Payment Amount: ' . $ClaimPaymentInformationLoop->find('ClaimPaymentInformation/@ClaimPaymentAmount4')->string_value . "\n"; print 'Deductible Amount: ? ' . "\n"; print 'Payer ICN: ' . $ClaimPaymentInformationLoop->find('ClaimPaymentInformation/@PayerClaimControlNumber7')->string_value . "\n"; print 'Name Patient: ' . $ClaimPaymentInformationLoop->find('PatientName/@PatientFirstName4')->string_value . " "; print $ClaimPaymentInformationLoop->find('PatientName/@PatientLastName3')->string_value . "\n"; $claimpaymentcount++; foreach my $ServicePaymentInformationLoop ($xp->find('//ServicePaymentInformation')->get_nodelist){ print 'CPT Code: ' . $ServicePaymentInformationLoop->find('CompositeMedicalProcedureIdentifier1/@Product_ServiceID2')->string_value . "\n"; print 'CPT Modifier: ' . $ServicePaymentInformationLoop->find('CompositeMedicalProcedureIdentifier1/@ProcedureModifier3')->string_value . "\n"; print 'CPT Billed Amount: ' . $ServicePaymentInformationLoop->find('@LineItemChargeAmount2')->string_value . "\n"; print 'CPT Allow Amount: ' . $ServicePaymentInformationLoop->find('@LineItemProviderPaymentAmount3')->string_value . "\n"; print 'Service Payment Count: ' . $servicepaymentcount . "\n"; $servicepaymentcount++; } $transactioncount++; } $icncount++; } }