Exemplo n.º 1
0
function import_results_miura()
{
    $link = start_nchsls();
    echo '<H1>Importing Results from Miura-300 file</H1>';
    $counter = 0;
    $uploaddir = '/';
    $uploadfile = $uploaddir . basename($_FILES['import_file']['name']);
    if ($handle = fopen($_FILES['import_file']['tmp_name'], "r")) {
        while (($data = fgetcsv($handle, 0, ';')) !== FALSE) {
            if (isset($data[2]) && isset($data[6]) && isset($data[4])) {
                if (ctype_digit($data[2]) && is_numeric($data[6]) && $data[6] > 0) {
                    $sql = 'update examination set result=\'' . $data[6] . '\' , details=concat(str_to_date(\'' . $data[10] . '\',\'%Y/%m/%d_%H_%i_%S\'),\'|Miura-300\') 
					where sample_id=\'' . $data[2] . '\' 
					and code=\'' . $data[4] . '\'
					and strcmp(substr(result,1,1),\'(\')';
                    //echo '<br>'.$sql;
                    if (!mysql_query($sql, $link)) {
                        echo mysql_error();
                    } else {
                        echo '<br>[' . mysql_affected_rows($link) . ']->' . $data[2] . '->' . $data[4] . '->' . $data[6];
                        $counter = $counter + mysql_affected_rows($link);
                        change_sample_status($data[2], 'analysed');
                    }
                } else {
                    echo '<br>' . $data[2] . ':sample_id is not digits or ' . $data[6] . ':result is not-numeric/0 or less';
                }
                //print_r($data);
            }
        }
        fclose($handle);
        echo '<h1>Updated data=' . $counter . '</h1>';
    } else {
        echo 'can not fopen';
    }
}
function import_results_XL_640()
{
    global $batch_of_sample;
    //07/06/2011 09:41:27 XL
    //2011-07-06 12:23:51 ideal
    $link = start_nchsls();
    echo '<H4>Importing Results from Erba XL-640</H4>';
    $counter = 0;
    $uploaddir = '/';
    $uploadfile = $uploaddir . basename($_FILES['import_file']['name']);
    if ($handle = fopen($_FILES['import_file']['tmp_name'], "r")) {
        while (($data = fgetcsv($handle, 0, chr(9))) !== FALSE) {
            if (isset($data[2]) && isset($data[5]) && isset($data[4])) {
                if (ctype_digit($data[2]) && is_numeric($data[5]) && $data[5] > 0) {
                    $batch_of_sample[$data[2]] = '';
                    ///////autoverify with no action
                    //autoverify($data[2],'','no');
                    ////////////////////////////////
                    $sql = 'update examination set result=\'' . $data[5] . '\' , details=concat(str_to_date(\'' . $data[8] . '\',\'%m/%d/%Y %H:%i:%S\'),\'|Erba-XL-640\') 
								where sample_id=\'' . $data[2] . '\' 
								and code=\'' . $data[4] . '\'  
								and strcmp(substr(result,1,1),\'(\')';
                    //echo '<br>'.$sql;
                    if (!mysql_query($sql, $link)) {
                        echo mysql_error();
                    } else {
                        $affected = mysql_affected_rows($link);
                        $counter = $counter + mysql_affected_rows($link);
                        if (get_sample_status($data[2]) != 'verified') {
                            //echo '<br><font color=red>['.$affected.']->'.$data[2].'->'.$data[4].'->'.$data[5].'</font>';
                            change_sample_status($data[2], 'analysed');
                        }
                    }
                } else {
                    //echo '<br>'.$data[2].':sample_id is not digits or '.$data[5].':result  is not-numeric/0 or less';
                }
            }
        }
        fclose($handle);
        echo '<h4>Updated data=' . $counter . '</h4>';
    } else {
        echo 'can not fopen';
    }
}
Exemplo n.º 3
0
function autoverify($sample_id, $filename, $action)
{
    global $reflex;
    if (get_sample_status($sample_id) == 'verified') {
        return;
    }
    if (!($all_details = get_all_details_of_a_sample($sample_id))) {
        return FALSE;
    }
    $verified = 0;
    foreach ($all_details as $key => $value) {
        $error_code_array = array();
        //CSF and Blood(Serum,Plasma) have no diff
        //$acr_code=check_critical_abnormal_reportable($value['sample_id'],$value['code']);
        $acr_code = check_critical_abnormal_reportable($value['sample_type'], $value['code'], $value['result']);
        //////////empty
        if ($acr_code == -2) {
            $error_code_array[] = $acr_code;
        }
        //-2 if empty
        //////////////critical 3,4
        if ($acr_code == 3 || $acr_code == 4) {
            $error_code_array[] = check_critical_reporting($sample_id);
            //8 if incomplate
        }
        //////////////absurd 1,2
        if ($acr_code == 1 || $acr_code == 2) {
            insert_single_examination($value['sample_id'], 1007);
            append_if_not('Send new sample to resolve absurd values.', $sample_id, 1007);
            $error_code_array[] = $acr_code;
            //1,2
        }
        //////////reflax if abnormal high(2,4,6)   //cholesterol=13
        if ($acr_code == 2 || $acr_code == 4 || $acr_code == 6 || $acr_code == 1 || $acr_code == 3 || $acr_code == 5) {
            if ($value['location'] == 'F3N(503)' && $value['code'] == 'TBIL') {
            } else {
                if ($reflex == 'yes') {
                    $any_ex_inserted = reflex_testing($sample_id, $value['id'], $acr_code);
                    if ($any_ex_inserted > 0) {
                        $verified = 1;
                    }
                    // if any is inserted, verification require next round of autoverification
                }
            }
        }
        ///////////////ibil
        if ($value['code'] == 'IBIL') {
            $ibil = indirect_bilirubin($value['sample_id']);
            if ($ibil == '11') {
                $error_code_array[] = 11;
                //11 if >10% diff
            }
        }
        ///////////////LDL
        if ($value['code'] == 'CHOL') {
            lipid_profile($value['sample_id']);
        }
        //////total of error to decide if verified(=0)
        foreach ($error_code_array as $error_value) {
            $verified = $verified + abs($error_value);
        }
        if ($action == 'yes') {
            ///////action
            error_action($value['sample_id'], $value['code'], $error_code_array, $filename);
            ///////
        }
    }
    ////update status
    if ($verified != 0) {
        change_sample_status($sample_id, 'verification failed');
    } else {
        change_sample_status($sample_id, 'verified');
    }
}