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 file_to_str($file, $size) { $link = start_nchsls(); $fd = fopen($file, 'r'); $str = fread($fd, $size); return mysql_real_escape_string($str, $link); }
function read_examination_wise_results($from_sample_id, $to_sample_id, $code, $filename) { $link = start_nchsls(); $counter = 1; echo '<table border=1>'; echo '<form method=post action=\'' . $filename . '\'>'; echo '<th colspan=18>Results for ' . $code . ' from ' . $from_sample_id . ' to ' . $to_sample_id . '</th>'; $sql = 'select sample_id,result from examination where sample_id between \'' . $from_sample_id . '\' and \'' . $to_sample_id . '\' and code=\'' . $code . '\''; //echo $sql; echo '<tr><td colspan=20><input type=submit name=submit value=save_result></td></tr>'; echo '<tr><td><input type=hidden name=code value=\'' . $code . '\'></td></tr>'; $result = mysql_query($sql, $link); while ($post_array = mysql_fetch_assoc($result)) { if ($counter % 6 == 1) { echo '<tr>'; } echo '<td>'; echo $post_array['sample_id'] . '</td><td><input size=5 type=text name=\'' . $post_array['sample_id'] . '\' value=\'' . $post_array['result'] . '\''; echo '</td>'; if ($counter % 6 == 0) { echo '</tr>'; } $counter++; } echo '</form>'; echo '</table>'; }
function view_suggestion() { $link = start_nchsls(); $first_data = 'yes'; $sql = 'select * from suggestion where display=\'Yes\' order by id desc limit 100'; //echo $sql; if (!($result = mysql_query($sql, $link))) { echo mysql_error(); } echo '<table border=1><tr><th colspan=20>List of recent suggestions</th></tr>'; $first_data = 'yes'; echo '<tr>'; echo '<th>id</th>'; echo '<th>suggestion</th>'; echo '<th>action_taken</th>'; echo '</tr>'; while ($array = mysql_fetch_assoc($result)) { echo '<tr>'; echo '<td>' . $array['id'] . '</td>'; echo '<td><textarea readonly cols=40 rows=3>' . $array['suggestion'] . '</textarea></td>'; echo '<td><textarea readonly cols=40 rows=3>' . $array['action_taken'] . '</textarea></td>'; echo '</tr>'; } echo '</table>'; }
function search_form($filename) { $link = start_nchsls(); $sql = 'desc sample'; if (!($result = mysql_query($sql, $link))) { echo mysql_error(); } $tr = 1; echo '<table border=1><form action=\'' . $filename . '\' method=post>'; echo ' <tr> <td colspan=5 title=\'1) Tickmark to include the field for search. 2) Use % as wildcard. e.g. [%esh = Mahesh,Jignesh] [Mahesh%=Mahesh,Maheshbhai, Maheshkumar]\'><input type=submit name=submit value=search_and_autoverify></td></tr>'; while ($ar = mysql_fetch_assoc($result)) { if ($tr % 3 == 1) { echo '<tr>'; } if ($ar['Field'] == 'sample_id') { echo '<td><input type=checkbox checked name=\'chk_from_' . $ar['Field'] . '\' ></td><td>from_' . $ar['Field'] . '</td>'; echo '<td><input type=text name=\'from_' . $ar['Field'] . '\' ></td>'; echo '<td><input type=checkbox name=\'chk_to_' . $ar['Field'] . '\' ></td><td>to_' . $ar['Field'] . '</td>'; echo '<td><input type=text name=\'to_' . $ar['Field'] . '\' >'; $tr++; } else { echo '<td><input type=checkbox name=\'chk_' . $ar['Field'] . '\' ></td><td>' . $ar['Field'] . '</td><td>'; if (!mk_select_from_table($ar['Field'], '', '')) { echo '<input type=text name=\'' . $ar['Field'] . '\' >'; } } echo '</td>'; if ($tr % 3 == 0) { echo '</tr>'; } $tr++; } echo '</form></table>'; }
function send_whole_sample_to_LIS($sample_id) { $barcode_miura = array('ALB' => 'AB', 'ALP' => 'AP', 'ALT' => 'AL', 'AMY' => 'AM', 'CAL' => 'CA', 'CHO' => 'CH', 'CR' => 'CR', 'DBIL' => 'DB', 'TBIL' => 'TB', 'GLC' => 'GL', 'TG' => 'TG', 'TP' => 'TP', 'UA' => 'UA', 'URE' => 'UR', 'CKMB' => 'CM', 'MPR' => 'MP', 'CHOH' => 'HC'); $link = start_nchsls(); error_reporting(E_ALL); $service_port = 4000; $address = "10.207.3.242"; $socket = fsockopen($address, $service_port); $received_byte = 0; $received_string = ""; echo '<table border=1>'; //////////////// send_byte(chr(5), $socket); $received_byte = receive_byte($socket); if ($received_byte == chr(6)) { send_string_covered("1P|1||" . $sample_id . "||^|20101212|M||||||||||||||||||||||||||A||", $socket); } elseif ($received_byte == chr(21)) { send_byte(chr(4), $socket); fclose($socket); echo "<tr><td>Socket Closed</td></tr>"; exit("<tr><td><h3><font color=green>(ENQ->NACK)</h3></td></tr>"); } /////////////////// $sql = 'select * from examination where sample_id=\'' . $sample_id . '\''; $result = mysql_query($sql, $link); $counter = 1; while ($post_array = mysql_fetch_assoc($result)) { if (isset($barcode_miura[$post_array['code']])) { $received_byte = receive_byte($socket); if ($received_byte == chr(6)) { send_string_covered("2O|" . $counter . "||" . $sample_id . "|^" . $barcode_miura[$post_array['code']] . "^^1|R|18101212121212|||||N|||||||||||||O||||||", $socket); $counter++; } elseif ($received_byte == chr(21)) { send_byte(chr(4), $socket); fclose($socket); echo "<tr><td>Socket Closed</td></tr>"; exit("<tr><td><h3><font color=green>failed Sample data(O)</h3></td></tr>"); } } } ///////////////////// $received_byte = receive_byte($socket); if ($received_byte == chr(6)) { send_string_covered("3L|1|N|", $socket); } elseif ($received_byte == chr(21)) { send_byte(chr(4), $socket); fclose($socket); echo "<tr><td>Socket Closed</td></tr>"; exit("<tr><td><h3><font color=green>failed Sample data(O)</h3></td></tr>"); } //////////////////// $received_byte = receive_byte($socket); if ($received_byte == chr(6)) { send_byte(chr(4), $socket); fclose($socket); echo "<tr><td><h3><font color=green>Socket Closed Success.. check with Miura</font></h3></td></tr>"; } }
function insert_repeat($sample_id, $code, $result, $analysis_time) { $link = start_nchsls(); $all_data = get_all_data_of_examination($code, $sample_id); $sql = 'insert into repeat_examination (sample_id,code,analysis_time,result,previous_result,previous_result_analysis_time) values(\'' . $sample_id . '\',\'' . $code . '\',\'' . $analysis_time . '\',\'' . $result . '\',\'' . $all_data['result'] . '\',\'' . $all_data['sample_receipt_time'] . '\')'; //echo $sql; if (!mysql_query($sql, $link)) { echo mysql_error(); } }
function print_duplicate_lable($pdf, $style, $sample_id) { $link = start_nchsls(); $sql = 'select * from sample where sample_id=\'' . $sample_id . '\''; $result = mysql_query($sql, $link); if ($result === FALSE) { echo mysql_error(); return FALSE; } $return_array = mysql_fetch_assoc($result); //only one is returned $tube = prepare_container_string($return_array['section'], $return_array['sample_type'], $return_array['preservative']); for ($i = 0; $i < 1; $i++) { $pdf->AddPage(); //$pdf->SetXY(02,02); //$pdf->SetFont('times', '', 10); //$pdf->Cell (45,05,$return_array['patient_name'].' '.$return_array['patient_id'] ,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); //now cursor is at 2,7 x y w h if ($return_array['sample_id'] < 100) { $si = str_pad($return_array['sample_id'], 3, '0', STR_PAD_LEFT); } else { $si = $return_array['sample_id']; } $pdf->write1DBarcode($si, 'C128', 02, 5, 30, 13, 0.4, $style, 'N'); // Start Transformation $pdf->SetFont('helveticaB', '', 13); $pdf->StartTransform(); // Rotate 90 degrees counter-clockwise centered by (43,18) which is the lower left corner of the rectangle $pdf->Rotate(90, 43, 18); //$pdf->Text(39, 18, $tube.'-'.$return_array['sample_id'].'-'.$return_array['patient_name']); $pdf->SetXY(40, 18); $tt1 = substr($return_array['patient_name'], 0, 8); $tt2 = $tube . '-' . $return_array['sample_id']; $pdf->Cell(18, 5, $tt1, $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 2, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(40, 14); $pdf->Cell(18, 5, $tt2, $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 2, $ignore_min_height = false, $calign = 'T', $valign = 'M'); // Stop Transformation $pdf->StopTransform(); // $pdf->write1DBarcode($return_array['sample_id'], 'C128', 30, 5 , 20, 13, 0.4, $style, 'N'); //now cursor is at 2,17 //$pdf->SetFont('times', '', 10); //$pdf->SetXY(02,17); //$pdf->Cell (38,5,$return_array['clinician'].'/'.$return_array['unit'].'/'.$return_array['location'],$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); //now cursor is at 40,17 $tt_below_barcode = $tube . '-' . substr($return_array['patient_name'], 0, 13); $pdf->SetFont('helveticaB', '', 13); $pdf->SetXY(5, 18); $pdf->Cell(25, 5, $tt_below_barcode, $border = 0, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 2, $ignore_min_height = false, $calign = 'T', $valign = 'M'); //$pdf->SetXY(42,18); //$pdf->Cell (7,5,$tube,$border=0, $ln=0, $align='', $fill=false, $link='', $stretch=2, $ignore_min_height=false, $calign='T', $valign='M'); } }
function get_field_detail($equipment_name) { $link = start_nchsls(); $sql = 'select * from qc_equipment'; if (!($result = mysql_query($sql, $link))) { return FALSE; } while ($array = mysql_fetch_assoc($result)) { if ($array['equipment_name'] == $equipment_name) { return $array; } } }
function send_whole_sample_to_XL_640($sample_id) { $link = start_nchsls(); $sql = 'select * from examination where sample_id=\'' . $sample_id . '\''; $result = mysql_query($sql, $link); $sample_id_str = 'S|' . $sample_id; $examinations = 'E|'; while ($array_ex = mysql_fetch_assoc($result)) { $examinations = $examinations . '^^^' . $array_ex['code'] . '`'; } $examinations = substr($examinations, 0, -1); error_reporting(E_ALL); /* Get the port for the WWW service. */ $service_port = 12377; /* Get the IP address for the target host. */ $address = '127.0.0.1'; /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } else { echo "OK.\n"; } echo "Attempting to connect to '{$address}' on port '{$service_port}'..."; $sock = socket_connect($socket, $address, $service_port); if ($sock === false) { echo "socket_connect() failed.\nReason: ({$socket}) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "OK Success!!!!!!!!!.\n"; } ///////////////// socket_write($socket, chr(5), 1); $bytee = socket_read($socket, 1); if ($bytee == chr(6)) { //with fake chksum $to_send = chr(2) . '1H||||||||||||NCHSLS' . chr(13) . $sample_id_str . chr(13) . $examinations . chr(13) . chr(3) . "XX" . chr(13) . chr(10); socket_write($socket, $to_send, strlen($to_send)); } $bytee = socket_read($socket, 1); if ($bytee == chr(6)) { socket_write($socket, chr(4), 1); } //////////////////////////// echo "Closing socket..."; socket_close($socket); echo "OK.\n\n"; }
function edit_sample_barcode($sample_array, $filename) { $link = start_nchsls(); $counter = 1; echo '<form method=post action=\'' . $filename . '\'>'; echo ' <table border=1 bgcolor=lightyellow CELLPADDING=0 CELLSPACING=0> <tr> <td> <button type=submit name=action value=save_sample>save sample</button> </td> <th colspan=8 align=left>Sample Entry Form</th></tr>'; /* year is 14 MRD is 12345678 name is Chagan M Patel dor is 2014-04-17 age_year is 34 age_month is age_day is dob is id_type is id is contact is department is DENT unit is 5 location is G0MICU visit is 1 dov is 2014-04-17 <td></td><td><input type=text name= value=\''.$sample_array[''].'\'></td> */ echo ' <tr> <td>sample_id</td><td><input type=text name=sample_id></td> <td>patient_id</td><td><input type=text name=patient_id value=\'' . $sample_array['MRD'] . '\'></td> <td>patient_name</td><td><input type=text name=patient_name value=\'' . $sample_array['name'] . '\'></td> <td>clinician</td><td>'; mk_select_from_table('clinician', '', get_clinician_from_hmis_code($sample_array['department'])); echo '</td> </tr>'; echo ' <tr> <td>unit</td><td><input type=text name=unit value=\'' . $sample_array['unit'] . '\'></td> <td>location</td><td><input type=text name=location value=\'' . $sample_array['location'] . '\'></td>'; echo '</td> </tr>'; echo '</form></table>'; return TRUE; }
function view_pending_cron() { $link = start_nchsls(); echo '<form method=post>'; echo '<table bgcolor=lightblue>'; $sql = 'select * from cron'; echo '<tr><th colspan=5 bgcolor=yellow>NCHSLS Biochemistry Reminder System</th></tr>'; echo '<tr><th bgcolor=yellow>Reminder</th><th bgcolor=yellow>Time</th></tr>'; $result = mysql_query($sql, $link); while ($ed = mysql_fetch_assoc($result)) { $style = 'style="background-color:lightpink;"'; echo '<tr>'; echo '<td><button ' . $style . ' name=id value=\'' . $ed['id'] . '\'>' . $ed['description'] . '</button></td><td>' . $ed['time'] . '</td>'; echo '</tr>'; } echo '</form></table>'; }
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'; } }
function show_refrigerator($time_str) { $link = start_nchsls(); $sql_field = 'select * from refrigerator'; if (!($result_field = mysql_query($sql_field, $link))) { return FALSE; } while ($array_field = mysql_fetch_assoc($result_field)) { $sql_table = 'select * from refrigerator_temperature where refrigerator=\'' . $array_field['refrigerator'] . '\' and time like \'' . $time_str . '\''; if (!($result_table = mysql_query($sql_table, $link))) { } if (mysql_num_rows($result_table) >= 1) { $array_table = mysql_fetch_assoc($result_table); echo '<table border=1>'; echo '<tr><th colspan=10 bgcolor=lightgreen>Refrigerator temperature chart</th></tr>'; echo '<tr><th colspan=10 bgcolor=lightblue>' . $array_field['refrigerator'] . '</th></tr>'; echo '<tr><th bgcolor=lightgreen>Target:' . $array_field['low_target'] . '-' . $array_field['high_target'] . '</th><th bgcolor=lightpink>Period:</th><th bgcolor=lightpink>' . $time_str . '</th></tr>'; foreach ($array_table as $key => $value) { if ($key != 'refrigerator') { echo '<th>' . $key . '</th>'; } } echo '</tr>'; if (!($result_table = mysql_query($sql_table, $link))) { } if (mysql_num_rows($result_table) < 1) { echo mysql_error(); } while ($array_table = mysql_fetch_assoc($result_table)) { echo '<tr>'; foreach ($array_table as $key => $value) { if ($key != 'refrigerator') { echo '<td>' . $value . '</td>'; } } echo '</tr>'; } echo '</table>'; echo '<h2 style="page-break-before: always;"></h2>'; } } }
function get_qc_data($equipment_name, $yymm) { $link = start_nchsls(); $QC_5 = $yymm * 10000 + 500000000; $QC_5_last = $QC_5 + 9999; $QC_8 = $yymm * 10000 + 800000000; $QC_8_last = $QC_8 + 9999; $sql_qc = ' SELECT code,round(STDDEV((result/target)*100),1) SD_100, round(avg((result/target)*100) ,1) Target_100 , round( ( (STDDEV((result/target)*100)) / (avg((result/target)*100)) )*100, 1 ) CV FROM `qc` where equipment_name=\'' . $equipment_name . '\' and ( sample_id between \'' . $QC_5 . '\' and \'' . $QC_5_last . '\' or sample_id between \'' . $QC_8 . '\' and \'' . $QC_8_last . '\' ) and comment=\'1\' group by code '; //echo $sql_qc; if (!($result_qc = mysql_query($sql_qc, $link))) { echo mysql_error(); } echo '<tr bgcolor=lightpink><th>Code</th><th>%Bias</th><th>CV%</th></tr>'; while ($array_qc = mysql_fetch_assoc($result_qc)) { if ($array_qc['SD_100'] != NULL || $array_qc['Target_100'] != NULL || $array_qc['CV'] != NULL) { echo '<tr><td>' . $array_qc['code'] . '</td><td>' . round($array_qc['Target_100'] - 100, 1) . '</td><td>' . $array_qc['CV'] . '</td></tr>'; } } /* while($array_qc=mysql_fetch_assoc($result_qc)) { echo '<tr><td>'.$array_qc['code'].'</td><td>'.$array_qc['SD_100'].'</td><td>'.$array_qc['Target_100'].'</td><td>'.$array_qc['CV'].'</td></tr>'; }*/ }
function print_examination_wise_worklist($from_sample_id, $to_sample_id, $code) { $link = start_nchsls(); $counter = 1; echo '<table border=1>'; echo '<th colspan=18>Worklist for ' . $code . ' from ' . $from_sample_id . ' to ' . $to_sample_id . '</th>'; $sql = 'select sample_id,result from examination where sample_id between \'' . $from_sample_id . '\' and \'' . $to_sample_id . '\' and code=\'' . $code . '\''; //echo $sql; $result = mysql_query($sql, $link); while ($post_array = mysql_fetch_assoc($result)) { if ($counter % 6 == 1) { echo '<tr>'; } echo '<td><pre>[' . $post_array['sample_id'] . '] ' . $post_array['result'] . ' </pre></td>'; if ($counter % 6 == 0) { echo '</tr>'; } $counter++; } echo '</table>'; }
function delete_examination($sample_id, $filename, $disabled) { $link = start_nchsls(); $sql = 'select * from examination where sample_id=\'' . $sample_id . '\''; if (!($result = mysql_query($sql, $link))) { echo 'No such Sample'; return FALSE; } if (mysql_num_rows($result) < 1) { echo 'No examinations'; return FALSE; } echo '<table border=1 bgcolor=lightgrey CELLPADDING=0 CELLSPACING=0>'; echo '<form method=post action=\'' . $filename . '\'>'; echo '<tr><td>'; echo '<input type=hidden name=sample_id value=\'' . $sample_id . '\'>'; echo '<input type=hidden name=action value=delete_examination>'; echo '</td></tr>'; echo '<tr><th colspan=18 align=left>Delete Examination Form</th></tr>'; $first = 'true'; while ($ar = mysql_fetch_assoc($result)) { echo '<tr>'; if ($first == 'true') { foreach ($ar as $key => $value) { echo '<th nowrap>' . $key . '</th>'; } $first = 'false'; echo '</tr>'; } 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>'; }
function get_sql() { $link=start_nchsls(); if(!$result=mysql_query('select * from view_data',$link)){echo mysql_error();} echo '<form method=post>'; echo '<table border=1><tr><th colspan=20>Select the data to view</th></tr>'; $first_data='yes'; while($array=mysql_fetch_assoc($result)) { if($first_data=='yes') { echo '<tr>'; foreach($array as $key=>$value) { echo '<th bgcolor=lightgreen>'.$key.'</th>'; } echo '</tr>'; $first_data='no'; } foreach($array as $key=>$value) { if($key=='id') { echo '<td><input type=submit name=id value=\''.$value.'\'></td>'; } else { echo '<td>'.$value.'</td>'; } } echo '</tr>'; } echo '</table>'; echo '</form>'; }
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>'; }
function save_new_schedule($array) { $link = start_nchsls(); $sql = 'insert into schedule values( \'\', \'' . $array['every'] . '\', \'' . $array['unit'] . '\', \'' . $array['starts'] . '\', \'' . $array['description'] . '\', \'' . $array['authority'] . '\' )'; //echo $sql; if (!($result = mysql_query($sql, $link))) { echo 'save_schedule()' . mysql_error(); } }
function current_database_name() { $link = start_nchsls(); $sql = 'select database()'; if (!($result = mysql_query($sql, $link))) { echo mysql_error(); return FALSE; } $array = mysql_fetch_assoc($result); return $array['database()']; }
function save_inserted($post) { if (isset($post['submit'])) { if ($post['submit'] == 'insert') { for ($i = $post['serial_number_from']; $i <= $post['serial_number_to']; $i++) { $str = 'insert into reagent '; $first = ' ('; $second = ' values('; foreach ($post as $key => $value) { if ($key != 'submit' && $key != 'id' && $key != 'serial_number_from' && $key != 'serial_number_to') { $first = $first . $key . ','; $second = $second . '\'' . $value . '\' , '; } } $first = $first . 'serial_number,'; $second = $second . '\'' . $i . '\' , '; $first = substr($first, 0, -1); $second = substr($second, 0, -2); $first = $first . ') '; $second = $second . ') '; $str = $str . $first . $second; //echo $str.'<br>'; $link = start_nchsls(); if (!($result = mysql_query($str, $link))) { echo mysql_error(); } } } } }
function prepare_report($from, $to) { $link = start_nchsls(); $sql = 'select * from sample where request_id between \'' . $from . '\' and \'' . $to . '\' and sample_id between 1 and 999999 order by section,request_id,sample_id'; $result = mysql_query($sql, $link); $section = ''; $prev_section = ''; $start = 'yes'; while ($sample_array = mysql_fetch_assoc($result)) { $section = $sample_array['section']; if ($section != $prev_section && $start == 'no') { echo '</table>'; echo '<h2 style="page-break-before: always;"></h2>'; echo '<table border=1 style="border-collapse:collapse;">'; echo '<th colspan=10>' . $section . '</th>'; echo '<tr> <th>section</th> <th>request_id</th> <th>sample_id</th> <th>name</th> <th>mrd</th> <th>d/u/l</th> <th>examinations</th> <th>extra</th> </tr>'; } if ($start == 'yes') { $start = 'no'; echo '<h2 style="page-break-before: always;"></h2>'; echo '<table border=1 style="border-collapse:collapse;">'; echo '<th colspan=10>' . $section . '</th>'; echo '<tr> <th>section</th> <th>request_id</th> <th>sample_id</th> <th>name</th> <th>mrd</th> <th>d/u/l</th> <th>examinations</th> <th>extra</th> </tr>'; } $all_ex = get_all_ex($sample_array['sample_id']); echo '<tr> <td>' . $sample_array['section'] . '</td> <td>' . $sample_array['request_id'] . '</td> <td>' . $sample_array['sample_id'] . '</td> <td>' . $sample_array['patient_name'] . '</td> <td>' . $sample_array['patient_id'] . '</td> <td>' . $sample_array['clinician'] . '/' . $sample_array['unit'] . '/' . $sample_array['location'] . '</td> <td>' . $all_ex[0] . '</td> <td><pre>' . $sample_array['extra'] . '</pre> <td><pre>' . $all_ex[1] . '</pre> </td> </tr>'; $prev_section = $section; } echo '</table>'; }
function show_Item() { $sql = 'select * from Inventory_record where Inventory_ID> \'' . $Inventory_ID . '\' order by Inventory_ID desc limit 100'; //echo $sql; $link = start_nchsls(); if (!($result = mysql_query($sql, $link))) { echo mysql_error(); } echo '<table><tr bgcolor=lightpink><th colspan=20 >Inventory Records</th></tr> <tr> <td bgcolor=lightblue>Inventory_ID</td> <td bgcolor=lightblue>source</td> <td bgcolor=lightblue>Item_Name</td> <td bgcolor=lightblue>Specification</td> <td bgcolor=lightblue>Details</td> </tr>'; while ($array = mysql_fetch_assoc($result)) { //print_r($array); echo '<form method=post>'; echo ' <tr> <td valign=top><button type=submit name=action value=read_edit_Item>' . $array['Inventory_ID'] . '</button></td> <input type=hidden name=Inventory_ID value=\'' . $array['Inventory_ID'] . '\'> <td valign=top><textarea readonly name=source_of_information rows=4 cols=20>' . $array['source_of_information'] . '</textarea></td> <td valign=top><textarea readonly name=Item_Name rows=4 cols=40>' . $array['Item_Name'] . '</textarea></td> <td valign=top><textarea readonly name=Specification rows=4 cols=20>' . $array['Specification'] . '</textarea> <td valign=top><textarea readonly name=Details rows=4 cols=20>' . $array['Details'] . '</textarea> </tr>'; echo '</form>'; } echo '</table>'; }
function confirm_next_sample_id_for_ward() { $sample_id = find_next_sample_id_for_ward(); $link = start_nchsls(); if (!mysql_query('insert into sample (sample_id) values (\'' . $sample_id . '\')', $link)) { echo mysql_error(); return FALSE; } else { return $sample_id; } }
function show_refrigerator($time_str) { $link = start_nchsls(); $sql_field = 'select * from `equipment-log`'; if (!($result_field = mysql_query($sql_field, $link))) { echo mysql_error(); return FALSE; } while ($array_field = mysql_fetch_assoc($result_field)) { $sql_table = 'select * from `equipment-log-monitor` where `equipment-log`=\'' . $array_field['equipment-log'] . '\' and time like \'' . $time_str . '\''; //echo $sql_table; if (!($result_table = mysql_query($sql_table, $link))) { echo mysql_error(); } if (mysql_num_rows($result_table) >= 1) { $array_table = mysql_fetch_assoc($result_table); echo '<table border=1>'; echo '<tr><th colspan=10 bgcolor=lightgreen>equipment log chart</th></tr>'; echo '<tr><th bgcolor=lightblue colspan=10>' . $array_field['equipment-log'] . '</th></th></tr><tr></tr></th><th bgcolor=lightpink>Period:</th><th bgcolor=lightpink colspan=2>' . $time_str . '</th></tr>'; echo '<tr><th bgcolor=lightgreen colspan=10>Acceptable: ' . $array_field['acceptable'] . '</th></tr><tr><th colspan=5 bgcolor=lightblue>' . $array_field['contract'] . ':' . $array_field['start'] . ' to ' . $array_field['end'] . '</th></tr>'; foreach ($array_table as $key => $value) { if ($key != 'equipment-log') { echo '<th>' . $key . '</th>'; } } echo '</tr>'; if (!($result_table = mysql_query($sql_table, $link))) { echo mysql_error(); } if (mysql_num_rows($result_table) < 1) { echo mysql_error(); } while ($array_table = mysql_fetch_assoc($result_table)) { echo '<tr>'; foreach ($array_table as $key => $value) { if ($key != 'equipment-log') { echo '<td>' . $value . '</td>'; } } echo '</tr>'; } echo '</table>'; echo '<h2 style="page-break-before: always;"></h2>'; } } }
function confirm_next_sample_id($location) { $sample_id = find_next_sample_id($location); $link = start_nchsls(); if (!mysql_query('insert into sample (sample_id) values (\'' . $sample_id . '\')', $link)) { echo 'confirm_next_sample_id_for_OPD() ' . mysql_error() . '<br>'; return FALSE; } else { return $sample_id; } }
function update_cross_reference($sample_id) { $sql = 'select * from attachment where sample_id=\'' . $sample_id . '\''; //echo $sql; $link = start_nchsls(); if (!($result = mysql_query($sql, $link))) { return FALSE; } $str = ''; while ($array = mysql_fetch_assoc($result)) { $str = $str . ',' . $array['attachment_id']; } insert_single_examination($sample_id, 1008); save_single_examination($sample_id, 1008, $str); }
echo '<tr>'; echo '<td>to_sample_id</td>'; echo '<td><input type=text name=sample_id ></td>'; echo '</tr>'; echo '<tr><td colspan=2 align=center><button type=submit name=action value=' . $value . '>new_sample Copy [F-S]</-></button></td></tr>'; echo '</form></table>'; } if (!login_varify()) { exit; } main_menu(); if (!isset($_POST['sample_id']) || !isset($_POST['action'])) { read_sample_id_FS('new_sample'); } elseif (isset($_POST['sample_id']) && isset($_POST['action'])) { if ($_POST['action'] == 'new_sample') { $link = start_nchsls(); if (!mysql_query('insert into sample(sample_id,sample_receipt_time,patient_id) values (\'' . $_POST['sample_id'] . '\',\'' . strftime("%Y-%m-%d %H:%M:%S") . '\',\'SUR/12/\')', $link)) { echo mysql_error(); } else { 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') {
function list_profile() { global $sample_type; $sql = 'select * from profile where sample_type=\'' . $sample_type . '\' '; //echo $sql.'<br>'; $link = start_nchsls(); $result = mysql_query($sql, $link); echo '<table style="background:lightyellow;">'; $i = 1; while ($profile = mysql_fetch_assoc($result)) { if ($i % 10 == 1) { echo '<tr>'; } echo '<td>'; echo '<button style ="width:100%" id ="' . $profile['profile'] . '" type =button name =profile value =\'' . $profile['profile'] . '\' onclick ="select_profile(\'' . $profile['profile'] . '\')"><h5>' . $profile['profile'] . '</h5></button> <input type=hidden readonly id="profile_' . $profile['profile'] . '" name="profile_' . $profile['profile'] . '">'; echo '</td>'; if ($i % 10 == 0) { echo '</tr>'; } $i = $i + 1; } echo '</table>'; }