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>'; } }
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'); } }