Example #1
0
function prompt_critical_reportable($sample_id)
{
    $all_details = get_all_details_of_a_sample($sample_id);
    if ($all_details == FALSE) {
        return;
    }
    $critical = 'no';
    foreach ($all_details as $ex_data) {
        //echo '<pre>';
        //print_r($ex_data);
        //$sample_type,$code,$result
        $ret = check_critical_abnormal_reportable($ex_data['sample_type'], $ex_data['code'], $ex_data['result']);
        //echo '<h1>'.$ex_data['result'].'-'.$ret.'</h1>';
        if ($ret == '1' || $ret == '2' || $ret == '4' || $ret == '3') {
            $critical = 'yes';
            $result = get_examination_result_id(1005, $sample_id);
            check_critical_reporting($sample_id);
            echo '	<tr>
					<td>' . $sample_id . '</td>
					<td>' . $ex_data['patient_id'] . '</td>
					<td>' . $ex_data['patient_name'] . '</td>
					<td>' . $ex_data['sample_type'] . '</td>
					<td>' . $ex_data['preservative'] . '</td>
					<td>' . $ex_data['code'] . '</td>					
					<td>' . $ex_data['result'] . '</td>
					<td>' . $ex_data['clinician'] . '</td>
					<td>' . $ex_data['unit'] . '</td>	
					<td>' . $ex_data['location'] . '</td>
					</tr>';
        }
    }
    if ($critical == 'yes') {
        echo '	<tr>
				<td>' . $ex_data['location'] . '</td>
				<td colspan=10>
					<input type=text  size="80" name=\'result_1005_' . $sample_id . '\' value=\'' . $result . '\'>
				</td>
				</tr><tr bgcolor=lightpink><td colspan=10>.....</td></tr>';
    }
}
*/
include 'common.php';
if (!login_varify()) {
    exit;
}
main_menu();
if ($_SESSION['login'] != 'root') {
    echo '<h3>You are not allowed to use this menu item!</h3>';
    exit;
}
if (isset($_POST['submit'])) {
    if ($_POST['submit'] == 'make_sql') {
        echo '<h4>You are trying to alter sample_ids of ' . $_POST['year'] . '-' . $_POST['month'] . '</h4>';
        echo '<h4>Current year and month is ' . date("y") . '-' . date("m") . '</h4>';
        //echo strlen($_POST['year']) .',' .strlen($_POST['month']).'<br>';
        $all_data = get_all_details_of_a_sample(1);
        //do not allow update if sample_id=1 have sample_receipt_time not matching with what you entered
        //This means that you are trying to update wrong sample ids
        if (date("y", strtotime($all_data[0]['sample_receipt_time'])) == date("y") && date("m", strtotime($all_data[0]['sample_receipt_time'])) == date("m")) {
            echo '<h5>Look at sample_id=1. The sample_receipt_time is ' . $all_data[0]['sample_receipt_time'];
            echo '<h5>It is different from the month ' . $_POST['month'] . ' or the year ' . $_POST['year'] . ' you entered</h5>';
            echo '<h5>Varify if sample id you wish to change are for the same month or not</h5>';
        } else {
            if (strlen($_POST['month']) != 2 || strlen($_POST['year']) != 2) {
                echo '<h5>Year and months must be in two digit format</h5>';
            } else {
                if (date("d") > 1 || date("H") > 13) {
                    echo '<h5>You can not change sample ids on any date other than 1st of a month, that too before 13.00 hours</h5>';
                } else {
                    //echo 'making sql....<br>';
                    $sql = '	update sample 
Example #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');
    }
}