This commit is contained in:
Dwi Swandhana
2026-03-10 13:53:06 +07:00
parent 2e0461b528
commit 5aed126889
8 changed files with 217 additions and 33 deletions
@@ -726,6 +726,7 @@ class DokterController extends Controller
$criticalSample = CriticalValueSample::firstOrNew(['periksa_id' => $periksa->id]);
$criticalSample->nofoto = $periksa->nofoto;
$criticalSample->noregister = $periksa->noregister;
$criticalSample->asalpasien = $periksa->asalpasien;
$criticalSample->nmpasien = $periksa->nmpasien;
$criticalSample->nm_spesimen = $periksa->nm_spesimen;
@@ -766,19 +767,74 @@ class DokterController extends Controller
'highlightId' => $highlightId,
]);
}
public function criticalValueNotificationSummary()
{
if (Session::get('id') === null) {
return response()->json([
'count' => 0,
'menu_html' => view('notifications.partials.critical-bell', [
'count' => 0,
'items' => collect(),
])->render(),
]);
}
$count = CriticalValueSample::whereNull('followed_up_at')->count();
$items = CriticalValueSample::whereNull('followed_up_at')
->orderBy('critical_set_at', 'asc')
->limit(8)
->get();
return response()->json([
'count' => (int) $count,
'menu_html' => view('notifications.partials.critical-bell', [
'count' => (int) $count,
'items' => $items,
])->render(),
]);
}
public function criticalValueNotificationOpen($id)
{
$criticalSample = CriticalValueSample::findOrFail($id);
$this->markCriticalValueAsRead($criticalSample);
return redirect()
->route('criticalValueNotifications', ['highlight' => $criticalSample->id])
->with('success', 'Sample nilai kritis sudah ditandai sudah ditindaklanjuti.');
->route('criticalValueNotifications', ['highlight' => $id]);
}
public function criticalValueNotificationMarkRead($id)
{
$criticalSample = CriticalValueSample::findOrFail($id);
$this->markCriticalValueAsRead($criticalSample);
if (!empty($criticalSample->followed_up_at)) {
return redirect()
->route('criticalValueNotifications', ['highlight' => $criticalSample->id])
->with('success', 'Sample nilai kritis ini sudah ditindaklanjuti sebelumnya.');
}
$followUpMethod = trim((string) request('caratindaklanjut', ''));
$followUpRecipient = trim((string) request('penerima_laporan', ''));
$followUpReason = trim((string) request('alasan_belum_laporkan', ''));
// If method is empty -> not reported, reason is required.
// If method is filled -> reported, recipient is required.
if ($followUpMethod === '') {
if ($followUpReason === '') {
return back()->with('error', 'Alasan belum dilaporkan wajib diisi jika belum dilaporkan.');
}
} else {
$allowed = ['Telpon', 'Whatshap', 'Email', 'Ketemu di Jalan'];
if (!in_array($followUpMethod, $allowed, true)) {
return back()->with('error', 'Cara tindak lanjut tidak valid.');
}
if ($followUpRecipient === '') {
return back()->with('error', 'Penerima laporan wajib diisi jika sudah dilaporkan.');
}
}
$criticalSample->followed_up_at = Carbon::now();
$criticalSample->followed_up_by_user_id = Session('id');
$criticalSample->followed_up_by_name = Session('nama');
$criticalSample->follow_up_status = $followUpMethod === '' ? 'not_reported' : 'reported';
$criticalSample->follow_up_method = $followUpMethod !== '' ? $followUpMethod : null;
$criticalSample->follow_up_recipient = $followUpRecipient !== '' ? $followUpRecipient : null;
$criticalSample->follow_up_reason = $followUpReason !== '' ? $followUpReason : null;
$criticalSample->save();
return redirect()
->route('criticalValueNotifications', ['highlight' => $criticalSample->id])
@@ -28,7 +28,6 @@ class ListController extends Controller
} else {
return redirect('/pendaftaran');
}
}
public function getList(Request $request) {
$jenis = $request->input('jenis');
@@ -737,7 +736,13 @@ class ListController extends Controller
</button>
</div>';
})
->rawColumns(['aksi', 'tlsstatus', 'tlsnofoto', 'tlsnoregister', 'tlsnama', 'tlsreques'])
->addColumn('batalaksi', function ($row) {
return '
<button type="button" class="btn btn-sm btn-danger waves-effect" onClick="btnBatal('.$row->id.')">
<i class="me-50 fa fa-ban"></i> Kembalikan ke Loket
</button>';
})
->rawColumns(['aksi', 'tlsstatus', 'tlsnofoto', 'tlsnoregister', 'tlsnama', 'tlsreques', 'batalaksi'])
->make(true);
}