This commit is contained in:
Dwi Swandhana
2026-02-19 09:42:12 +07:00
parent 6d859d1c6a
commit fddfe775ce
2 changed files with 64 additions and 75 deletions
@@ -1858,54 +1858,31 @@ class DokterController extends Controller
} else if ($worklist == 'getgenexpert'){
$isidata = $request->input('isi');
try {
$ketemu = '';
$cekada = ResultSample::where('accession_number', 'LIKE', $nofoto.'%')->get();
if ($cekada->isNotEmpty()){
foreach($cekada as $rows){
$ketemu .= ($ketemu ? '<br />' : '') . $rows->test_status;
}
} else {
$payload = [
'command' => 'request_result',
'data' => [
'sample_id' => $nofoto
],
];
$response = Http::timeout(30)->post($this->lisServiceUrl . '/command', $payload);
if ($response->successful()) {
Log::info('Permintaan hasil berhasil dikirim ke LIS service.', [
'sample_id' => $nofoto,
'response' => $response->json()
]);
} else {
Log::error('Gagal terhubung ke LIS service saat meminta hasil.', [
'sample_id' => $nofoto,
'status' => $response->status(),
'body' => $response->body()
]);
}
$cekdata = Periksa::where('nofoto', $nofoto)->first();
$noregister = $cekdata->noregister ?? '';
$url = 'http://10.10.120.14:6002/api/genexpert/query-result';
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Accept' => 'application/json',
])->timeout(30)
->post($url, [
'accnumber' => $nofoto,
'register_no' => $noregister,
]);
if ($response->successful()) {
Log::info('requestResult.', [
'status' => $response->status(),
'message' => $response->json()
]);
}
if ($ketemu != ''){
if (is_null($isidata) || $isidata == ''){
$isidata = $ketemu;
} else {
$isidata = $isidata.'<br />'.$ketemu;
}
}
if (!is_null($isidata) && $isidata != ''){
KomponenJawaban::updateOrCreate(
[
'accnumber' => $nofoto,
'template' => $request->input('jenis'),
'komponen' => $request->input('komponen'),
],
[
'isidata' => $isidata,
'created_by' => Session('nama')
]
);
}
$pesan = $isidata;
Log::error('Exception dalam fungsi requestResult.', [
'status' => $response->status(),
'message' => 'Python Server Error: ' . $response->body()
]);
} catch (Exception $e) {
$pesan = (is_null($isidata) ? '' : $isidata . '<br />') . 'Error: ' . $e->getMessage();
Log::error('Exception dalam fungsi requestResult.', [