Example #1
0
/**
 * filter input and generate display of x12 file
 * 
 * @uses csv_filetohtml()
 * @uses ibr_upload_files()
 * @uses ibr_ebr_ebt_name()
 * @return string
 */
function ibr_disp_fileText()
{
    //
    $str_html = '';
    //isset($_POST['fileX12']) && isset($_FILES['fileUplx12'])
    if (count($_FILES) && isset($_FILES['fileUplx12'])) {
        $fn = htmlentities($_FILES['fileUplx12']['name']);
        $str_html = ibr_html_heading('newfiles', $fn);
        $f_array = ibr_upload_files($str_html);
        if (is_array($f_array) && count($f_array)) {
            $str_html .= csv_filetohtml($f_array);
        } else {
            $str_html = ibr_html_heading('error');
            $str_html .= "no files accepted <br />" . PHP_EOL;
        }
    } elseif (isset($_GET['fvkey'])) {
        $fn = filter_input(INPUT_GET, 'fvkey', FILTER_SANITIZE_STRING);
        // Availity 'readable' versions ibr, ebr, dpr
        $ishr = isset($_GET['readable']) && $_GET['readable'] == 'yes' ? true : false;
        if (!$fn) {
            $str_html = ibr_html_heading('error');
        } elseif ($ishr && $fn) {
            $ftxt = ibr_ebr_ebt_name($fn);
            $str_html = ibr_html_heading('textdisplay', $ftxt);
            $str_html .= csv_filetohtml($ftxt);
        } else {
            $bn = basename($fn);
            $str_html = ibr_html_heading('textdisplay', $bn);
            $str_html .= csv_filetohtml($fn);
        }
    } elseif (isset($_GET['btctln'])) {
        $btisa13 = filter_input(INPUT_GET, 'btctln', FILTER_SANITIZE_STRING);
        if ($btisa13) {
            //$btname = ibr_batch_find_file_with_controlnum($btisa13);
            $btname = csv_file_by_controlnum('batch', $btisa13);
            $str_html = ibr_html_heading('textdisplay', $btname);
            if ($btname) {
                $str_html .= csv_filetohtml($btname);
            } else {
                $str_html .= "Failed to identify file with control number {$btisa13} <br />" . PHP_EOL;
            }
        } else {
            $str_html .= "error in file display <br />";
        }
    } else {
        $str_html = ibr_html_heading('error');
        $str_html .= "error in file display <br />";
    }
    return $str_html;
}
Example #2
0
/**
 * parse dpr file into an array
 * 
 * @uses ibr_ebr_ebt_name()
 * @param array  the array from csv_ebr_filetoarray()
 * @param string  the file path
 * @return array
 */
function ibr_dpr_values($ar_dpr_fields, $dpr_filepath)
{
    // the .dpr file is one DPR line for each batch file
    // followed by a CST for each patient for that payer in the batch file
    //
    if ($dpr_filepath) {
        $fname = basename($dpr_filepath);
        $dpt_name = ibr_ebr_ebt_name($fname);
    } else {
        csv_edihist_log("ibr_dpr_values: no file path provided");
        return FALSE;
    }
    if (!is_array($ar_dpr_fields) && count($ar_dpr_fields) > 0) {
        csv_edihist_log("ibr_dpr_values: no values array provided");
        return FALSE;
    }
    //
    $ar_dpr_clm = array();
    //
    foreach ($ar_dpr_fields as $fld) {
        //
        if ($fld[0] == "DPR") {
            $batch_ctrl = $fld[3];
            $batch_name = $fld[6];
            continue;
        }
        if ($fld[0] = "CST") {
            // CST line -- there may be one or more for each DPR line, but we just create a line entry for
            //  each CST line
            //  -- only have a claims_dpr.csv file
            //
            $ar_pid = preg_split('/\\D/', $fld[2], 2, PREG_SPLIT_NO_EMPTY);
            if (count($ar_pid) == 2) {
                $pid = $ar_pid[0];
                $enctr = $ar_pid[1];
            } else {
                $enctr = substr($fld[2], -IBR_ENCOUNTER_DIGIT_LENGTH);
                $pid = substr($fld[2], 0, strlen($fld[2]) - IBR_ENCOUNTER_DIGIT_LENGTH);
            }
            //
            $clm01 = $fld[2];
            $payer_id = $fld[3];
            $pt_name = $fld[5];
            $frm_date = $fld[6];
            $payer_name = $fld[15];
            // take the fields out of order because the message precedes the status
            //
            $clm_status = $fld[11];
            // Status|  "REJ" or "ACK"
            //
            $msg_txt = "";
            // DPR_MSG_DELIM is '^' and '^' is a PCRE metacharacter
            // the DPR layout leaves a lot to be desired, there is no telling what you will get
            // but it appears to be a distillation of the 277
            $msg_ar = explode(DPR_MSG_DELIM, $fld[9]);
            if (is_array($msg_ar) && count($msg_ar)) {
                for ($i = 0; $i < count($msg_ar); $i++) {
                    $statuspos = strpos($msg_ar[$i], 'Status:');
                    if ($statuspos) {
                        $msg_txt = substr($msg_ar[$i], $statuspos) . ' ' . substr($msg_ar[$i], 0, $statuspos - 1);
                    } else {
                        $msg_txt .= strpos($msg_ar[$i], '\\') === false ? $msg_ar[$i] : str_replace('\\', ' ', $msg_ar[$i]);
                    }
                }
            }
            $msg_txt = trim($msg_txt);
            $clm_ins_id = $fld[12];
            // Payer Claim Number|
            $clm_ins_name = $fld[15];
            // Payer Name|
            //
            //$csv_hd_ar['dpr']['claim'] = array('PtName','SvcDate', 'clm01', 'Status', 'Batch', 'FileName', 'Payer')
            // add the values to the output array
            $ar_dpr_clm[] = array('pt_name' => $pt_name, 'date' => $frm_date, 'clm01' => $clm01, 'status' => $clm_status, 'payer_name' => $payer_name, 'batch_name' => $batch_name, 'dpr_name' => $fname, 'dpr_text' => $dpt_name, 'message' => $msg_txt);
        }
        // 'pt_name''date''pid''enctr''ext''status''batch_name''file_text''message'
    }
    // end foreach
    //
    return $ar_dpr_clm;
}