first result commit

This commit is contained in:
mahdahar 2025-01-23 13:30:00 +07:00
parent e6750627c1
commit 89ac4fd55e

View File

@ -27,7 +27,7 @@ class API_Results extends ResourceController {
$response = [ $response = [
"headers" => [ "headers" => [
"Content-Type" => "application/json", "Content-Type" => "application/json",
"Authorization" => "NasiGorengBambuRuncing", "Authorization" => "MILUZAKARIA",
"AppCode" => "2" "AppCode" => "2"
], ],
"data" => [ "data" => [
@ -39,9 +39,10 @@ class API_Results extends ResourceController {
] ]
]; ];
$sql = "select dc.CHAPID, t.DEPTH as depth_test, dc.FULLTEXT as chap_eng, dc.FULLTEXT as chap_ind, st.FULLTEXT as serum_type, cdt.TEXT1 as test_eng, cdt.TEXT2 as test_ind, cdt.UNIT as UNITTEXT, cdt.REFFTEXT, t.NOTPRINTABLE, $sql = "select dc.CHAPID, t.DEPTH as depth_test, dc.FULLTEXT as chap_eng, dc.FULLTEXT as chap_ind, st.FULLTEXT as serum_type, cdt.TEXT1 as test_eng, cdt.TEXT2 as test_ind,
cdt.UNIT as UNITTEXT, cdt.REFFTEXT, t.NOTPRINTABLE,
t.TESTORDER, t.RESTYPE as code_type, t.VALIDATIONINITIALS as validator, dt.SHORTTEXT, t.TESTORDER, t.RESTYPE as code_type, t.VALIDATIONINITIALS as validator, dt.SHORTTEXT,
RESULT = case when t.RESVALUE is null then tx.FULLTEXT else t.RESVALUE end, cr.*, ct.*, tub.TUBENAME RESULT = case when t.RESVALUE is null then tx.FULLTEXT else t.RESVALUE end, ct.REFFTESTID, m.HISCODE, m.LISCODE, tub.TUBENAME, cr.REFRANGE, dt.TESTCODE, t.TESTORDER
from REQUESTS r from REQUESTS r
left join TESTS t on t.REQUESTID = r.REQUESTID left join TESTS t on t.REQUESTID = r.REQUESTID
left join DICT_TESTS dt on dt.ENDVALIDDATE is null and t.TESTID=dt.TESTID left join DICT_TESTS dt on dt.ENDVALIDDATE is null and t.TESTID=dt.TESTID
@ -54,44 +55,52 @@ left join cmod.dbo.CM_RESULTS cr on cr.ACCESSNUMBER=r.ACCESSNUMBER and cr.TESTCO
left join cmod.dbo.CM_DICT_MAPPINGS m on m.LISCODE=cr.TESTCODE left join cmod.dbo.CM_DICT_MAPPINGS m on m.LISCODE=cr.TESTCODE
left join cmod.dbo.CM_TM_TESTS ct on ct.HISCODE=m.HISCODE left join cmod.dbo.CM_TM_TESTS ct on ct.HISCODE=m.HISCODE
left join cmod.dbo.CM_DICT_TUBES tub on tub.TUBEID=m.TUBEID left join cmod.dbo.CM_DICT_TUBES tub on tub.TUBEID=m.TUBEID
where r.ACCESSNUMBER='$accessnumber' where r.ACCESSNUMBER='$accessnumber' ORDER BY t.TESTORDER";
ORDER BY dc.CHAPID, depth_test, t.TESTORDER";
$query = $db->query($sql); $query = $db->query($sql);
$test_results = $query->getResultArray(); $test_results = $query->getResultArray();
$d0 = 0;
foreach ($test_results as $result) { foreach ($test_results as $result) {
$refftestid = trim($result['REFFTESTID']); $refftestid = trim($result['REFFTESTID']);
$testorder = $result['TESTORDER'];
if($refftestid == '') { $refftestid = $accessnumber . str_pad($testorder,3,0, STR_PAD_LEFT); }
$hiscode = $result['HISCODE']; $hiscode = $result['HISCODE'];
$tubename = $result['TUBENAME']; $tubename = $result['TUBENAME'];
$depth = $result['depth_test']; $depth = $result['depth_test'];
if ( $depth == 0) { $liscode = $result['LISCODE'];
$testcode = $result['TESTCODE'];
$testname = $result['test_eng'];
$sampletype = $result['serum_type'];
$chapter = $result['chap_eng'];
$testresult = $result['RESULT'];
$refrange = $result['REFRANGE'];
$refftext = $result['REFFTEXT'];
if($refftext != '') { $testreff = $refftext; }
else { $testreff = $refrange; }
if($liscode == '') {$liscode = $testcode;}
$data = [ $data = [
"test_ref_id"=> "$refftestid", "test_ref_id"=> "$refftestid",
"service_id"=> "$hiscode", "hiscode"=> "$hiscode",
"service_name"=> $result['test_eng'], "liscode"=> "$liscode",
"test_medium"=> $result['serum_type'], "service_name"=> "$testname",
"test_medium"=> "$sampletype",
"test_container"=> "$tubename", "test_container"=> "$tubename",
"chapter_type"=> $result['chap_eng'], "chapter_type"=> "$chapter",
# "test_summary"=> "", "test_result"=> "$testresult",
# "status"=> "", "test_reff" => "$testreff",
"test_summary"=> "",
"subtest_results" => [], "subtest_results" => [],
]; ];
array_push($response['data']['test_results'], $data); if ( $depth == 0 || $depth == '' ) { // depth 0
$d0++; if(isset($d0)) { $d0++; } else { $d0 = 0; }
} else if ($depth == 1) { $d1=0;
// $data = [ $response['data']['test_results'][] = $data;
// "subtest_ref_id"=> $uuid, } else if ($depth == 1) { // depth 1
// "subtest_name"=> $result['SHORTTEXT'], if(isset($d1)) { $d1++; }
// "subtest_uom"=> $result['TESTCODE'], $d2=0;
// "subtest_lower_limit"=> "", $response['data']['test_results'][$d0]['subtest_results'][] = $data;
// "subtest_upper_limit"=> "", } else if ($depth == 2) { // depth 2
// "subtest_critical_lower_limit"=> "", if(isset($d2)) { $d2++; }
// "subtest_critiacl_upper_limit"=> "", $d3=0;
// "subtest_result"=> "", $response['data']['test_results'][$d0]['subtest_results'][$d1]['subtest_results'][] = $data;
// "subtest_summary"=> "",
// "sub_subtest_results" => [],
// ];
// array_push($response['data']['test_results']['subtest_results'], $data);
} }
} }