Update
This commit is contained in:
@@ -470,6 +470,7 @@ class DokterController extends Controller
|
||||
'created_by' => Session('nama')
|
||||
]
|
||||
);
|
||||
$statusdraft = 'Proses Analisis Sampel';
|
||||
KomponenJawaban::where('accnumber', $nofoto)->where('template', $dlp)->delete();
|
||||
$data = $request->except(['_token', 'periksa_id', 'val01', 'val10', 'acc_number']);
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -487,6 +488,20 @@ class DokterController extends Controller
|
||||
]
|
||||
);
|
||||
} else {
|
||||
if ($key == 'id_statusmediatamlainnya' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else if ($key == 'id_statusmediasellainnya' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else if ($key == 'id_statusmediasda' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else if ($key == 'id_statusmediamcconkey' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else if ($key == 'id_statusmediacap' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else if ($key == 'id_statusmediabap' AND $value != ''){
|
||||
$statusdraft = $value;
|
||||
} else {
|
||||
}
|
||||
KomponenJawaban::updateOrCreate(
|
||||
[
|
||||
'accnumber' => $nofoto,
|
||||
@@ -581,7 +596,7 @@ class DokterController extends Controller
|
||||
'nmdrafter' => Session('nama'),
|
||||
'nmexcutor' => Session('nama'),
|
||||
'excutor' => Session('id'),
|
||||
'status' => 'Proses Analisis Sampel'
|
||||
'status' => $statusdraft
|
||||
]);
|
||||
$surat = self::genSurat($periksa->id, 'dengan kop');
|
||||
Riwayat::create([
|
||||
@@ -622,7 +637,7 @@ class DokterController extends Controller
|
||||
'nmdrafter' => Session('nama'),
|
||||
'nmexcutor' => Session('nama'),
|
||||
'excutor' => Session('id'),
|
||||
'status' => 'Proses Analisis Sampel'
|
||||
'status' => $statusdraft
|
||||
]);
|
||||
return response()->json(['icon' => 'success', 'status' => 'Success', 'message' => 'Expertise Saved']);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,7 @@ use ZipArchive;
|
||||
class JsonTransferController extends Controller
|
||||
{
|
||||
protected $exportPath = 'database/seeders/data/';
|
||||
|
||||
public function index()
|
||||
{
|
||||
public function index(){
|
||||
//POSTGRESS
|
||||
$tables = DB::select("SELECT tablename FROM pg_tables WHERE schemaname = 'public'");
|
||||
$tableNames = array_map(fn($t) => $t->tablename, $tables);
|
||||
@@ -32,9 +30,7 @@ class JsonTransferController extends Controller
|
||||
}
|
||||
return view('backup', compact('tableInfo'));
|
||||
}
|
||||
|
||||
public function generate()
|
||||
{
|
||||
public function generate(){
|
||||
$exportPath = base_path($this->exportPath);
|
||||
if (!is_dir($exportPath)) {
|
||||
mkdir($exportPath, 0777, true);
|
||||
@@ -74,10 +70,7 @@ class JsonTransferController extends Controller
|
||||
|
||||
return redirect()->back()->with('success', 'Semua tabel berhasil diekspor tanpa kehabisan memori.');
|
||||
}
|
||||
|
||||
|
||||
public function downloadTable($table)
|
||||
{
|
||||
public function downloadTable($table){
|
||||
$file = base_path($this->exportPath . $table . '.json');
|
||||
|
||||
if (!file_exists($file)) {
|
||||
@@ -86,9 +79,7 @@ class JsonTransferController extends Controller
|
||||
|
||||
return response()->download($file);
|
||||
}
|
||||
|
||||
public function downloadAll()
|
||||
{
|
||||
public function downloadAll(){
|
||||
$zipFile = base_path('database/seeders/data/all_json.zip');
|
||||
$zip = new ZipArchive;
|
||||
|
||||
@@ -103,8 +94,7 @@ class JsonTransferController extends Controller
|
||||
|
||||
return response()->download($zipFile);
|
||||
}
|
||||
public function importTable($table)
|
||||
{
|
||||
public function importTable($table){
|
||||
$path = base_path($this->exportPath . $table . '.json');
|
||||
if (!file_exists($path)) {
|
||||
return redirect()->back()->with('error', "File JSON untuk tabel $table tidak ditemukan.");
|
||||
@@ -128,5 +118,21 @@ class JsonTransferController extends Controller
|
||||
return redirect()->back()->with('error', "Gagal import tabel $table: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function pull(Request $request){
|
||||
if (session('previlage') !== 'developer') {
|
||||
abort(403, 'Akses ditolak. Anda tidak memiliki izin untuk menjalankan git pull.');
|
||||
}
|
||||
$gitPath = '/var/www/html/lis/';
|
||||
|
||||
// Jalankan git pull
|
||||
$output = shell_exec("cd {$gitPath} && git pull 2>&1");
|
||||
|
||||
// Simpan log siapa yang menjalankan (opsional)
|
||||
if (auth()->check()) {
|
||||
Log::info('Git pull executed by user: ' . auth()->user()->email);
|
||||
}
|
||||
|
||||
return back()->with('git_output', $output);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LisController extends Controller
|
||||
{
|
||||
/**
|
||||
* Alamat IP dan port dari service Python/Flask.
|
||||
* Sebaiknya diletakkan di file .env
|
||||
* LIS_SERVICE_URL=http://127.0.0.1:5000
|
||||
*/
|
||||
protected $lisServiceUrl;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Mengambil URL service dari file .env, dengan fallback default
|
||||
$this->lisServiceUrl = env('LIS_SERVICE_URL', 'http://localhost:5000');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mengirim perintah untuk mendaftarkan tes pasien baru ke GeneXpert.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function registerPatient(Request $request)
|
||||
{
|
||||
// Validasi input dari request (sangat direkomendasikan)
|
||||
$validatedData = $request->validate([
|
||||
'patient_name' => 'required|string|max:100',
|
||||
'patient_id' => 'required|string|max:50',
|
||||
'sample_id' => 'required|string|max:50',
|
||||
'test_code' => 'required|string|max:20',
|
||||
'test_name' => 'sometimes|string|max:50',
|
||||
'dob' => 'sometimes|date_format:Ymd',
|
||||
'gender' => 'sometimes|string|in:M,F,O,U',
|
||||
]);
|
||||
|
||||
// Membangun payload sesuai format yang diharapkan oleh app.py
|
||||
$payload = [
|
||||
'command' => 'register_patient',
|
||||
'data' => $validatedData,
|
||||
];
|
||||
|
||||
try {
|
||||
// Mengirim request POST ke service Python
|
||||
$response = Http::timeout(30) // Set timeout 30 detik
|
||||
->post($this->lisServiceUrl . '/command', $payload);
|
||||
|
||||
// Cek jika request gagal di level HTTP
|
||||
if ($response->failed()) {
|
||||
Log::error('Gagal terhubung ke LIS service saat registrasi.', [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body()
|
||||
]);
|
||||
return response()->json([
|
||||
'error' => 'Tidak dapat terhubung ke LIS service.',
|
||||
'details' => $response->body()
|
||||
], 503); // Service Unavailable
|
||||
}
|
||||
|
||||
// Mengembalikan response dari service Python ke client
|
||||
return response()->json($response->json(), $response->status());
|
||||
|
||||
} catch (\Illuminate\Http\Client\ConnectionException $e) {
|
||||
Log::error('Koneksi ke LIS service gagal.', ['exception' => $e->getMessage()]);
|
||||
return response()->json(['error' => 'Koneksi ke LIS service gagal.'], 504); // Gateway Timeout
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mengirim perintah untuk meminta ulang hasil tes berdasarkan Sample ID.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function requestResult(Request $request)
|
||||
{
|
||||
// Validasi input
|
||||
$validatedData = $request->validate([
|
||||
'sample_id' => 'required|string|max:50',
|
||||
]);
|
||||
|
||||
// Membangun payload
|
||||
$payload = [
|
||||
'command' => 'request_result',
|
||||
'data' => $validatedData,
|
||||
];
|
||||
|
||||
try {
|
||||
// Mengirim request POST ke service Python
|
||||
$response = Http::timeout(30)->post($this->lisServiceUrl . '/command', $payload);
|
||||
|
||||
if ($response->failed()) {
|
||||
Log::error('Gagal terhubung ke LIS service saat meminta hasil.', [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body()
|
||||
]);
|
||||
return response()->json([
|
||||
'error' => 'Tidak dapat terhubung ke LIS service.',
|
||||
'details' => $response->body()
|
||||
], 503);
|
||||
}
|
||||
|
||||
return response()->json($response->json(), $response->status());
|
||||
|
||||
} catch (\Illuminate\Http\Client\ConnectionException $e) {
|
||||
Log::error('Koneksi ke LIS service gagal.', ['exception' => $e->getMessage()]);
|
||||
return response()->json(['error' => 'Koneksi ke LIS service gagal.'], 504);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user