update
This commit is contained in:
@@ -53,6 +53,8 @@ use Session;
|
||||
use QrCode;
|
||||
use Exception;
|
||||
use PDFCREATOR;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
define( 'API_ACCESS_KEY', 'AAAA6YBXh1k:APA91bFL0q7QAXQGohXMpTwHco79f13C8PFk1Oo8kKhg1JerOulT9-37dxyP8X5ibABI0NuQ4ZsVxKQKCt7HuR7lUdJJuB-hTVnBmOUIBYfBlHb-Lcp6aGkj4erfF7J__A5hufXjF8Vt' );
|
||||
|
||||
@@ -717,6 +719,11 @@ class DokterController extends Controller
|
||||
protected function shouldMarkAsCritical(Request $request): bool
|
||||
{
|
||||
$flag = strtolower((string) $request->input('nilai_kritis', '0'));
|
||||
$master = (string) $request->input('master_mikro', '');
|
||||
|
||||
if ($master !== 'buku03') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($flag, ['1', 'true', 'on', 'yes'], true);
|
||||
}
|
||||
@@ -750,16 +757,24 @@ class DokterController extends Controller
|
||||
$criticalSample->followed_up_by_name = Session('nama');
|
||||
$criticalSample->save();
|
||||
}
|
||||
public function criticalValueNotifications(Request $request)
|
||||
protected function getPendingCriticalValueItems()
|
||||
{
|
||||
$highlightId = $request->query('highlight');
|
||||
$items = CriticalValueSample::whereNull('followed_up_at')
|
||||
return CriticalValueSample::whereNull('followed_up_at')
|
||||
->orderBy('critical_set_at', 'asc')
|
||||
->get();
|
||||
$followedItems = CriticalValueSample::whereNotNull('followed_up_at')
|
||||
}
|
||||
protected function getFollowedCriticalValueItems()
|
||||
{
|
||||
return CriticalValueSample::whereNotNull('followed_up_at')
|
||||
->orderBy('followed_up_at', 'desc')
|
||||
->limit(100)
|
||||
->get();
|
||||
}
|
||||
public function criticalValueNotifications(Request $request)
|
||||
{
|
||||
$highlightId = $request->query('highlight');
|
||||
$items = $this->getPendingCriticalValueItems();
|
||||
$followedItems = $this->getFollowedCriticalValueItems();
|
||||
|
||||
return view('notifications.critical-values', [
|
||||
'items' => $items,
|
||||
@@ -767,6 +782,80 @@ class DokterController extends Controller
|
||||
'highlightId' => $highlightId,
|
||||
]);
|
||||
}
|
||||
public function criticalValueNotificationExport(Request $request)
|
||||
{
|
||||
$type = $request->query('type', 'pending');
|
||||
$isFollowed = $type === 'followed';
|
||||
$rows = $isFollowed ? $this->getFollowedCriticalValueItems() : $this->getPendingCriticalValueItems();
|
||||
$filename = $isFollowed
|
||||
? 'notifikasi-nilai-kritis-riwayat-'.Carbon::now()->format('Ymd_His').'.xlsx'
|
||||
: 'notifikasi-nilai-kritis-belum-dilaporkan-'.Carbon::now()->format('Ymd_His').'.xlsx';
|
||||
|
||||
return response()->streamDownload(function () use ($rows, $isFollowed) {
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setTitle($isFollowed ? 'Riwayat Nilai Kritis' : 'Nilai Kritis');
|
||||
|
||||
$headers = [
|
||||
'No',
|
||||
'No Foto',
|
||||
'No Register',
|
||||
'Pasien',
|
||||
'Asal Pasien',
|
||||
'Spesimen',
|
||||
'Waktu Set Nilai Kritis',
|
||||
'Diset Oleh',
|
||||
'Waktu Ditindaklanjuti',
|
||||
'Ditindaklanjuti Oleh',
|
||||
'Status Tindak Lanjut',
|
||||
'Metode',
|
||||
'Penerima Laporan',
|
||||
'Alasan',
|
||||
];
|
||||
$sheet->fromArray($headers, null, 'A1');
|
||||
|
||||
$rowNumber = 2;
|
||||
foreach ($rows as $index => $item) {
|
||||
$status = $item->follow_up_status ?? '';
|
||||
if ($status === 'reported') {
|
||||
$statusLabel = 'Dilaporkan';
|
||||
} elseif ($status === 'not_reported') {
|
||||
$statusLabel = 'Belum Dilaporkan';
|
||||
} else {
|
||||
$statusLabel = '-';
|
||||
}
|
||||
|
||||
$sheet->fromArray([
|
||||
$index + 1,
|
||||
$item->nofoto ?? '-',
|
||||
$item->noregister ?? '-',
|
||||
$item->nmpasien ?? '-',
|
||||
$item->asalpasien ?? '-',
|
||||
$item->nm_spesimen ?? '-',
|
||||
$item->critical_set_at ? Carbon::parse($item->critical_set_at)->format('d-m-Y H:i:s') : '-',
|
||||
$item->critical_set_by_name ?? '-',
|
||||
$item->followed_up_at ? Carbon::parse($item->followed_up_at)->format('d-m-Y H:i:s') : '-',
|
||||
$item->followed_up_by_name ?? '-',
|
||||
$statusLabel,
|
||||
$item->follow_up_method ?? '-',
|
||||
$item->follow_up_recipient ?? '-',
|
||||
$item->follow_up_reason ?? '-',
|
||||
], null, 'A'.$rowNumber);
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
foreach (range('A', 'N') as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save('php://output');
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
unset($spreadsheet);
|
||||
}, $filename, [
|
||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
]);
|
||||
}
|
||||
public function criticalValueNotificationSummary()
|
||||
{
|
||||
if (Session::get('id') === null) {
|
||||
|
||||
Reference in New Issue
Block a user