@extends('layouts.app') @section('title', 'Worklist Spirometry - MCU Klinik Mustika') @section('breadcrumb')

Worklist Spirometry

@endsection @section('content')
Worklist Spirometry
Daftar ini menampilkan pasien yang telah diarahkan ke workstation spirometry dari dashboard utama. Jika tidak ada pasien yang muncul, pastikan pasien sudah diarahkan melalui tombol "Assign Workstation".
@if ($pendingAppointments->total() == 0)
Tidak Ada Pasien di Workstation Spirometri
@if ($inputOnly) Tidak ada antrean pemeriksaan pada tanggal ini. Pasien yang sudah dikirim untuk verifikasi tidak ditampilkan dalam antrean petugas. @else Tidak ada antrean pada tanggal ini. Pastikan pasien telah diarahkan ke workstation yang sesuai. @endif
@endif

Antrian Menunggu

{{ $workstationData['stats']['waiting'] }}

Sampel Terkumpul

{{ $workstationData['stats']['sample_collected'] }}

Sedang Diproses

{{ $workstationData['stats']['in_progress'] }}

@if (!$inputOnly)

Menunggu Verifikasi

{{ $workstationData['stats']['pending_verification'] }}

Selesai

{{ $workstationData['stats']['completed'] }}

@endif

{{ $inputOnly ? 'Total antrean' : 'Total Aktif' }}

{{ $workstationData['stats']['total_active'] }}

Pasien yang Diarahkan ke Spirometry
{{ $pendingAppointments->total() }} Pasien {{ \App\Helpers\DateHelper::formatDate(now()) }}
@include('partials.tables.filters', ['paginator' => $pendingAppointments, 'tableFilters' => ['date', 'status', 'sort', 'direction']]) @forelse ($pendingAppointments as $appointment) @php // Double-check: only show appointments with assigned spirometry items $hasAssignedSpirometryItems = $appointment->appointmentMcuItems ->filter(function ($item) { return $item->mcuItem && $item->mcuItem->department === 'spirometry' && in_array($item->status, [ 'menunggu', 'antrian', 'sedang_diproses', 'menunggu_verifikasi', 'sample_collected', 'selesai', ]) && $item->assigned_at !== null; }) ->count() > 0; // Include cases where verification was cancelled or result was rejected so it reappears in worklist $spirometryResultStatusCheck = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); $hasCancelledOrRejected = $spirometryResultStatusCheck && ($spirometryResultStatusCheck->cancelled_at || $spirometryResultStatusCheck->status === 'rejected'); $shouldShow = $hasAssignedSpirometryItems || $hasCancelledOrRejected; @endphp @if ($shouldShow) @endif @empty @endforelse
No. No. Registrasi & MR @include('partials.tables.sort_link', ['column' => 'name', 'label' => 'Nama Pasien']) @include('partials.tables.sort_link', ['column' => 'gender', 'label' => 'Jenis Kelamin']) Umur @include('partials.tables.sort_link', ['column' => 'appointment_date', 'label' => 'Tanggal MCU']) Status Petugas Spirometri Waktu Diarahkan MCU Ke Aksi
{{ $pendingAppointments->firstItem() + $loop->index }}
{{ $appointment->registration_number ?? '-' }} {{ $appointment->patient->medical_record_number ?? '-' }}
{{ $appointment->patient->name }}
@php $companyFromPatient = $appointment->patient && $appointment->patient->company ? $appointment->patient->company : null; $company = $companyFromPatient ?: $appointment->company ?? null; @endphp
@if ($company) {{ $company->name }} @if ($appointment->patient->job_position) {{ $appointment->patient->job_position }} @endif @else Individu @endif
{{ $appointment->patient->gender == 'male' ? 'Laki-laki' : 'Perempuan' }} {{ $appointment->patient->detailed_age ?: '-' }} {{ $appointment->appointment_date ? $appointment->appointment_date->format('d/m/Y') : '-' }} @php $spirometryItems = $appointment->appointmentMcuItems->filter(function ($item) { return $item->mcuItem && $item->mcuItem->department === 'spirometry' && in_array($item->status, [ 'menunggu', 'antrian', 'sedang_diproses', 'menunggu_verifikasi', 'sample_collected', 'selesai', ]) && $item->assigned_at !== null; // Only show assigned items }); $hasAssignedItems = $spirometryItems ->whereIn('status', ['antrian', 'sedang_diproses', 'menunggu_verifikasi', 'sample_collected', 'selesai']) ->count() > 0; $hasWaitingItems = $spirometryItems->where('status', 'menunggu')->count() > 0; $spirometryItem = $spirometryItems ->whereIn('status', ['antrian', 'sedang_diproses', 'menunggu_verifikasi', 'sample_collected', 'selesai']) ->first() ?: $spirometryItems->where('status', 'menunggu')->first(); @endphp @if ($spirometryItem) @if ($spirometryItem->status === 'menunggu') Menunggu Pemeriksaan @elseif ($spirometryItem->status === 'antrian') Siap Diperiksa @elseif ($spirometryItem->status === 'sedang_diproses') @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult && $spirometryResult->status === 'rejected') Ditolak - Perlu Perbaikan @elseif ($spirometryResult && $spirometryResult->cancelled_at) Verifikasi Dibatalkan @else Sedang Diproses @endif @elseif ($spirometryItem->status === 'menunggu_verifikasi') @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult && $spirometryResult->status === 'rejected') Ditolak - Perlu Perbaikan @elseif ($spirometryResult && $spirometryResult->cancelled_at) Verifikasi Dibatalkan @else Menunggu Verifikasi @endif @elseif ($spirometryItem->status === 'sample_collected') Perlu Diperbaiki @elseif ($spirometryItem->status === 'selesai') Selesai @endif @elseif (!$spirometryItem && $hasCancelledOrRejected) @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult && $spirometryResult->status === 'rejected') Ditolak - Perlu Perbaikan @elseif ($spirometryResult && $spirometryResult->cancelled_at) Verifikasi Dibatalkan @endif @endif {{ $appointment->spirometryResult ? $appointment->spirometryResult->technicianDisplayName($defaultTechnician) ?? '-' : '-' }} @php $assignedTime = $spirometryItem && $spirometryItem->assigned_at ? $spirometryItem->assigned_at->format('d/m/Y H:i') : ''; $assignedBy = $spirometryItem && $spirometryItem->assignedBy ? $spirometryItem->assignedBy->name : ''; @endphp @if ($assignedTime)
{{ $assignedTime }}
@if ($assignedBy) oleh: {{ $assignedBy }} @endif @else - @endif
@php $mcuOrder = $appointment->patient->appointments ->filter(function ($apt) use ($appointment) { return $apt->status !== 'cancelled' && ($apt->appointment_date < $appointment->appointment_date || ($apt->appointment_date->eq($appointment->appointment_date) && $apt->id <= $appointment->id)); }) ->count(); $previousMcu = $appointment->patient->appointments ->filter(function ($apt) use ($appointment) { return $apt->status !== 'cancelled' && ($apt->appointment_date < $appointment->appointment_date || ($apt->appointment_date->eq($appointment->appointment_date) && $apt->id < $appointment->id)); }) ->sortByDesc('appointment_date') ->first(); @endphp
MCU ke-{{ $mcuOrder }} @if ($previousMcu) MCU Terakhir: {{ \App\Helpers\DateHelper::formatFull($previousMcu->appointment_date) }} @else Pertama kali @endif
@if ($spirometryItem && in_array($spirometryItem->status, ['menunggu', 'antrian']))
@canRoute ('spirometry.process') Proses @endcanRoute
@elseif ($spirometryItem && $spirometryItem->status === 'sedang_diproses') @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult && $spirometryResult->status === 'rejected')
@canRoute ('spirometry.process') @endcanRoute Ditolak - Perlu Perbaikan
@elseif ($spirometryResult && $spirometryResult->cancelled_at)
@canRoute ('spirometry.edit') @endcanRoute Verifikasi Dibatalkan
@else
@canRoute ('spirometry.process') Lanjutkan @endcanRoute
@endif @elseif ($spirometryItem && $spirometryItem->status === 'sample_collected') @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult)
@canRoute ('spirometry.edit') @endcanRoute
@else
@canRoute ('spirometry.process') Proses @endcanRoute
@endif @elseif ($spirometryItem && $spirometryItem->status === 'menunggu_verifikasi') @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult)
@canRoute ('spirometry.edit') @endcanRoute @if ($spirometryResult->status === 'rejected') Ditolak - Perlu Perbaikan @elseif ($spirometryResult->cancelled_at) Verifikasi Dibatalkan @else Menunggu Verifikasi @endif
@else Menunggu Verifikasi @endif @elseif ($spirometryItem && $spirometryItem->status === 'selesai')
@elseif (!$spirometryItem && $hasCancelledOrRejected) @php $spirometryResult = \App\Models\SpirometryResult::where('appointment_id', $appointment->id)->first(); @endphp @if ($spirometryResult)
@canRoute ('spirometry.edit') @endcanRoute @if ($spirometryResult->status === 'rejected') Ditolak - Perlu Perbaikan @elseif ($spirometryResult->cancelled_at) Verifikasi Dibatalkan @endif
@endif @else @canRoute ('appointments.assign-workstation') @endcanRoute @endif
Tidak ada data yang cocok dengan pencarian.
{{ $pendingAppointments->links( 'partials.tables.pagination', ) }}
@push('styles') @endpush @push('scripts') @endpush @endsection