function insert_required_samples($post)
{
    echo '<button type=button  style="background:lightpink;" id=showhide onclick="showhide()">hide</button>';
    $req = analyse_examination_request($post);
    if (count($req) == 0) {
        return FALSE;
    }
    //echo '<pre>';
    //echo 'Reuqested Examinations';
    //print_r($req);
    //echo '</pre>';
    $sample_id_array = array();
    //('Blood(Plasma,Serum)|None'=>34)
    $link = start_nchsls();
    foreach ($req as $key => $value) {
        $sql = 'select * from scope where id=\'' . $value . '\'';
        $result = mysql_query($sql, $link);
        if ($result === FALSE) {
            echo mysql_error();
            return FALSE;
        }
        $return_array = mysql_fetch_assoc($result);
        if (array_key_exists($return_array['sample_type'] . '|' . $return_array['preservative'], $sample_id_array)) {
            $sample_id = $sample_id_array[$return_array['sample_type'] . '|' . $return_array['preservative']];
            insert_single_examination($sample_id, $value);
        } else {
            $sample_id = confirm_next_sample_id('OPD');
            //new sample_id inserted
            $sample_array['sample_id'] = $sample_id;
            $sample_array['patient_id'] = 'SUR/' . date("y") . '/' . str_pad($post['mrd'], 8, '0', STR_PAD_LEFT);
            $sample_array['patient_name'] = $post['name'];
            $sample_array['clinician'] = $post['selected_department'];
            $sample_array['unit'] = '-';
            $sample_array['location'] = 'OPD';
            $sample_array['sample_type'] = $return_array['sample_type'];
            $sample_array['preservative'] = $return_array['preservative'];
            $sample_array['sample_details'] = $post['selected_sample_details'];
            $sample_array['urgent'] = 'N';
            $sample_array['status'] = 'entered';
            $sample_array['sample_receipt_time'] = strftime("%Y-%m-%d %H:%M:%S");
            $sample_array['sample_collection_time'] = strftime("%Y-%m-%d %H:%M:%S");
            save_sample($sample_array);
            //data filled
            $sample_id_array[$return_array['sample_type'] . '|' . $return_array['preservative']] = $sample_id;
            //added in array
            insert_single_examination($sample_id, $value);
            //Examination inserted
        }
    }
    //echo '<pre>';
    //print_r($sample_id_array);
    //echo '</pre>';
    $list_of_samples = '';
    foreach ($sample_id_array as $key => $value) {
        $list_of_samples = $list_of_samples . '|' . $value;
    }
    echo '<table><tr>';
    echo '<td>';
    echo '<form method=post target=_blank action=print_sample_barcode.php>';
    echo '<button  style="background:lightpink;" type=submit name=list_of_samples value=\'' . $list_of_samples . '\'' . '>Barcode</button>';
    echo '</form>';
    echo '</td>';
    foreach ($sample_id_array as $key => $value) {
        $list_of_samples = $list_of_samples . '|' . $value;
        if (strpos($key, "None")) {
            $style = "border:2px solid red;color:red;font-weight:bolder;";
        } else {
            if (strpos($key, "Fluoride")) {
                $style = "border:2px solid black;color:black;font-weight:bolder;";
            } else {
                $style = "border:2px solid black;font-color:black;";
            }
        }
        echo '<td style=\'' . $style . '\'>' . $key . '=>' . $value . '</td>';
    }
    echo '</tr></table>';
    echo '<div id=display>';
    foreach ($sample_id_array as $key => $value) {
        edit_sample($value, '', 'disabled', 'no');
        edit_examination($value, '', 'disabled');
    }
    echo '</div>';
}
Ejemplo n.º 2
0
            save_sample_FS($_POST['from_sample_id'], $_POST['sample_id']);
            edit_sample($_POST['sample_id'], 'new_request_FS.php	', '', '');
        }
    } elseif ($_POST['action'] == 'save_sample') {
        if (!save_sample($_POST)) {
            echo 'no sample saved<br>';
        } else {
            edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
            select_profile($_POST['sample_id'], 'new_request_FS.php	');
            select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
        }
    } elseif ($_POST['action'] == 'profile') {
        insert_profile($_POST['sample_id'], $_POST['profile']);
        edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
        edit_examination($_POST['sample_id'], 'new_request_FS.php	', '');
        select_profile($_POST['sample_id'], 'new_request_FS.php	');
        select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
    } elseif ($_POST['action'] == 'save_examination') {
        save_examination($_POST);
        edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
        edit_examination($_POST['sample_id'], 'new_request_FS.php	', 'disabled');
        select_profile($_POST['sample_id'], 'new_request_FS.php	');
        select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
    } elseif ($_POST['action'] == 'select_examination') {
        insert_single_examination($_POST['sample_id'], $_POST['id']);
        edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
        edit_examination($_POST['sample_id'], 'new_request_FS.php	', '');
        select_profile($_POST['sample_id'], 'new_request_FS.php	');
        select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
    }
}
        }
        foreach ($ar as $key => $value) {
            if ($key == 'id') {
                echo '<td nowrap><input type=submit ' . $disabled . ' name=id \' value=\'' . $value . '\'></td>';
            } else {
                echo '<td nowrap>' . $value . '</td>';
            }
        }
        echo '</tr>';
    }
    echo '</form></table>';
}
if (!login_varify()) {
    exit;
}
main_menu();
if (!isset($_POST['sample_id']) || !isset($_POST['action'])) {
    read_sample_id('delete_examination');
} elseif (isset($_POST['sample_id']) && isset($_POST['action'])) {
    if ($_POST['action'] == 'delete_examination') {
        if (isset($_POST['id'])) {
            $link = start_nchsls();
            $sql = 'delete from examination where sample_id=\'' . $_POST['sample_id'] . '\' and id=\'' . $_POST['id'] . '\'';
            //echo $sql;
            $result = mysql_query($sql, $link);
            //echo 'deleted '.mysql_affected_rows($link).' examination<br>';
        }
        edit_sample($_POST['sample_id'], 'edit_request.php	', 'disabled', 'no');
        delete_examination($_POST['sample_id'], 'delete_examination_request.php	', '');
    }
}
function insert_required_samples($post)
{
    echo '<button type=button  style="background:lightpink;" id=showhide onclick="showhide()">hide</button>';
    $req = analyse_examination_request($post);
    if (count($req) == 0) {
        return FALSE;
    }
    //echo '<pre>';
    //echo 'Reuqested Examinations';
    //print_r($req);
    //echo '</pre>';
    $sample_id = confirm_next_sample_id($post['selected_location']);
    echo '<div id=display>';
    $sample_array = array();
    if (isset($sample_id)) {
        $sample_array['sample_id'] = $sample_id;
        $sample_array['patient_id'] = 'SUR/' . date("y") . '/' . str_pad($post['mrd'], 8, '0', STR_PAD_LEFT);
        $sample_array['patient_name'] = $post['name'];
        $sample_array['clinician'] = $post['selected_department'];
        $sample_array['unit'] = $post['selected_unit'];
        $sample_array['location'] = $post['selected_location'];
        $sample_array['sample_type'] = $post['selected_sample_type'];
        $sample_array['preservative'] = 'None';
        $sample_array['sample_details'] = $post['selected_sample_details'];
        $sample_array['urgent'] = 'N';
        $sample_array['status'] = 'entered';
        $sample_array['sample_receipt_time'] = strftime("%Y-%m-%d %H:%M:%S");
        $sample_array['sample_collection_time'] = strftime("%Y-%m-%d %H:%M:%S");
        if (save_sample($sample_array) === FALSE) {
            echo '<h4>Can not insert the last ID found. Retry</h4>';
            return FALSE;
        }
        $ex_list = '';
        foreach ($req as $key => $value) {
            insert_single_examination($sample_array['sample_id'], $value);
            $ex_list = $ex_list . ',' . get_code_from_id($value);
        }
        echo '<table style="background:lightblue;"><tr><td>';
        echo '<form method=post target=_blank action=print_sample_barcode.php>';
        echo '<input type=hidden name=patient_name value=\'' . $sample_array['patient_name'] . '\'>';
        echo '<input type=hidden name=patient_id value=\'' . $sample_array['patient_id'] . '\'>';
        echo '<input type=hidden name=ex_list value=\'' . $ex_list . '\'>';
        echo '<input type=hidden name=tube value=\'S\'>';
        echo '<button  style="background:lightpink;" type=submit name=sample_id value=\'' . $sample_array['sample_id'] . '\'>Barcode-' . $sample_array['sample_id'] . '</button>';
        echo '</form>';
        echo '<form method=post target=_blank action=edit_request.php>';
        echo '<input type=hidden name=sample_id value=\'' . $sample_array['sample_id'] . '\'>';
        echo '<button style="background:lightgreen;" type=submit name=action value=edit_sample>Edit-' . $sample_array['sample_id'] . '</button>';
        echo '</form></td><td>';
        edit_sample($sample_array['sample_id'], '', 'disabled', 'no');
        edit_examination($sample_array['sample_id'], '', 'disabled');
        echo '</td></tr></table>';
    }
    echo '</div>';
}
function insert_required_samples($post)
{
    global $sample_type, $location, $unit;
    echo '<button type=button  style="background:lightpink;" id=showhide onclick="showhide()">hide</button>';
    echo '<div id=display>';
    $req = analyse_examination_request($_POST);
    //echo '<pre>';
    //echo 'Reuqested Examinations';
    //print_r($req);
    //echo '</pre>';
    $req_tube = find_required_tubes($req);
    if ($req_tube === FALSE) {
        return FALSE;
    }
    //echo 'required tubes:'.$req_tube.'<br>';
    if ($req_tube == 'P') {
        $plain_sample_id = confirm_next_sample_id($post['selected_location']);
        if ($plain_sample_id === FALSE) {
            return FALSE;
        }
    } else {
        if ($req_tube == 'F') {
            $fluoride_sample_id = confirm_next_sample_id($post['selected_location']);
            if ($fluoride_sample_id === FALSE) {
                return FALSE;
            }
        } else {
            if ($req_tube == 'PF') {
                $fluoride_sample_id = confirm_next_sample_id($post['selected_location']);
                $plain_sample_id = confirm_next_sample_id($post['selected_location']);
                if ($plain_sample_id === FALSE || $fluoride_sample_id === FALSE) {
                    return FALSE;
                }
            }
        }
    }
    $sample_array = array();
    if (isset($fluoride_sample_id)) {
        $sample_array['sample_id'] = $fluoride_sample_id;
        $sample_array['patient_id'] = 'SUR/' . date("y") . '/' . str_pad($post['mrd'], 8, '0', STR_PAD_LEFT);
        $sample_array['patient_name'] = $post['name'];
        $sample_array['clinician'] = $post['selected_department'];
        $sample_array['unit'] = $post['selected_unit'];
        $sample_array['location'] = $post['selected_location'];
        $sample_array['sample_type'] = $sample_type;
        $sample_array['preservative'] = 'Fluoride';
        $sample_array['sample_details'] = $post['selected_sample_details'];
        $sample_array['urgent'] = 'N';
        $sample_array['status'] = 'entered';
        $sample_array['sample_receipt_time'] = strftime("%Y-%m-%d %H:%M:%S");
        $sample_array['sample_collection_time'] = strftime("%Y-%m-%d %H:%M:%S");
        save_sample($sample_array);
        $id = get_id_from_code('GLC', $sample_array['sample_type'], $sample_array['preservative']);
        insert_single_examination($sample_array['sample_id'], $id);
        $ex_list = 'GLC';
        echo '<table style="background:lightblue;"><tr><td>';
        echo '<form method=post target=_blank action=print_sample_barcode.php>';
        echo '<input type=hidden name=patient_name value=\'' . $sample_array['patient_name'] . '\'>';
        echo '<input type=hidden name=patient_id value=\'' . $sample_array['patient_id'] . '\'>';
        echo '<input type=hidden name=ex_list value=\'' . $ex_list . '\'>';
        echo '<input type=hidden name=tube value=\'F\'>';
        echo '<button style="background:lightpink;" type=submit name=sample_id value=\'' . $sample_array['sample_id'] . '\'>Barcode-' . $sample_array['sample_id'] . '</button>';
        echo '</form>';
        echo '<form method=post target=_blank action=edit_request.php>';
        echo '<input type=hidden name=sample_id value=\'' . $sample_array['sample_id'] . '\'>';
        echo '<button style="background:lightgreen;" type=submit name=action value=edit_sample>Edit-' . $sample_array['sample_id'] . '</button>';
        echo '</form></td><td>';
        edit_sample($sample_array['sample_id'], '', 'disabled', 'no');
        edit_examination($sample_array['sample_id'], '', 'disabled');
        echo '</td></tr></table>';
    }
    if (isset($plain_sample_id)) {
        $sample_array['sample_id'] = $plain_sample_id;
        $sample_array['patient_id'] = 'SUR/' . date("y") . '/' . str_pad($post['mrd'], 8, '0', STR_PAD_LEFT);
        $sample_array['patient_name'] = $post['name'];
        $sample_array['clinician'] = $post['selected_department'];
        $sample_array['unit'] = $post['selected_unit'];
        $sample_array['location'] = $post['selected_location'];
        $sample_array['sample_type'] = $sample_type;
        $sample_array['preservative'] = 'None';
        $sample_array['sample_details'] = $post['selected_sample_details'];
        $sample_array['urgent'] = 'N';
        $sample_array['status'] = 'entered';
        $sample_array['sample_receipt_time'] = strftime("%Y-%m-%d %H:%M:%S");
        $sample_array['sample_collection_time'] = strftime("%Y-%m-%d %H:%M:%S");
        save_sample($sample_array);
        $ex_list = '';
        foreach ($req as $key => $value) {
            if ($value != 'GLC') {
                $id = get_id_from_code($value, $sample_array['sample_type'], $sample_array['preservative']);
                insert_single_examination($sample_array['sample_id'], $id);
                $ex_list = $ex_list . ',' . $value;
            }
        }
        echo '<table style="background:lightblue;"><tr><td>';
        echo '<form method=post target=_blank action=print_sample_barcode.php>';
        echo '<input type=hidden name=patient_name value=\'' . $sample_array['patient_name'] . '\'>';
        echo '<input type=hidden name=patient_id value=\'' . $sample_array['patient_id'] . '\'>';
        echo '<input type=hidden name=ex_list value=\'' . $ex_list . '\'>';
        echo '<input type=hidden name=tube value=\'S\'>';
        echo '<button  style="background:lightpink;" type=submit name=sample_id value=\'' . $sample_array['sample_id'] . '\'>Barcode-' . $sample_array['sample_id'] . '</button>';
        echo '</form>';
        echo '<form method=post target=_blank action=edit_request.php>';
        echo '<input type=hidden name=sample_id value=\'' . $sample_array['sample_id'] . '\'>';
        echo '<button style="background:lightgreen;" type=submit name=action value=edit_sample>Edit-' . $sample_array['sample_id'] . '</button>';
        echo '</form></td><td>';
        edit_sample($sample_array['sample_id'], '', 'disabled', 'no');
        edit_examination($sample_array['sample_id'], '', 'disabled');
        echo '</td></tr></table>';
    }
    echo '</div>';
}
Ejemplo n.º 6
0
     edit_sample($_POST['sample_id'], 'autoverify_action.php	', 'disabled', 'No');
     edit_examination($_POST['sample_id'], 'autoverify_action.php	', '');
 } elseif ($_POST['action'] == '5') {
     save_single_examination_code($_POST['sample_id'], $_POST['code'], 'not done');
     insert_single_examination($_POST['sample_id'], 1002);
     append_single_examination($_POST['sample_id'], 1002, $_POST['code'] . ' NOT DONE done because sample inadequate.');
     edit_sample($_POST['sample_id'], 'autoverify_action.php	', 'disabled', 'No');
     edit_examination($_POST['sample_id'], 'autoverify_action.php	', '');
 } elseif ($_POST['action'] == '6') {
     save_single_examination_code($_POST['sample_id'], $_POST['code'], 'not done');
     insert_single_examination($_POST['sample_id'], 1002);
     append_single_examination($_POST['sample_id'], 1002, $_POST['code'] . ' NOT DONE done because lab. resources inadequate.');
     edit_sample($_POST['sample_id'], 'autoverify_action.php	', 'disabled', 'No');
     edit_examination($_POST['sample_id'], 'autoverify_action.php	', '');
 } elseif ($_POST['action'] == '7') {
     edit_sample($_POST['sample_id'], 'autoverify_action.php	', 'disabled', 'No');
     edit_examination($_POST['sample_id'], 'autoverify_action.php	', '');
 }
 /*
 	elseif($_POST['action']=='delete_examination')
 	{
 		if(isset($_POST['code']))
 		{
 			$link=start_nchsls();
 			$sql='delete from examination where sample_id=\''.$_POST['sample_id'].'\' and code=\''.$_POST['code'].'\'';
 			echo $sql;
 			$result=mysql_query($sql,$link);
 			echo 'deleted '.mysql_affected_rows($link).' examination<br>';	
 		}
 		edit_sample($_POST['sample_id'],'autoverify_action.php	','disabled','No');
 		edit_examination($_POST['sample_id'],'autoverify_action.php	','disabled');
function insert_required_samples($post)
{
    //echo $post['selected_ex'];
    //$selected_ex=explode('|',$post['selected_ex']);
    $required_sample = array();
    //print_r($selected_ex);
    $selected_ex = analyse_examination_request($post);
    //prepare array of required samples	and examinations to be done in each
    foreach ($selected_ex as $value) {
        if (strlen($value) > 0) {
            $ex_info = get_scope_info($value);
            //print_r($ex_info);
            $required_sample[$ex_info['section']][$ex_info['sample_type']][$ex_info['preservative']][] = $ex_info['id'];
        }
    }
    //echo '<pre>';
    //print_r($required_sample);
    //echo '</pre>';
    //insert require sample and examinations to be done in each
    $inserted_sample = '';
    foreach ($required_sample as $section => $section_value) {
        foreach ($section_value as $sample_type => $sample_type_value) {
            foreach ($sample_type_value as $preservative => $preservative_value) {
                //echo 'insert a sample:'.$section.'-'.$sample_type.'-'.$preservative.'-'.$value.'<br>';
                $sample_id = confirm_next_sample_id($section, $post['selected_location']);
                if ($sample_id === FALSE) {
                    echo 'can not allocate sample_id: insert_required_samples($post)';
                    return;
                } else {
                    $inserted_sample = $inserted_sample . '|' . $sample_id;
                }
                $st = '<h4>';
                if ($preservative == 'None') {
                    $st = '<h4 style="border:2px;color:red">';
                } elseif ($preservative == 'Fluoride') {
                    $st = '<h4 style="border:2px;color:gray">';
                }
                if ($preservative == 'EDTA') {
                    $st = '<h4 style="border:2px;color:purple">';
                }
                $string = $st . $section . '-' . $sample_type . '-' . $preservative . '-SAMPLE_ID=' . $sample_id . '</h4>';
                ?>
						<script  type="text/javascript">
						document.getElementById('sample_list_box').innerHTML=document.getElementById('sample_list_box').innerHTML  + <?php 
                echo '\'' . $string . '\'';
                ?>
;	
						
						</script>
						<?php 
                $sample_array['sample_id'] = $sample_id;
                $sample_array['patient_id'] = 'SUR/' . date("y") . '/' . str_pad($post['mrd'], 8, '0', STR_PAD_LEFT);
                $sample_array['patient_name'] = $post['name'];
                $sample_array['clinician'] = $post['selected_department'];
                $sample_array['unit'] = $post['selected_unit'];
                $sample_array['location'] = $post['selected_location'];
                $sample_array['sample_type'] = $sample_type;
                $sample_array['preservative'] = $preservative;
                $sample_array['sample_details'] = $post['selected_sample_details'];
                $sample_array['urgent'] = 'N';
                $sample_array['status'] = 'entered';
                $sample_array['sample_receipt_time'] = strftime("%Y-%m-%d %H:%M:%S");
                $sample_array['sample_collection_time'] = strftime("%Y-%m-%d %H:%M:%S");
                $sample_array['section'] = $section;
                $sample_array['request_id'] = $post['request_id'];
                $sample_array['extra'] = $post['extra'];
                save_sample($sample_array);
                foreach ($preservative_value as $value) {
                    //echo 'insert an examination:'.$value.'<br>';
                    insert_single_examination($sample_id, $value);
                }
                edit_sample($sample_id, '', 'disabled', 'no');
                edit_examination($sample_id, '', 'disabled');
            }
        }
    }
    //echo $inserted_sample;
    $barcode_html = '<form target=_blank  method=post action=print_sample_barcode.php><button type=submit  name=list_of_samples value=\'' . $inserted_sample . '\'>Print Barcodes</button></form>';
    ?>
		<script  type="text/javascript">
		// ' " with javascript and PHP mix create many problem
		document.getElementById('sample_list_box').innerHTML=document.getElementById('sample_list_box').innerHTML  + <?php 
    echo '"' . $barcode_html . '"';
    ?>
;	
		</script>
		<?php 
}