/** * check the csv claims tables and return rows for a particular encounter * * @uses csv_pid_enctr_parse() * @uses csv_file_with_pid_enctr() * @uses csv_table_select_list() * @uses csv_search_record() * @param string encounter number * @return string */ function csv_claim_history($encounter) { // if ($encounter) { $enct = csv_pid_enctr_parse(strval($encounter)); $e = $enct ? $enct['enctr'] : false; } // if (!$e) { return "invalid encounter value {$encounter} <br />" . PHP_EOL; } // get complete pid-encounter from the batch claims record $efp = csv_file_with_pid_enctr($e); if (is_array($efp) && count($efp)) { $pe = $efp[0][0]; } else { csv_edihist_log("csv_claim_history: failed to locate {$e} in batch claims record"); return "failed to locate {$e} in batch claims record"; } // use function csv_table_select_list() so that only // existing csv tables are queried $tbl2 = csv_table_select_list('array'); $rtypes = array(); if (is_array($tbl2) && count($tbl2)) { foreach ($tbl2 as $tbl) { $tp1 = explode(' ', $tbl['desc']); if ($tp1[1] == 'files') { continue; } if ($tp1[0] == '999' || $tp1[0] == '997' || $tp1[0] == '277') { $k = 'f' . $tp1[0]; $rtypes[$k] = $k; } elseif ($tp1[0] == 'ibr' || $tp1[0] == 'ebr' || $tp1[0] == 'dpr') { $k = $tp1[0]; $rtypes['prop'][] = $k; } else { $k = $tp1[0]; $rtypes[$k] = $k; } } } else { csv_edihist_log("csv_claim_history: failed to get csv table names"); return "failed to get csv table names"; } // $ch_html .= "<table class='clmhist' columns=4><caption>Encounter Record for {$pe}</caption>"; $ch_html .= "<tbody>" . PHP_EOL; // if (isset($rtypes['batch'])) { $tp = 'batch'; $srchar = array('s_val' => $pe, 's_col' => 2, 'r_cols' => 'all'); $btar = csv_search_record($tp, 'claim', $srchar, '2'); // $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Name</td><td>SvcDate</td><td>CLM01</td><td>File</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; if (is_array($btar) && count($btar)) { foreach ($btar as $ch) { $dt = substr($ch[1], 0, 4) . '-' . substr($ch[1], 4, 2) . '-' . substr($ch[1], 6, 2); //array('PtName', 'SvcDate', 'clm01', 'InsLevel', 'Ctn_837', 'File_837', 'Fee', 'PtPaid', 'Provider' ); $ch_html .= "<tr class='chbatch'>" . PHP_EOL; // $ch_html .= "<td>{$ch[0]}</td>" . PHP_EOL; $ch_html .= "<td>{$dt}</td>" . PHP_EOL; $ch_html .= "<td><a class='btclm' target='_blank' href='edi_history_main.php?fvbatch={$ch[5]}&btpid={$ch[2]}'>{$ch[2]}</a></td>" . PHP_EOL; $ch_html .= "<td title='{$ch[4]}'><a target='_blank' href='edi_history_main.php?fvkey={$ch[5]}'>{$ch[5]}</a></td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='chbatch'>" . PHP_EOL; $ch_html .= "<td colspan=4>Batch -- Nothing found for {$pe} in {$tp} record</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (isset($rtypes['f997'])) { $tp = 'f997'; $srchar = array('s_val' => $pe, 's_col' => 2, 'r_cols' => 'all'); $f997ar = csv_search_record($tp, 'claim', $srchar, '2'); // $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>File</td><td>Notes</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; if (is_array($f997ar) && count($f997ar)) { foreach ($f997ar as $ch) { // $msg = strlen($ch[7]) ? $ch[7] : 'ST Number'; //array('PtName', 'SvcDate', 'clm01', 'Status', 'ak_num', 'File_997', 'Ctn_837', 'err_seg'); $ch_html .= "<tr class='chf997'>"; $ch_html .= "<td>997/999</td>" . PHP_EOL; $ch_html .= "<td><a class='clmstatus' target='_blank' href='edi_history_main.php?fv997={$ch[5]}&aknum={$ch[4]}'>{$ch[3]}</a></td>" . PHP_EOL; $ch_html .= "<td><a target='_blank' href='edi_history_main.php?fvkey={$ch[5]}'>{$ch[5]}</a></td>" . PHP_EOL; $ch_html .= "<td title='{$msg}'>{$ch[6]} {$ch[4]}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='chf997'>"; $ch_html .= "<td colspan=4>x12 999 -- Nothing found for {$pe}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (isset($rtypes['f277'])) { $tp = 'f277'; // $srchar = array('s_val' => $pe, 's_col' => 2, 'r_cols' => 'all'); $f277ar = csv_search_record($tp, 'claim', $srchar, '2'); // $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>File</td><td>ClaimID</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; if (is_array($f277ar) && count($f277ar)) { foreach ($f277ar as $ch) { // array('PtName', 'SvcDate', 'clm01', 'Status', 'st_277', 'File_277', 'payer_name', 'claim_id', 'bht03_837'); $ch_html .= "<tr class='chf277'>"; // $ch_html .= "<td>x12 277</td>" . PHP_EOL; $ch_html .= "<td><a class='clmstatus' target='_blank' href='edi_history_main.php?rspfile={$ch[5]}&pidenc={$ch[2]}&rspstnum={$ch[4]}'>{$ch[3]}</a></td>" . PHP_EOL; $ch_html .= "<td title='{$ch[5]}'><a target='_blank' href='edi_history_main.php?fvkey={$ch[5]}'>File</a></td>" . PHP_EOL; $ch_html .= "<td title='{$ch[6]}'>{$ch[7]}</td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='chf277'>"; $ch_html .= "<td colspan=4>x12 277 -- Nothing found for {$pe}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (is_array($rtypes['prop']) && count($rtypes['prop'])) { foreach ($rtypes['prop'] as $tp) { // $rspnm = strtoupper($tp); $srchar = array('s_val' => $pe, 's_col' => 2, 'r_cols' => 'all'); $ibrar = csv_search_record($tp, 'claim', $srchar, '2'); // $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>File</td><td>Payer</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; if (is_array($ibrar) && count($ibrar)) { foreach ($ibrar as $ch) { //array('PtName','SvcDate', 'clm01', 'Status', 'Batch', 'FileName', 'Payer'); $ch_html .= "<tr class='ch{$tp}'>"; // $ch_html .= "<td>{$rspnm}</td>" . PHP_EOL; if ($tp == 'dpr') { $ch_html .= "<td><a class='clmstatus' target='_blank' href='edi_history_main.php?dprfile={$ch[5]}&dprclm={$ch[2]}'>{$ch[3]}</a></td>" . PHP_EOL; } else { $ch_html .= "<td><a class='clmstatus' target='_blank' href='edi_history_main.php?ebrfile={$ch[5]}&ebrclm={$ch[2]}&batchfile={$ch[4]}'>{$ch[3]}</a></td>" . PHP_EOL; } $ch_html .= "<td title='{$ch[5]}'><a target='_blank' href='edi_history_main.php?fvkey={$ch[5]}'>File</a></td>" . PHP_EOL; $ch_html .= "<td>{$ch[6]}</td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch{$tp}'>"; $ch_html .= "<td colspan=4>{$rspnm} -- Nothing found for {$pe}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } } // if (isset($rtypes['era'])) { $tp = 'era'; // $srchar = array('s_val' => $pe, 's_col' => 2, 'r_cols' => 'all'); $eraar = csv_search_record($tp, 'claim', $srchar, '2'); // $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>Trace</td><td>Payer</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; if (is_array($eraar) && count($eraar)) { foreach ($eraar as $ch) { // $msg = $ch[6] . ' ' . $ch[7] . ' ' . $ch[8]; // array('PtName', 'SvcDate', 'clm01', 'Status', 'trace', 'File_835', 'claimID', 'Pmt', 'PtResp', 'Payer'); $ch_html .= "<tr class='ch835'>"; // $ch_html .= "<td>x12 ERA</td>" . PHP_EOL; $ch_html .= "<td>{$ch[3]} <a class='clmstatus' target='_blank' href='edi_history_main.php?erafn={$ch[5]}&pidenc={$ch[2]}&summary=yes'>S</a> <a target='_blank' href='edi_history_main.php?erafn={$ch[5]}&pidenc={$ch[2]}&srchtp=encounter'>RA</a></td>" . PHP_EOL; $ch_html .= "<td><a target='_blank' href='edi_history_main.php?erafn={$ch[5]}&trace={$ch[4]}&srchtp=trace'>{$ch[4]}</a> <a target='_blank' href='edi_history_main.php?fvkey={$ch[5]}'>x12</a></td>" . PHP_EOL; $ch_html .= "<td title={$msg}>{$ch[9]}</td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch835'>"; $ch_html .= "<td colspan=4>x12 835 ERA -- Nothing found for {$pe}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } // } // end if($tp ... // -- this is where a query on the payments datatable could be used to show if payment // has been received, even if no era file shows the payment. // $ch_html .= "</tbody>" . PHP_EOL; $ch_html .= "</table>" . PHP_EOL; // return $ch_html; }
$html_str = ibr_html_heading('error'); $html_str .= "<p>Error: unrecognized value in POST array</p>" . PHP_EOL; foreach ($_POST as $ky => $val) { $html_str .= "{$ky} : {$val} <br />" . PHP_EOL; } } // end if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') // } elseif (strtolower($_SERVER['REQUEST_METHOD']) == 'get') { // if (isset($_GET['srvinfo']) && $_GET['srvinfo'] == 'yes') { // initial ajax request $html_str = ibr_inivals(); } elseif (isset($_GET['csvtbllist']) && $_GET['csvtbllist'] == 'yes') { // initial ajax request $html_str = csv_table_select_list(); } elseif (isset($_GET['ckprocessed']) && $_GET['ckprocessed'] == 'yes') { // initial ajax request $html_str = ibr_disp_is_era_processed(); } elseif (isset($_GET['fvkey'])) { // this will output to a new window (target=_blank) $html_str .= ibr_disp_fileText(); } elseif (isset($_GET['btctln'])) { $html_str .= ibr_disp_fileText(); } elseif (isset($_GET['erafn'])) { $html_str = is_xhr() ? '' : ibr_html_heading('eradisplay'); $html_str .= ibr_disp_era_get(); } elseif (isset($_GET['fvbatch'])) { $html_str = is_xhr() ? '' : ibr_html_heading('textdisplay'); $html_str .= ibr_disp_claimst(); } elseif (isset($_GET['chenctr'])) {
/** * check the csv claims tables and return rows for a particular encounter * * @uses csv_pid_enctr_parse() * @uses csv_file_with_pid_enctr() * @uses csv_table_select_list() * @uses csv_search_record() * * @param string encounter number * * @return string */ function edih_claim_history($encounter) { // if ($encounter) { $e = (string) $encounter; } else { return 'invalid encounter value ' . $encounter . '<br />' . PHP_EOL; } // use function csv_table_select_list() so that only // existing csv tables are queried $tbl2 = csv_table_select_list('array'); // $rtypes = array(); if (is_array($tbl2['claims']) && count($tbl2['claims'])) { $rtypes = array_keys($tbl2['claims']); } else { csv_edihist_log("csv_claim_history: failed to get csv table names"); return "failed to get csv table names"; } // $ch_html = "<table class='clmhist' columns=4><caption>Encounter Record for {$e}</caption>"; $ch_html .= "<tbody>" . PHP_EOL; // if (in_array('f837', $rtypes)) { $tp = 'f837'; $btar = csv_file_by_enctr($e, $tp); // if (is_array($btar) && count($btar)) { $ch_html .= "<tr class='ch837'><td colspan=4>837 Claim " . count($btar) . "</td></tr>" . PHP_EOL; $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Name</td><td>SvcDate</td><td>CLM01</td><td>File</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; foreach ($btar as $ch) { $dt = substr($ch['SvcDate'], 0, 4) . '-' . substr($ch['SvcDate'], 4, 2) . '-' . substr($ch['SvcDate'], 6, 2); //array('PtName', 'SvcDate', 'CLM01', 'InsLevel', 'Control', 'FileName', 'Fee', 'PtPaid', 'Provider' ); $ch_html .= "<tr class='ch837'>" . PHP_EOL; // $ch_html .= "<td>{$ch['PtName']}</td>" . PHP_EOL; $ch_html .= "<td>{$dt}</td>" . PHP_EOL; $ch_html .= "<td><a class='seg' href='edih_main.php?gtbl=claim&fname={$ch['FileName']}&ftype={$tp}&pid={$ch['CLM01']}&fmt=seg'>{$ch['CLM01']}</a></td>" . PHP_EOL; $ch_html .= "<td title='{$ch['Control']}'><a class='seg' href='edih_main.php?gtbl=file&fname={$ch['FileName']}&ftype={$tp}&fmt=seg'>{$ch['FileName']}</a></td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch837'>" . PHP_EOL; $ch_html .= "<td colspan=4>837 Claim -- Nothing found for {$e}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (in_array('f997', $rtypes)) { $tp = 'f997'; $f997ar = csv_file_by_enctr($e, $tp); // if (is_array($f997ar) && count($f997ar)) { $ch_html .= "<tr class='ch997'><td colspan=4>Ack 997/999 " . count($f997ar) . "</td></tr>" . PHP_EOL; $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td colspan=3>Acknowledgement File</td><td>Notes</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; foreach ($f997ar as $ch) { // $msg = strlen($ch[7]) ? $ch[7] : 'ST Number'; //array('PtName', 'RspDate', 'Trace', 'Status', 'Control', 'FileName', 'RspType', 'err_seg');; $ch_html .= "<tr class='ch997'>"; $ch_html .= "<td>Rsp Ack</td>" . PHP_EOL; $ch_html .= "<td><a class='rsp' target='_blank' href='edih_main.php?gtbl=claim&fname={$ch['FileName']}&ftype={$tp}&trace={$ch['Trace']}&rsptype={$ch['RspType']}&errseg={$ch['err_seg']}'>{$ch['Status']}</a></td>" . PHP_EOL; $ch_html .= "<td><a class='seg' href='edih_main.php?gtbl=file&fname={$ch['FileName']}&ftype={$tp}&fmt=seg'>{$ch['FileName']}</a></td>" . PHP_EOL; $ch_html .= "<td title='Response type/date'>{$ch['RspType']} {$ch['RspDate']}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch997'>"; $ch_html .= "<td colspan=4>Ack 997/999 -- Nothing found for {$e}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (in_array('f277', $rtypes)) { $tp = 'f277'; $f277ar = csv_file_by_enctr($e, $tp); // if (is_array($f277ar) && count($f277ar)) { $ch_html .= "<tr class='ch277'><td colspan=4>Status 277 " . count($f277ar) . "</td></tr>" . PHP_EOL; $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>File</td><td>ClaimID</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; foreach ($f277ar as $ch) { //'f277':array('PtName', 'SvcDate', 'CLM01', 'Status', 'BHT03', 'FileName', 'Payer', 'Trace'); $ch_html .= "<tr class='ch277'>"; // $ch_html .= "<td>Claim Status</td>" . PHP_EOL; $ch_html .= "<td><a class='rsp' href='edih_main.php?gtbl=claim&fname={$ch['FileName']}&ftype={$tp}&bht03={$ch['BHT03']}&fmt=htm'>{$ch['Status']}</a></td>" . PHP_EOL; $ch_html .= "<td title='{$ch['FileName']}'><a href='edih_main.php?gtbl=file&fname={$ch['FileName']}&ftype={$tp}&fmt=seg'>{$ch['FileName']}</a></td>" . PHP_EOL; $ch_html .= "<td title='Payer {$ch['Payer']}'>{$ch['Trace']}</td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch277'>"; $ch_html .= "<td colspan=4>Status 277 -- Nothing found for {$e}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } } // if (in_array('f835', $rtypes)) { $tp = 'f835'; $f835ar = csv_file_by_enctr($e, $tp); // if (is_array($f835ar) && count($f835ar)) { $ch_html .= "<tr class='ch835'><td colspan=4>Payment 835 " . count($f835ar) . "</td></tr>" . PHP_EOL; $ch_html .= "<tr class='chhead'>" . PHP_EOL; $ch_html .= "<td>Response</td><td>Status</td><td>Trace</td><td>Payer</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; foreach ($f835ar as $ch) { // $msg = $ch['ClaimID'] . ' ' . $ch['Pmt'] . ' ' . $ch['PtResp']; // array('PtName', 'SvcDate', 'CLM01', 'Status', 'Trace', 'FileName', 'ClaimID', 'Pmt', 'PtResp', 'Payer'); $ch_html .= "<tr class='ch835'>"; // $ch_html .= "<td>{$ch['PtName']}</td>" . PHP_EOL; $ch_html .= "<td><a class='rsp' href='edih_main.php?gtbl=claim&fname={$ch['FileName']}&ftype={$tp}&pid={$ch['CLM01']}&summary=no'>{$ch['Status']}</a></td>" . PHP_EOL; $ch_html .= "<td><a href='edih_main.php?gtbl=file&fname={$ch['FileName']}&ftype={$tp}&trace={$ch['Trace']}&fmt=htm'>{$ch['Trace']}</a></td>" . PHP_EOL; $ch_html .= "<td title={$msg}>{$ch['Payer']}</td>" . PHP_EOL; // $ch_html .= "</tr>" . PHP_EOL; } } else { $ch_html .= "<tr class='ch835'>"; $ch_html .= "<td colspan=4>Payment 835 -- Nothing found for {$e}</td>" . PHP_EOL; $ch_html .= "</tr>" . PHP_EOL; } // } // end if($tp ... // -- this is where a query on the payments datatable could be used to show if payment // has been received, even if no era file shows the payment. // $ch_html .= "</tbody>" . PHP_EOL; $ch_html .= "</table>" . PHP_EOL; // return $ch_html; }