request->getRawInput(); if (empty($input)) { return $this->fail('No JSON data received', 400); } var_dump($input); //return $this->respond($input, 200); } public function dictTests() { $db = \Config\Database::connect(); $sql = "select top 5 HISCODE as ServiceCode, DESCS as ServiceName from cmod.dbo.CM_DICT_MAPPINGS"; $query = $db->query($sql); $results = $query->getResultArray(); $data = $results; return $this->respond($data,200); } // public function generate_uuid(): string { // // $data = random_bytes(16); // // $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // Set version to 0100 // // $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // Set to IETF variant // // return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); // // Generate random hexadecimal blocks // $block1 = bin2hex(random_bytes(2)); // 4 characters // $block2 = bin2hex(random_bytes(2)); // 4 characters // $block3 = bin2hex(random_bytes(6)); // 12 characters // // Concatenate in desired pattern // return "{$block1}-{$block2}-{$block3}{$block1}-{$block2}-{$block3}{$block1}-{$block2}-{$block3}"; // } // function generateUUID24(): string { // return substr(bin2hex(random_bytes(12)), 0, 24); // } // function generateUUID32(): string { // return substr(bin2hex(random_bytes(16)), 0, 32); // } // 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); // } // $data = [ // "test_ref_id" => $uuid32, // "service_id"=> "", // "service_name"=> $result['TESTCODE'], // "test_medium"=> "", // "test_container"=> "", // "chapter_type"=> "", // "test_summary"=> "", // "status"=> "", // ]; }