From f9e5e4d9f7e0b166e08a60f31f1e1500dd72c71b Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Mon, 20 Jan 2025 17:02:17 +0800 Subject: [PATCH] separate req n res, fix BV SV to only B / S --- app/Config/Routes.php | 4 +- app/Controllers/{API.php => API_Requests.php} | 103 +--------------- app/Controllers/API_Results.php | 110 ++++++++++++++++++ app/Controllers/Home.php | 11 ++ env | 69 +++++++++++ public/.htaccess | 2 - public/web.config | 33 ++++++ 7 files changed, 226 insertions(+), 106 deletions(-) rename app/Controllers/{API.php => API_Requests.php} (54%) create mode 100644 app/Controllers/API_Results.php create mode 100644 app/Controllers/Home.php create mode 100644 env create mode 100644 public/web.config diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f50e609..1e45de9 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -6,5 +6,5 @@ use CodeIgniter\Router\RouteCollection; * @var RouteCollection $routes */ $routes->get('/', 'Pages::home'); -$routes->post('/api/requests/', 'API::requests'); -$routes->get('/api/results/(:any)', 'API::results/$1'); +$routes->post('/api/requests/', 'API_Requests::requests'); +$routes->get('/api/results/(:any)', 'API_Results::results/$1'); diff --git a/app/Controllers/API.php b/app/Controllers/API_Requests.php similarity index 54% rename from app/Controllers/API.php rename to app/Controllers/API_Requests.php index e9b1d42..940b676 100644 --- a/app/Controllers/API.php +++ b/app/Controllers/API_Requests.php @@ -4,7 +4,7 @@ namespace App\Controllers; use CodeIgniter\RESTful\ResourceController; use CodeIgniter\I18n\Time; -class API extends ResourceController { +class API_Requests extends ResourceController { public function requests() { $db = \Config\Database::connect(); @@ -107,105 +107,4 @@ class API extends ResourceController { */ } - public function results($accessnumber) { - $db = \Config\Database::connect(); - - // $sql = "select HOSTORDERNUMBER as HISNO from SP_REQUESTS where SP_ACCESSNUMBER='$accessnumber'"; - // $query = $db->query($sql); - // $results = $query->getResultArray(); - // $data['LISNO'] = $accessnumber; - // $hisno = $results[0]['HISNO']; - // $sql = "select TESTCODE, TESTORDER, RESTYPE, RESVALUE, RESFLAG, UNIT, REFRANGE, USERVAL, RESDATE - // from cmod.dbo.CM_RESULTS r - // where ACCESSNUMBER='$accessnumber' - // order by TESTORDER"; - // $query = $db->query($sql); - // $results = $query->getResultArray(); - - $sql = "SELECT sp.HOSTORDERNUMBER, hiso.LOC, hiso.PAYERNAME - FROM dbo.SP_REQUESTS sp - LEFT JOIN cmod.dbo.CM_HIS_ORDERS hiso ON hiso.VISITNUMBER = sp.HOSTORDERNUMBER - WHERE SP_ACCESSNUMBER = '$accessnumber'"; - $query = $db->query($sql); - $results = $query->getResultArray(); - - $location = $results[0]['LOC'] == null ? 'PBMC Bali' : 'PBMC Surabaya'; - $payer_name = $results[0]['PAYERNAME'] == null ? '' : $results[0]['PAYERNAME']; - - $sql = "select - dc.CHAPID, - 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.DEPTH as text_depth, - t.NOTPRINTABLE, - 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.* - from REQUESTS r - 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_TEXTS tx on tx.TEXTID=t.CODEDRESULTID - left join DICT_CHAPTERS dc on dc.CHAPID=dt.CHAPID and dc.ENDVALIDDATE is null - left join DICT_TEST_SAMPLES ts on ts.TESTID=t.TESTID and dt.TESTID=ts.TESTID - left join DICT_SAMPLES_TYPES st on st.SAMPTYPEID=ts.SAMPTYPEID - left join cmod.dbo.CM_DICT_TESTS cdt on dt.TESTCODE=cdt.TESTCODE - left join cmod.dbo.CM_RESULTS cr on cr.ACCESSNUMBER=r.ACCESSNUMBER and cr.TESTCODE=cdt.TESTCODE and cr.TESTCODE=dt.TESTCODE - where r.ACCESSNUMBER='$accessnumber' - ORDER BY t.TESTORDER"; - $query = $db->query($sql); - $test_results = $query->getResultArray(); - - // $uuid24 = $this->generateUUID24(); - $response = [ - "headers" => [ - "Content-Type" => "application/json", - "Authorization" => "Transmedic api key" - ], - "data" => [ - "reference_id" => "", - "created" => "2024-10-19T02:11:06.424654Z", - "company_name" => $payer_name, - "branch" => $location, - "test_results" => [] - ] - ]; - - // Digunakan Untuk Hasil test - foreach ($test_results as $result) { - - // var_dump($result);die(); - - if ($result['text_depth'] == 0) { - // $uuid32 = $this->generateUUID32(); - $uuid24 = $this->generateUUID24(); - - $data = [ - "test_ref_id"=> $uuid24, - "service_id"=> "", - "service_name"=> $result['test_eng'], - "test_medium"=> $result['serum_type'], - "test_container"=> "", - "chapter_type"=> $result['chap_eng'], - "test_summary"=> "", - "status"=> "", - ]; - - array_push($response['data']['test_results'], $data); - } - - - } - - - return $this->respond($response,200); - } - } diff --git a/app/Controllers/API_Results.php b/app/Controllers/API_Results.php new file mode 100644 index 0000000..d0d395e --- /dev/null +++ b/app/Controllers/API_Results.php @@ -0,0 +1,110 @@ +query($sql); + // $results = $query->getResultArray(); + // $data['LISNO'] = $accessnumber; + // $hisno = $results[0]['HISNO']; + // $sql = "select TESTCODE, TESTORDER, RESTYPE, RESVALUE, RESFLAG, UNIT, REFRANGE, USERVAL, RESDATE + // from cmod.dbo.CM_RESULTS r + // where ACCESSNUMBER='$accessnumber' + // order by TESTORDER"; + // $query = $db->query($sql); + // $results = $query->getResultArray(); + + $sql = "SELECT sp.HOSTORDERNUMBER, hiso.LOC, hiso.PAYERNAME + FROM dbo.SP_REQUESTS sp + LEFT JOIN cmod.dbo.CM_HIS_ORDERS hiso ON hiso.VISITNUMBER = sp.HOSTORDERNUMBER + WHERE SP_ACCESSNUMBER = '$accessnumber'"; + $query = $db->query($sql); + $results = $query->getResultArray(); + + $location = $results[0]['LOC'] == null ? 'PBMC Bali' : 'PBMC Surabaya'; + $payer_name = $results[0]['PAYERNAME'] == null ? '' : $results[0]['PAYERNAME']; + + $sql = "select + dc.CHAPID, + 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.DEPTH as text_depth, + t.NOTPRINTABLE, + 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.* + from REQUESTS r + 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_TEXTS tx on tx.TEXTID=t.CODEDRESULTID + left join DICT_CHAPTERS dc on dc.CHAPID=dt.CHAPID and dc.ENDVALIDDATE is null + left join DICT_TEST_SAMPLES ts on ts.TESTID=t.TESTID and dt.TESTID=ts.TESTID + left join DICT_SAMPLES_TYPES st on st.SAMPTYPEID=ts.SAMPTYPEID + left join cmod.dbo.CM_DICT_TESTS cdt on dt.TESTCODE=cdt.TESTCODE + left join cmod.dbo.CM_RESULTS cr on cr.ACCESSNUMBER=r.ACCESSNUMBER and cr.TESTCODE=cdt.TESTCODE and cr.TESTCODE=dt.TESTCODE + where r.ACCESSNUMBER='$accessnumber' + ORDER BY t.TESTORDER"; + $query = $db->query($sql); + $test_results = $query->getResultArray(); + + // $uuid24 = $this->generateUUID24(); + $response = [ + "headers" => [ + "Content-Type" => "application/json", + "Authorization" => "Transmedic api key" + ], + "data" => [ + "reference_id" => "", + "created" => "2024-10-19T02:11:06.424654Z", + "company_name" => $payer_name, + "branch" => $location, + "test_results" => [] + ] + ]; + + // Digunakan Untuk Hasil test + foreach ($test_results as $result) { + + // var_dump($result);die(); + + if ($result['text_depth'] == 0) { + // $uuid32 = $this->generateUUID32(); + $uuid24 = $this->generateUUID24(); + + $data = [ + "test_ref_id"=> $uuid24, + "service_id"=> "", + "service_name"=> $result['test_eng'], + "test_medium"=> $result['serum_type'], + "test_container"=> "", + "chapter_type"=> $result['chap_eng'], + "test_summary"=> "", + "status"=> "", + ]; + + array_push($response['data']['test_results'], $data); + } + + + } + + return $this->respond($response,200); + } + +} \ No newline at end of file diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php new file mode 100644 index 0000000..5934333 --- /dev/null +++ b/app/Controllers/Home.php @@ -0,0 +1,11 @@ + diff --git a/public/web.config b/public/web.config new file mode 100644 index 0000000..116c616 --- /dev/null +++ b/public/web.config @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +