kevmccor wrote on Thursday, August 09, 2012:
I have had secondary insurance claims rejected due to errors in the CAS segment. The errors were due to a repeated CAS segments with the same group code, e.g.
CAS*CO*45*42.85~
CAS*CO*247*1.25~
(just arbitrary examples)
The segment should have been
CAS*CO*45*42.85**247*1.25~
Edit 1:
/openemr/library/gen_x12_837.inc.php, around line 810
/***** CAS segments should be one per adjustment group, CO, OA, PI, PR
* $aarr = $claim->payerAdjustments($ins);
* this is: $aadj[] = array($date, $gcode, $rcode, sprintf('%.2f', $chg));
* CAS*$gcode* then triplets of $rcode*$chg*$qty ($qty ommitted from $aadj)
* Concept: recast the $aarr array
*/
$aarr = $claim->payerAdjustments($ins);
$castp = array();
foreach ($aarr as $a) {
$ky = $a[1];
if (array_key_exists($ky, $castp)) {
$castp[$ky] = array_merge($castp[$ky], array('', $a[2], $a[3]));
} else {
$castp[$ky] = array($a[2],$a[3]);
}
}
foreach ($castp as $g => $a) {
$ct = count($a)
$out .= "CAS*$g";
for($i=0; $i<$ct; $i++) {
$out .= "*" . $a[$i];
}
$out .= "~\n";
}
This next one is to prevent duplicate batch control numbers in the ISA segment of consecutive batch files, which could cause the second batch file to be rejected by a clearinghouse. This would change the ICN number from 022408852 to 224088523, for example.
Edit 2
/openemr/library/interface/billing/billing_process.php around line 35
// Minutes since 1/1/1970 00:00:00 GMT will be our interchange control number:
// -- not good enough; batch can be generated in less than 1 minute, div by 6 not 60
$bat_icn = sprintf('%09.0f', $bat_time/6);
The last edit is to give a unique identifier, besides the patient control number (CLM01). The 999 x12 response files may have it in an error case, but not otherwise, and the 277 x12 files also may not have it. When this number is returned in a response, the batch file and claim can be identified.
Edit 3
/openemr/library/interface/billing/billing_process.php around line 87
if ($elems[0] == 'BHT') {
// gives each claim a unique BHT id number: isa-control-num and st-num are concatenated
// which is how the claim is identified in x12 277 claim-status file
$bat_content .= str_replace("*0123*", sprintf("*%s%04d*", $bat_icn, $bat_stcount), $seg) .'~';
continue;
}
I just figured out edits 1 and 2, so I have not tested them except for syntax and results.
I have used edit 3 for several months with no problems.