예제 #1
0
/**
 * Process new batch files for csv data and html output
 * 
 * The html output is only a file summary, no claim detail is created
 * 
 * 
 * @uses csv_verify_file()
 * @uses ibr_batch_csv_data()
 * @uses csv_write_record() 
 * @uses csv_newfile_list()
 * @param array $file_array   optional default is NULL 
 * @param boolean $html_out   whether to generate html files summary table
 * @return string             html output only for files table
 */
function ibr_batch_process_new($file_array = NULL, $html_out = TRUE)
{
    //
    // 'mtime', 'dirname', 'fname', 'trace' 'payer' 'claims'
    $html_str = "";
    $chars1 = 0;
    $chars2 = 0;
    //$chars2 = 0;
    $idx = 0;
    $ar_batchf = array();
    //$need_dir = TRUE;
    // get the list of new files
    if ($file_array === NULL || !is_array($file_array) || count($file_array) == 0) {
        $ar_newfiles = csv_newfile_list("batch");
    } else {
        $ar_newfiles = $file_array;
        //$need_dir = FALSE;
    }
    //
    if (count($ar_newfiles) == 0) {
        if ($html_out) {
            $html_str .= "<p>ibr_batch_process_new: no new batch files <br />";
            return $html_str;
        } else {
            return false;
        }
    } else {
        $btfcount = count($ar_newfiles);
    }
    // we have some new ones
    // verify and get complete path
    foreach ($ar_newfiles as $fbt) {
        $fp = csv_verify_file($fbt, 'batch', false);
        if ($fp) {
            $ar_batchf[] = $fp;
        }
    }
    $p = csv_parameters("batch");
    $b_dir = $p['directory'];
    //
    if ($html_out) {
        $html_str .= "<table cols=5 class=\"batch\">\n\t\t  <caption>Batch Files CSV</caption>\n\t\t  <thead>\n\t\t\t<tr>\n\t\t\t  <th>File Time</th><th>File Name</th>\n\t\t\t  <th>Control</th><th>Claims</th><th>x12_Partner</th>\n\t\t\t</tr>\n\t\t  </thead>\n\t\t  <tbody>";
    }
    foreach ($ar_batchf as $f_batch) {
        //
        // increment counter for alternating html backgrounds
        $bgc = $idx % 2 == 1 ? 'odd' : 'even';
        $idx++;
        //
        //$full_path = ($need_dir) ? $b_dir.DIRECTORY_SEPARATOR.$f_batch : $f_batch;
        // get the file data for csv output
        //$ar_csv_data = ibr_batch_csv_data($full_path);
        $ar_csv_data = ibr_batch_csv_data($f_batch);
        //
        // write to the files_batch csv record
        $chars1 += csv_write_record($ar_csv_data['file'], 'batch', 'file');
        $chars2 += csv_write_record($ar_csv_data['claim'], 'batch', 'claim');
        //
        // link for viewing file <a href=\"edi_view_file.php?\'fvkey\'=$dta\" target=\"_blank\">$dta</a></td>";
        if ($html_out) {
            $html_str .= "<tr class=\"{$bgc}\">\n                 <td>{$ar_csv_data['file'][0]}</td>\n                 <td><a target='_blank' href='edi_history_main.php?fvkey={$ar_csv_data['file'][1]}'>{$ar_csv_data['file'][1]}</a></td>\n                 <td>{$ar_csv_data['file'][2]}</td>\n                 <td>{$ar_csv_data['file'][3]}</td>\n                 <td>{$ar_csv_data['file'][4]}</td>\n               </tr>";
        }
    }
    if ($html_out) {
        $html_str .= "</tbody>\n\t\t   </table>\n\t\t <p></p>";
    }
    //
    csv_edihist_log("ibr_batch_process_new: {$chars1} characters written to files_batch.csv");
    csv_edihist_log("ibr_batch_process_new: {$chars2} characters written to claims_batch.csv");
    //
    if ($html_out) {
        return $html_str;
    } else {
        return "<p>Batch files: processed {$btfcount} files </p>";
    }
}
예제 #2
0
/**
 * Process new files for csv table and html output
 * 
 * @uses csv_newfile_list()
 * @uses csv_parameters()
 * @uses csv_x12_segments()
 * @uses ibr_277_parse()
 * @uses ibr_277_csv_claim_data()
 * @uses csv_write_record()
 * @param bool $html_out -- whether to return html output
 * @param bool $err_only -- only list claims with errors in output
 * @param array $files_ar -- list of new files from upload script
 * @return string
 */
function ibr_277_process_new($files_ar = NULL, $html_out = FALSE, $err_only = TRUE)
{
    //
    if ($files_ar === NULL || !is_array($files_ar) || count($files_ar) == 0) {
        $ar_files = csv_newfile_list("f277");
    } else {
        $ar_files = $files_ar;
        //$need_dir = FALSE;
    }
    //
    if (count($ar_files) == 0) {
        if ($html_out) {
            $html_str .= "<p>ibr_277_process_new: no new f277 files <br />";
            return $html_str;
        }
    }
    // we have some new ones, verify and get complete path
    foreach ($ar_files as $fbt) {
        $fp = csv_verify_file($fbt, 'f277', false);
        if ($fp) {
            $ar_277files[] = $fp;
        }
    }
    //
    if (!is_array($ar_277files) || count($ar_277files) == 0) {
        $html_str = "ibr_277_process_new: no new f277 files found <br />" . PHP_EOL;
        return $html_str;
    } else {
        $f277count = count($ar_277files);
    }
    // OK, we have some new files
    $html_str = "";
    $idx = 0;
    $chr_c = 0;
    $chr_f = 0;
    //
    foreach ($ar_277files as $file_277) {
        // since the newfiles routine is updated, the need_dir test is not necessary
        //$path_277 = ($need_dir) ? $dir.DIRECTORY_SEPARATOR.$file_277 : $file_277;
        $path_277 = $file_277;
        //
        $ar_277seg = csv_x12_segments($path_277, "f277", FALSE);
        //
        if (is_array($ar_277seg) && count($ar_277seg['segments'])) {
            $ar_277_vals = ibr_277_parse($ar_277seg);
            if (!$ar_277_vals) {
                $html_str .= "failed to get segments for {$file_277} <br />" . PHP_EOL;
                continue;
            }
        } else {
            $html_str .= "failed to get segments for {$file_277} <br />" . PHP_EOL;
            continue;
        }
        // since main array is indexed on isa segment and there may be more
        // than one per file, the 'file' csv table has a row for each ISA segment
        // and the 'claim' csv table has a row for each BHT segment
        foreach ($ar_277_vals as $isa) {
            $ar_csvf = $isa['file'];
            $ar_csvc = ibr_277_csv_claim_data($isa['claim']);
            //
            if ($html_out) {
                $ar_h[$idx]['file'] = $ar_csvf;
                $ar_h[$idx]['claim'] = $ar_csvc;
                $idx++;
            }
            // still too much in claim csv record, drop the message
            //['f277']['claim'] =  array('PtName', 'SvcDate', 'clm01', 'Status', 'st_277', 'File_277', 'payer_name', 'claim_id', 'bht03_837');
            $ar_csvclm = array();
            foreach ($ar_csvc as $clm) {
                $ar_csvclm[] = array_slice($clm, 0, 9);
            }
            $chr_f += csv_write_record($ar_csvf, "f277", "file");
            $chr_c += csv_write_record($ar_csvclm, "f277", "claim");
            //
        }
    }
    // end foreach ($ar_files as $file_277)
    //
    if ($html_out) {
        $html_str .= ibr_277_html($ar_h, $err_only);
    } else {
        $html_str .= "x12_277 files: processed {$f277count} x12-277 files <br />" . PHP_EOL;
    }
    csv_edihist_log("ibr_277_process_new: {$chr_f} characters written to files_277.csv");
    csv_edihist_log("ibr_277_process_new: {$chr_c} characters written to claims_277.csv");
    //
    return $html_str;
}
예제 #3
0
/**
 * Process new x12 835 files so data is written to csv tables and html output is created
 * 
 * This is a multi-operational function, calling other functions in this script and in 
 * csv_record_include.php to list newly uploaded files, parse them for csv data, write 
 * to the csv data files, and generate html output.
 * 
 * @uses csv_newfile_list()
 * @uses csv_x12_segments()
 * @uses ibr_era_csv_file_data()
 * @uses ibr_era_csv_write_data()
 * @uses ibr_era_csv_files_html()
 * 
 * @param array $file_array     not required, array of new filenames, generated by csv_newfile_list()
 * @param boolean $html_out     whether to generate html files summary table
 * @param boolean $err_only     whether to generate html for denied claims
 * @return string               html output
 */
function ibr_era_process_new($file_array = NULL, $html_out = TRUE, $err_only = TRUE)
{
    //
    // get new files from directory and write data to the .csv files
    //
    // create html table if $html_out is true
    // 'mtime', 'dirname', 'fname', 'trace' 'payer' 'claims'
    $html_str = "";
    $ar_csv_data = array();
    //
    $err_ref = "";
    //
    if (is_array($file_array) && count($file_array)) {
        $ar_newfiles = $file_array;
    } else {
        $ar_newfiles = csv_newfile_list("era");
    }
    // cut it off if there are no new files
    if (count($ar_newfiles) == 0) {
        // no new files
        if ($html_out) {
            // return a message
            $html_str = "<p>ibr_era_process_new: No new ERA 835 files found</p>";
            return $html_str;
        } else {
            return FALSE;
        }
    } else {
        $fcount = count($ar_newfiles);
    }
    // we have new files
    foreach ($ar_newfiles as $f_era) {
        //
        $era_segments = csv_x12_segments($f_era, "era", FALSE);
        //
        if (is_array($era_segments) && count($era_segments['segments']) > 0) {
            $ar_csv_data[] = ibr_era_csv_file_data($era_segments);
            //
        } else {
            csv_edihist_log("ibr_era_process_new: did not get segments for " . basename($full_path));
            $htm_hdrc .= "<p>did not get segments for {$f_era} </p>" . PHP_EOL;
            continue;
        }
    }
    // now send the data to be written to csv table and html output
    foreach ($ar_csv_data as $eradata) {
        $chars = ibr_era_csv_write_data($eradata, $err_ref);
        //$html_out
        $html_str .= isset($htm_hdrc) ? $htm_hdrc : "";
        //
        if (is_array($chars)) {
            if ($chars[0]) {
                csv_edihist_log("ibr_era_process_new: {$chars[0]} characters written to files_era.csv");
            } else {
                csv_edihist_log("ibr_era_process_new: error writing csv data for files: " . PHP_EOL . $err_ref);
                $html_str .= "<p>ibr_era_process_new: error writing csv data</p>";
            }
            if ($chars[1]) {
                csv_edihist_log("ibr_era_process_new: {$chars[1]} characters written to claims_era.csv");
            } else {
                csv_edihist_log("ibr_era_process_new: error writing csv data for claims ");
                $html_str .= "<p>ibr_era_process_new: error writing csv data</p>";
            }
        }
    }
    //
    if ($html_out) {
        $html_str .= ibr_era_csv_files_html($ar_csv_data, $err_only);
    } elseif ($chars[0] && $chars[1]) {
        $html_str .= "x12_835 ERA files: processed {$fcount} ERA files <br />" . PHP_EOL;
    } else {
        $html_str .= "x12_835 ERA: error writing csv data <br />";
    }
    return $html_str;
}
예제 #4
0
/**
 * process new 997/999 files
 * 
 * @uses csv_newfile_list()
 * @uses csv_verify_file()
 * @uses csv_parameters()
 * @param array $file_array -- optional, this array is sent from the ibr_io.php script
 * @param bool $html_out -- whether to produce and return html output
 * @param bool $err_only -- whether to generate claim information only for errors (ignored)
 * @return string
 */
function ibr_997_process_new($file_array = NULL, $html_out = TRUE, $err_only = TRUE)
{
    //
    $ret_str = "";
    $chr_ct1 = 0;
    $chr_ct2 = 0;
    $new_997 = array();
    $need_dir = TRUE;
    //
    if (is_null($file_array) || empty($file_array)) {
        // directory will need to be prepended to name
        $new_997 = csv_newfile_list('f997');
    } elseif (is_array($file_array) && count($file_array)) {
        // files that are not verified will just be ignored
        foreach ($file_array as $finp) {
            $fp = csv_verify_file($finp, 'f997');
            if ($fp) {
                $new_997[] = $fp;
            }
        }
        $need_dir = FALSE;
    }
    //
    if (count($new_997) == 0) {
        $ret_str = "<p>ibr_997_process_new: no new 997/999 files. </p>";
        return $ret_str;
    } else {
        $f997count = count($new_997);
    }
    //
    $ar_htm = array();
    //
    $params = csv_parameters("f997");
    $tdir = dirname(__FILE__) . $params['directory'];
    //
    // get batch files parameters, we need the batch_dir
    $bp = csv_parameters("batch");
    $batch_dir = dirname(__FILE__) . $bp['directory'];
    //
    foreach ($new_997 as $f997) {
        // make the file path
        $fpath = $need_dir ? $tdir . DIRECTORY_SEPARATOR . $f997 : $f997;
        // get file m-time
        //$ftime = date('Ymd:His', filemtime($fpath));
        // read file into string
        $f_str = file_get_contents($fpath);
        if ($f_str) {
            // transform file contents into segment arrays
            $ar_seg = csv_x12_segments($fpath, "f997", FALSE);
            //
            if (!$ar_seg) {
                // file was rejected
                csv_edihist_log("ibr_997_process_new: failed to get segments for {$fpath}");
                $ret_str .= "ibr_997_process_new: failed to get segments for {$fpath}</p>" . PHP_EOL;
                continue;
            }
            // parse arrays into data arrays
            $ar_data = ibr_997_parse($ar_seg);
            // $ar_data = array("file" => $ar_997file, "rejects" => $ar_reject);
            //
            $csv_claims = ibr_997_data_csv($ar_data['file'], 'file');
            if ($csv_claims) {
                $chr_ct1 += csv_write_record($csv_claims, "f997", "file");
            } else {
                csv_edihist_log("ibr_997_process_new: error with files csv array");
            }
            //
            if (isset($ar_data['claims']) && count($ar_data['claims'])) {
                // only add to claims_997.csv if there are rejected claims
                $csv_claims = ibr_997_data_csv($ar_data['claims'], 'claim');
                if ($csv_claims) {
                    $chr_ct2 += csv_write_record($csv_claims, "f997", "claim");
                } else {
                    csv_edihist_log("ibr_997_process_new: error with claims csv array");
                }
                //
            }
            //
            // save all the ar_datas for html output
            if ($html_out) {
                $ar_htm[] = $ar_data;
            }
            //
        } else {
            $ret_str .= "<p>ibr_997_process_new: failed to read {$fpath} </p>" . PHP_EOL;
        }
    }
    //
    csv_edihist_log("ibr_997_process_new: {$chr_ct1} characters written to files_997.csv");
    csv_edihist_log("ibr_997_process_new: {$chr_ct2} characters written to claims_997.csv");
    //
    if ($html_out) {
        // generate html output and return that
        $ret_str .= ibr_997_file_data_html($ar_htm, $err_only);
    } else {
        $ret_str .= "x12_999 files: processed {$f997count} x12-999 files <br />";
    }
    //
    return $ret_str;
}
예제 #5
0
/**
 * process new .ta1 files
 * 
 * 
 * @uses ibr_process_ta1()
 * @uses ibr_ack_html()
 * @uses csv_newfile_list()
 * @uses csv_verify_file()
 * @param array|string -- optional array of filenames or filename
 * @param bool --whether to produce html table
 * @return string
 */
function ibr_ta1_process_new($ta1_files, $html_out = TRUE)
{
    //
    $str_html = "";
    //
    if (is_array($ta1_files)) {
        $new_files = $ta1_files;
    } elseif (is_string($ta1_files) && strlen($ta1_files)) {
        $new_files[] = $ta1_files;
    } else {
        $new_files = csv_newfile_list("ta1");
    }
    //
    if (is_array($new_files) && count($new_files) > 0) {
        $fcount = count($new_files);
        foreach ($new_files as $ta) {
            $fp = csv_verify_file($ta, 'ta1');
            if ($fp) {
                $ar_d[] = ibr_process_ta1($fp);
            } else {
                $str_html .= "TA1 failed to verify file: {$ta} <br />" . PHP_EOL;
                csv_edihist_log("ibr_ta1_process_new: failed to verify file: {$ta}");
            }
        }
    }
    // write a line to csv file -- put in file_997.csv
    if (is_array($ar_d) && count($ar_d)) {
        foreach ($ar_d as $arec) {
            // do not put message, batch, or text file in csv record
            $ar_csv[] = array_slice($arec, 0, count($arec) - 3);
        }
        $rslt = csv_write_record($ar_csv, "ta1", "file");
        csv_edihist_log("ibr_ta1_process_new: {$rslt} characters written to files_997.csv");
        if ($html_out) {
            $str_html .= ibr_ack_html($ar_d);
        } else {
            $str_html .= "TA1 files: processed {$fcount} TA1 files <br />" . PHP_EOL;
        }
    } else {
        $str_html .= "No new TA1 files found. <br />" . PHP_EOL;
    }
    //
    return $str_html;
}
예제 #6
0
/**
 * call new uploaded files process functions
 * 
 * @todo    save the newfiles lists to file so they can
 *          be re-displayed if user has to close app before
 *          finishing review (need to have csv_write option)
 * 
 * @uses csv_newfile_list()
 * @uses ibr_batch_process_new()
 * @uses ibr_ack_process_new()
 * @uses ibr_997_process_new()
 * @uses ibr_277_process_new()
 * @uses ibr_ebr_process_new()
 * @uses ibr_dpr_process_new()
 * @uses ibr_era_process_new()
 * 
 * @return string  html format
 */
function ibr_disp_newfiles()
{
    //
    if (!isset($_POST['NewFiles'])) {
        // should only be called with this value existing
        $str_html = "Error: invalid value for Process New <br />" . PHP_EOL;
        return $str_html;
    }
    $htm = $er = false;
    if (isset($_POST['htmlout'])) {
        $htmval = filter_input(INPUT_POST, 'htmlout', FILTER_SANITIZE_STRING);
        $htm = $htmval == 'on' ? true : false;
    }
    if (isset($_POST['erronly'])) {
        $errval = filter_input(INPUT_POST, 'erronly', FILTER_SANITIZE_STRING);
        $er = $errval == 'on' ? true : false;
    }
    $str_html = "<p>Process new files</p>" . PHP_EOL;
    //
    $p = csv_parameters();
    $ftype = array_keys($p);
    //
    foreach ($ftype as $tp) {
        $checkdir = false;
        // check for directory contents
        $ckdir = $p[$tp]['directory'];
        if (is_dir($ckdir)) {
            $dh = opendir($ckdir);
            if ($dh) {
                while (($file = readdir($dh)) !== false) {
                    if ($file != '.' && $file != '..') {
                        $checkdir = true;
                        break;
                    }
                }
                closedir($dh);
            }
        }
        // if false, no files in directory
        if (!$checkdir) {
            continue;
        }
        //
        $upload_ar = csv_newfile_list($tp);
        //
        if (count($upload_ar) > 0) {
            if ($tp == 'batch') {
                $str_html .= ibr_batch_process_new($upload_ar, $htm);
            } elseif ($tp == 'ack') {
                $str_html .= ibr_ack_process_new($upload_ar, $htm);
            } elseif ($tp == 'ta1') {
                $str_html .= ibr_ta1_process_new($upload_ar, $htm);
            } elseif ($tp == 'f997') {
                $str_html .= ibr_997_process_new($upload_ar, $htm, $er);
            } elseif ($tp == 'f277') {
                $str_html .= ibr_277_process_new($upload_ar, $htm, $er);
            } elseif ($tp == 'ibr') {
                $str_html .= ibr_ebr_process_new_files($upload_ar, 'ibr', $htm, $er);
            } elseif ($tp == 'ebr') {
                $str_html .= ibr_ebr_process_new_files($upload_ar, 'ebr', $htm, $er);
            } elseif ($tp == 'dpr') {
                $str_html .= ibr_dpr_process_new($upload_ar, $htm, $er);
            } elseif ($tp == 'era') {
                $str_html .= ibr_era_process_new($upload_ar, $htm, $er);
            } elseif ($tp == 'text') {
                // do nothing
                continue;
            } else {
                $str_html .= "unknown type {$tp} <br />" . PHP_EOL;
            }
        } else {
            $str_html .= "No new files for type {$tp} <br />" . PHP_EOL;
        }
    }
    return $str_html;
}
예제 #7
0
/**
 * the main function for ebr and ibr files in this script
 * 
 * @uses csv_newfile_list()
 * @uses csv_verify_file()
 * @uses csv_write_record()
 * @uses ibr_ebr_values()
 * @uses ibr_ibr_values()
 * @uses ibr_ebr_csv_files()
 * @uses ibr_ebr_csv_claims()
 * @param array              optional array of filenames or null
 * @param string $extension  one of ibr, or ebr; default is ibr
 * @param bool $html_out  true or false whether html output string should be created and returned
 * @param bool $err_only  true or false whether html output shows files and only errors or all claims
 * @return string|bool       html output string or boolean
 */
function ibr_ebr_process_new_files($files_ar = NULL, $extension = 'ibr', $html_out = TRUE, $err_only = TRUE)
{
    // process new ebr or ibr files by calling the functions in this script
    // three optional arguments to be passed to functions and used within
    //
    $html_str = "";
    $f_list = array();
    // patterned from ibr_batch_read.php
    if ($files_ar === NULL || !is_array($files_ar) || count($files_ar) == 0) {
        $f_new = csv_newfile_list($extension);
    } elseif (is_array($files_ar) && count($files_ar)) {
        $f_new = $files_ar;
    }
    //
    if (count($f_new) == 0) {
        if ($html_out) {
            $html_str .= "<p>IBR/EBR files: no new {$extension} files <br />";
            return $html_str;
        } else {
            return false;
        }
    }
    // we have some new files
    // verify and get complete path
    foreach ($f_new as $fbt) {
        $fp = csv_verify_file($fbt, $extension, false);
        if ($fp) {
            $f_list[] = $fp;
        } else {
            $html_str .= "verification failed for {$fbt} <br />" . PHP_EOL;
            csv_edihist_log("ibr_ebr_process_new_files: verification failed for {$fbt}");
        }
    }
    $fibrcount = count($f_list);
    //
    // initialize variables
    $data_ar = array();
    $wf = array();
    $wc = array();
    $chrf = 0;
    $chrc = 0;
    $idx = 0;
    //
    // sort ascending so latest files are last to be output
    $is_sort = asort($f_list);
    // returns true on success
    //
    // Step 2: file data written to csv files
    //         also html string created if $html_out = TRUE
    foreach ($f_list as $f_name) {
        // get the data array for the file
        //
        // verify extension
        if (substr($f_name, -3) != $extension) {
            csv_edihist_log("ibr_ebr_process_new_files: type mismatch {$extension} " . basename($f_name));
            continue;
        }
        //
        if ($extension == 'ibr') {
            $data_vals = ibr_ibr_values($f_name);
        } elseif ($extension == 'ebr') {
            $data_vals = ibr_ebr_values($f_name);
        } else {
            csv_edihist_log("ibr_ebr_process_new_files: incorrect extension {$ext} " . basename($f_name));
            continue;
        }
        //
        if (is_array($data_vals) && count($data_vals)) {
            foreach ($data_vals as $dm) {
                $wf[] = ibr_ebr_csv_files($dm['file']);
                foreach ($dm['claims'] as $cl) {
                    // array for csv
                    $wc[] = ibr_ebr_csv_claims($cl);
                }
                $data_ar[$idx]['file'] = $dm['file'];
                $data_ar[$idx]['claims'] = $dm['claims'];
                $idx++;
            }
        }
    }
    //
    $chrf += csv_write_record($wf, $extension, "file");
    $chrc += csv_write_record($wc, $extension, "claim");
    //
    if ($html_out) {
        $html_str .= ibr_ebr_html($data_ar, $err_only);
    } else {
        $html_str .= "IBR/EBR files: processed {$fibrcount} {$extension} files <br />" . PHP_EOL;
    }
    return $html_str;
}
예제 #8
0
/**
 * call new uploaded files process functions
 * 
 * @todo    save the newfiles lists to file so they can
 *          be re-displayed if user has to close app before
 *          finishing review (need to have csv_write option)
 * 
 * @uses csv_newfile_list()
 * @uses edih_parse_select()
 * @uses edih_csv_write()
 * @uses edih_csv_process_html()
 * 
 * @return string  html format
 */
function edih_disp_file_process()
{
    //file "fileUplMulti "submit" "uplsubmit" "button""uplreset"
    //
    // debug
    if (isset($_GET)) {
        $dbg_str = 'GET vars ';
        foreach ($_GET as $k => $v) {
            $dbg_str .= $k . ' ' . $v . '  ';
        }
        csv_edihist_log("edih_disp_file_process {$dbg_str}");
    }
    //
    if (!isset($_GET['ProcessFiles'])) {
        // should only be called with this value existing
        $str_html = "Error: invalid value for Process New <br />" . PHP_EOL;
        return $str_html;
    }
    $htm = $er = false;
    if (isset($_GET['process_html'])) {
        // show tables for process results
        $htmval = filter_input(INPUT_GET, 'process_html', FILTER_SANITIZE_STRING);
        $htm = $htmval == 'htm' ? true : false;
    }
    if (isset($_GET['process_err'])) {
        // show only claims with errors (denied, rejected, etc)
        $errval = filter_input(INPUT_GET, 'process_err', FILTER_SANITIZE_STRING);
        $er = $errval == 'err' ? true : false;
    }
    $str_html = "";
    //
    $p = csv_parameters();
    $ftype = array_keys($p);
    $fct = 0;
    //
    foreach ($ftype as $tp) {
        $checkdir = false;
        // check for directory contents
        $fdir = $p[$tp]['directory'];
        if (is_dir($fdir)) {
            $dh = opendir($fdir);
            if ($dh) {
                while (($file = readdir($dh)) !== false) {
                    if ($file != '.' && $file != '..') {
                        $checkdir = true;
                        break;
                    }
                }
                closedir($dh);
            }
        }
        // if false, no files in directory
        if (!$checkdir) {
            continue;
        }
        //
        $upload_ar = csv_newfile_list($tp);
        //
        if (is_array($upload_ar) && count($upload_ar)) {
            $dirct = count($upload_ar);
            if ($htm) {
                $dtl = $er ? "(claims: errors only)" : "(claims: all)";
                //$hvals = csv_table_header($tp, 'file');
                //$col_ct = count($hvals);
                ////csv_table_header(
                //$str_html .= "<table class='$tp' cols=$col_ct><caption>$tp Files Summary $dtl</caption>".PHP_EOL;
                //$str_html .= csv_thead_html($tp, 'file');
                //$str_html .= "<tbody>".PHP_EOL;
                $str_html .= "<h2 class='prcs'>{$tp} {$dirct} files {$dtl}</h2>" . PHP_EOL;
                $str_html .= "<dl class='{$tp}'>" . PHP_EOL;
            }
            foreach ($upload_ar as $fn) {
                $fp = $fdir . DS . $fn;
                $csvdata = edih_parse_select($fp);
                $csvchr = edih_csv_write($csvdata);
                $fct++;
                if ($htm) {
                    $str_html .= edih_csv_process_html($csvdata, $er);
                }
            }
            //$str_html .= ($htm) ? "</tbody>".PHP_EOL."</table>".PHP_EOL : "";
            $str_html .= $htm ? "</dl>" . PHP_EOL : "";
        } else {
            $str_html .= "<p>No new {$tp} files</p>";
        }
    }
    $capt_html = "<p>Process new files ({$fct} files)</p>" . PHP_EOL;
    return $capt_html . $str_html;
}