This commit is contained in:
Dwi Swandhana
2026-03-06 06:52:40 +07:00
parent 5d6afc19af
commit ab438f0c55
2 changed files with 102 additions and 61 deletions
@@ -75,6 +75,57 @@ class FrontpageController extends Controller
$data['butuhverifikasi'] = $unveri;
$data['antrian'] = $hariini;
$data['persenantrian'] = $tulis;
$now = Carbon::now();
$rawEarlyWarnings = Periksa::leftJoin('poli', 'periksa.poli_id', '=', 'poli.id')
->select(
'periksa.id',
'periksa.nofoto',
'periksa.noregister',
'periksa.nmpasien',
'periksa.reques',
'periksa.asalpasien',
'periksa.daftar',
'periksa.status',
'poli.subpoli',
'poli.modaliti2'
)
->where(function($q) {
$q->whereNull('periksa.status')
->orWhere('periksa.status', '<>', 'Selesai');
})
->whereNotNull('periksa.daftar')
->orderBy('periksa.daftar', 'ASC')
->get();
$earlyWarnings = [];
foreach ($rawEarlyWarnings as $row) {
$targetDays = 1;
if (!empty($row->modaliti2) && is_numeric($row->modaliti2) && intval($row->modaliti2) > 0) {
$targetDays = intval($row->modaliti2);
}
$waktuDaftar = Carbon::parse($row->daftar);
$targetSelesai = $waktuDaftar->copy()->addDays($targetDays);
$sisaMenit = $now->diffInMinutes($targetSelesai, false);
if ($sisaMenit <= 60) {
$earlyWarnings[] = [
'id' => $row->id,
'nofoto' => $row->nofoto,
'noregister' => $row->noregister,
'nmpasien' => $row->nmpasien,
'reques' => $row->reques,
'asalpasien' => $row->asalpasien,
'status' => $row->status ?? '-',
'daftar' => $waktuDaftar->format('Y-m-d H:i:s'),
'target_hari' => $targetDays,
'target_selesai' => $targetSelesai->format('Y-m-d H:i:s'),
'sisa_menit' => $sisaMenit,
'warning_label' => $sisaMenit <= 0 ? 'Melewati Target' : 'Kurang dari 1 Jam'
];
}
}
$data['earlyWarnings'] = $earlyWarnings;
return view('dokter.dashborad', $data);
} else {
try {
@@ -111,9 +111,52 @@
</div><!-- end col -->
</div>
<div class="card-box">
<h4 class="header-title mb-3">Kalender</h4>
<h4 class="header-title mb-3">Early Warning Sistem</h4>
<div class="table-responsive">
<div id="gridjadwal"></div>
<table class="table table-bordered table-striped table-sm">
<thead>
<tr>
<th>No</th>
<th>No.Sample</th>
<th>No.RM</th>
<th>Nama</th>
<th>Order</th>
<th>Asal Pasien</th>
<th>Status</th>
<th>Daftar</th>
<th>Target (Hari)</th>
<th>Estimasi Selesai</th>
<th>Warning</th>
</tr>
</thead>
<tbody>
@forelse($earlyWarnings as $i => $row)
<tr>
<td>{{ $i + 1 }}</td>
<td>{{ $row['nofoto'] }}</td>
<td>{{ $row['noregister'] }}</td>
<td>{{ $row['nmpasien'] }}</td>
<td>{{ $row['reques'] }}</td>
<td>{{ $row['asalpasien'] }}</td>
<td>{{ $row['status'] }}</td>
<td>{{ $row['daftar'] }}</td>
<td>{{ $row['target_hari'] }}</td>
<td>{{ $row['target_selesai'] }}</td>
<td>
@if($row['sisa_menit'] <= 0)
<span class="badge badge-danger">{{ $row['warning_label'] }}</span>
@else
<span class="badge badge-warning">{{ $row['warning_label'] }} ({{ $row['sisa_menit'] }} menit)</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="11" class="text-center">Tidak ada data Early Warning.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
@@ -275,8 +318,8 @@ $(document).ready(function() {
$(".btnubahfoto").click(function() {
$('#modalupdatefoto').modal('show');
});
$("#btnsimpanfoto").click(function(){
var filegambar = document.getElementById('upload_file');
$("#btnsimpanfoto").click(function(){
var filegambar = document.getElementById('upload_file');
$('#modalupdatefoto').modal('hide');
var form_data = new FormData();
form_data.append('file', filegambar.files[0]);
@@ -316,62 +359,9 @@ $(document).ready(function() {
text: error,
type: 'warning',
})
}
});
});
var sourcekalender = {
datatype: "json",
datafields: [
{ name: 'id', type: 'string' },
{ name: 'description', type: 'string' },
{ name: 'location', type: 'string' },
{ name: 'subject', type: 'string' },
{ name: 'calendar', type: 'string' },
{ name: 'start', type: 'date' },
{ name: 'end', type: 'date' }
],
id : 'id',
url : '{{ route("getkalenderlist") }}'
};
var datajsonawal = new $.jqx.dataAdapter(sourcekalender);
$("#gridjadwal").jqxScheduler({
date : new $.jqx.date(),
width : '95%',
height : 600,
source : datajsonawal,
showLegend : true,
theme : 'energyblue',
view : 'agendaView',
ready: function () {
$("#gridjadwal").jqxScheduler('ensureAppointmentVisible', 'id1');
},
resources:
{
colorScheme : "scheme05",
dataField : "calendar",
source : new $.jqx.dataAdapter(sourcekalender)
},
appointmentDataFields:
{
from : "start",
to : "end",
id : "id",
description : "description",
location : "place",
subject : "subject",
readOnly : "readOnly",
resourceId : "calendar",
},
views :
[
'dayView',
'weekView',
'monthView',
'agendaView'
],
});
}
});
});
});
</script>
@endpush
@endpush