update
This commit is contained in:
@@ -33,6 +33,7 @@ use App\SiraB;
|
||||
use App\Organisms;
|
||||
use App\RekapAntibiotik;
|
||||
use App\PendaftaranOnListiner;
|
||||
use App\CriticalValueSample;
|
||||
use Carbon\Carbon;
|
||||
use Aranyasen\HL7\Message;
|
||||
use Aranyasen\HL7\Connection;
|
||||
@@ -600,6 +601,9 @@ class DokterController extends Controller
|
||||
'status' => 'Selesai',
|
||||
];
|
||||
$periksa->update($updateData);
|
||||
if ($this->shouldMarkAsCritical($request)) {
|
||||
$this->upsertCriticalValueSample($periksa);
|
||||
}
|
||||
$surat = self::genSurat($periksa->id, 'dengan kop');
|
||||
Riwayat::create([
|
||||
'nofoto' => $nofoto,
|
||||
@@ -710,6 +714,76 @@ class DokterController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
protected function shouldMarkAsCritical(Request $request): bool
|
||||
{
|
||||
$flag = strtolower((string) $request->input('nilai_kritis', '0'));
|
||||
|
||||
return in_array($flag, ['1', 'true', 'on', 'yes'], true);
|
||||
}
|
||||
protected function upsertCriticalValueSample(Periksa $periksa): void
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$criticalSample = CriticalValueSample::firstOrNew(['periksa_id' => $periksa->id]);
|
||||
$criticalSample->nofoto = $periksa->nofoto;
|
||||
$criticalSample->noregister = $periksa->noregister;
|
||||
$criticalSample->nmpasien = $periksa->nmpasien;
|
||||
$criticalSample->nm_spesimen = $periksa->nm_spesimen;
|
||||
|
||||
// Keep the first critical timestamp intact on repeated clicks.
|
||||
if (empty($criticalSample->critical_set_at)) {
|
||||
$criticalSample->critical_set_at = $now;
|
||||
$criticalSample->critical_set_by_user_id = Session('id');
|
||||
$criticalSample->critical_set_by_name = Session('nama');
|
||||
}
|
||||
|
||||
$criticalSample->save();
|
||||
}
|
||||
protected function markCriticalValueAsRead(CriticalValueSample $criticalSample): void
|
||||
{
|
||||
if (!empty($criticalSample->followed_up_at)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$criticalSample->followed_up_at = Carbon::now();
|
||||
$criticalSample->followed_up_by_user_id = Session('id');
|
||||
$criticalSample->followed_up_by_name = Session('nama');
|
||||
$criticalSample->save();
|
||||
}
|
||||
public function criticalValueNotifications(Request $request)
|
||||
{
|
||||
$highlightId = $request->query('highlight');
|
||||
$items = CriticalValueSample::whereNull('followed_up_at')
|
||||
->orderBy('critical_set_at', 'asc')
|
||||
->get();
|
||||
$followedItems = CriticalValueSample::whereNotNull('followed_up_at')
|
||||
->orderBy('followed_up_at', 'desc')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
return view('notifications.critical-values', [
|
||||
'items' => $items,
|
||||
'followedItems' => $followedItems,
|
||||
'highlightId' => $highlightId,
|
||||
]);
|
||||
}
|
||||
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.');
|
||||
}
|
||||
public function criticalValueNotificationMarkRead($id)
|
||||
{
|
||||
$criticalSample = CriticalValueSample::findOrFail($id);
|
||||
$this->markCriticalValueAsRead($criticalSample);
|
||||
|
||||
return redirect()
|
||||
->route('criticalValueNotifications', ['highlight' => $criticalSample->id])
|
||||
->with('success', 'Sample nilai kritis sudah ditandai sudah ditindaklanjuti.');
|
||||
}
|
||||
public function cancelOrder(Request $request) {
|
||||
$val01 = $request->input('alasan');
|
||||
$getsetting = Setting::where('id', '1')->first();
|
||||
|
||||
Reference in New Issue
Block a user