Update send order ke Python MiniPCs

This commit is contained in:
servdal
2025-08-23 19:59:36 +07:00
parent 094ceb0b9f
commit 0cecf8760c
3 changed files with 284 additions and 75 deletions
@@ -51,6 +51,11 @@ define( 'API_ACCESS_KEY', 'AAAA6YBXh1k:APA91bFL0q7QAXQGohXMpTwHco79f13C8PFk1Oo8k
class DokterController extends Controller
{
protected $lisServiceUrl;
public function __construct()
{
$this->lisServiceUrl = env('LIS_SERVICE_URL', 'http://localhost:5000');
}
protected static function genSurat($id, $tabel){
if ($tabel == 'dengan kop'){
$kopsurat = url('/templateimage/kopsurat.png');
@@ -1127,7 +1132,7 @@ class DokterController extends Controller
}
return response()->json(['pesan' => $pesan, 'organism' => $organism]);
return back();
} else if ($worklist == 'getbbachtect' OR $worklist == 'getmgit' OR $worklist == 'getgenexpert' OR $worklist == 'getabbot'){
} else if ($worklist == 'getbbachtect' OR $worklist == 'getmgit' OR $worklist == 'getabbot'){
$isidata = $request->input('isi');
try {
$ketemu = '';
@@ -1166,6 +1171,67 @@ class DokterController extends Controller
$pesan = $isidata.'<br />'.$e->getMessage();
}
return $pesan;
} 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()
]);
}
}
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;
} catch (Exception $e) {
$pesan = (is_null($isidata) ? '' : $isidata . '<br />') . 'Error: ' . $e->getMessage();
Log::error('Exception dalam fungsi requestResult.', [
'sample_id' => $nofoto,
'exception' => $e->getMessage()
]);
}
return response($pesan, 200);
} else if ($worklist == 'addviralload'){
$tabelawal = $request->input('tabelawal');
$idtabel = $request->input('idtabel');