Uploaded From CV. Swandhana Server

This commit is contained in:
Duidev Software House
2025-01-27 08:16:55 +07:00
commit 6b3be42361
15186 changed files with 2328862 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SyncLabResultsSerial extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:sync-lab-results-serial';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
$host = '192.168.1.100'; // IP alat
$port = 4000; // Port alat
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $host, $port);
$response = socket_read($socket, 1024);
// Proses response dari alat
$this->processSocketData($response);
socket_close($socket);
}
protected function processSocketData($data)
{
// Proses data yang diterima (misalnya parsing atau format hasil tes)
$testResult = json_decode($data, true);
// Simpan hasil tes ke database
TestResult::create([
'patient_id' => $testResult['patient_id'],
'test_id' => $testResult['test_id'],
'result_value' => $testResult['result_value'],
'timestamp' => $testResult['timestamp']
]);
}
}