@extends(request()->query('fragment') === 'verification' ? 'layouts.fragment' : 'layouts.app') @section('title', 'Verifikasi Terpusat - MCU Klinik Mustika') @section('breadcrumb')

Verifikasi Terpusat

@endsection @section('content')
Verifikasi Terpusat Semua Workstation
Halaman ini menampilkan semua hasil pemeriksaan dari berbagai workstation yang menunggu verifikasi dokter penanggung jawab.
@if ($appointments->total() == 0)
Tidak Ada Pasien yang Menunggu Verifikasi
Saat ini tidak ada pasien yang memiliki hasil pemeriksaan menunggu verifikasi untuk tanggal yang dipilih.
@endif
@if ($canSummarize) @endif @if (in_array('lab', $availableWorkstations, true))
Laboratorium

{{ $stats['lab'] }}

@endif @if (in_array('radiology', $availableWorkstations, true))
Radiologi

{{ $stats['radiology'] }}

@endif @if (in_array('physical_exam', $availableWorkstations, true))
Pemeriksaan Fisik

{{ $stats['physical_exam'] }}

@endif @if (in_array('spirometry', $availableWorkstations, true))
Spirometri

{{ $stats['spirometry'] }}

@endif @if (in_array('audiometry', $availableWorkstations, true))
Audiometri

{{ $stats['audiometry'] }}

@endif @if (in_array('visus', $availableWorkstations, true))
Pemeriksaan Mata

{{ $stats['visus'] }}

@endif @if (in_array('ekg', $availableWorkstations, true))
EKG

{{ $stats['ekg'] }}

@endif @if (in_array('dass21', $availableWorkstations, true))
DASS21

{{ $stats['dass21'] }}

@endif
Hasil Pemeriksaan Menunggu Verifikasi
{{ $appointments->total() }} Pasien {{ \App\Helpers\DateHelper::formatDate(now()) }}
@include('partials.tables.filters', ['paginator' => $appointments, 'tableFilters' => ['date', 'sort', 'direction']]) @forelse ($appointments as $appointment) @php $allStages = [ 'registration' => [ 'name' => 'Pendaftaran', 'icon' => 'ri-user-add-line', 'result' => $appointment, 'short' => 'REG', 'type' => 'registration', ], 'physical_exam' => [ 'name' => 'Pemeriksaan Fisik', 'icon' => 'ri-heart-pulse-line', 'result' => $appointment->physicalExamResult, 'short' => 'PE', 'type' => 'workstation', ], 'lab' => [ 'name' => 'Laboratorium', 'icon' => 'ri-test-tube-line', 'result' => $appointment->labResult, 'short' => 'LAB', 'type' => 'workstation', ], 'radiology' => [ 'name' => 'Radiologi', 'icon' => 'ri-scan-line', 'result' => $appointment->radiologyResult, 'short' => 'RAD', 'type' => 'workstation', ], 'spirometry' => [ 'name' => 'Spirometry', 'icon' => 'ri-lungs-line', 'result' => $appointment->spirometryResult, 'short' => 'SPR', 'type' => 'workstation', ], 'audiometry' => [ 'name' => 'Audiometry', 'icon' => 'ri-headphone-line', 'result' => $appointment->audiometryResult, 'short' => 'AUD', 'type' => 'workstation', ], 'visus' => [ 'name' => 'Visus', 'icon' => 'ri-eye-line', 'result' => $appointment->visusResult, 'short' => 'VIS', 'type' => 'workstation', ], 'ekg' => [ 'name' => 'EKG', 'icon' => 'ri-pulse-line', 'result' => $appointment->ekgResult, 'short' => 'EKG', 'type' => 'workstation', ], 'dass21' => [ 'name' => 'DASS21', 'icon' => 'ri-brain-line', 'result' => $appointment->dass21Result, 'short' => 'DASS', 'type' => 'workstation', ], 'finalization' => [ 'name' => 'Finalisasi Dokter', 'icon' => 'ri-file-check-line', 'result' => $appointment->mcuResult, 'short' => 'FIN', 'type' => 'finalization', ], ]; $allStages = array_filter( $allStages, fn($stage, $key) => $stage['type'] === 'workstation' ? in_array($key, $availableWorkstations, true) : $canSummarize, ARRAY_FILTER_USE_BOTH, ); $workstationStages = array_filter( $allStages, function ($stage, $key) use ($appointment) { if ($stage['type'] !== 'workstation') { return false; } // Skip DASS21 if company doesn't use it if (isset($stage['short']) && $stage['short'] === 'DASS' && !$appointment->shouldHaveDass21()) { return false; } return true; }, ARRAY_FILTER_USE_BOTH, ); $completedStations = 0; $totalStations = count($workstationStages); $pendingVerification = 0; // Check registration completion first $isRegistrationComplete = true; $patient = $appointment->patient; // For quick registration patients, check registration_status first if ($appointment->is_quick_registration && $appointment->registration_status === 'temporary') { $isRegistrationComplete = false; } // Check basic required data if (!$patient->name || !$patient->gender || !$patient->birth_date || !$patient->phone_number) { $isRegistrationComplete = false; } // Check photo if (!$patient->photo) { $isRegistrationComplete = false; } // Check company data if patient has company if ($patient->company_id && !$patient->job_position) { $isRegistrationComplete = false; } // Check additional health data (these are filled once and reused) $hasHealthData = $patient->healthQuestionnaires()->exists(); $hasWorkData = $patient->workActivities()->exists(); $hasFamilyData = $patient->familyHealthHistories()->exists(); $hasLifestyleData = $patient->lifestyleData()->exists(); if (!$hasHealthData || !$hasWorkData || !$hasFamilyData || !$hasLifestyleData) { $isRegistrationComplete = false; } // Check signature if (!$patient->signature_path) { $isRegistrationComplete = false; } // Check vital signs for this specific appointment $hasVitalSigns = false; if ($appointment->physicalExamResult) { $vitalSigns = $appointment->physicalExamResult; if ( $vitalSigns->blood_pressure_systolic || $vitalSigns->blood_pressure_diastolic || $vitalSigns->heart_rate || $vitalSigns->respiratory_rate || $vitalSigns->body_temperature || $vitalSigns->height || $vitalSigns->weight || $vitalSigns->waist_circumference ) { $hasVitalSigns = true; } } if (!$hasVitalSigns) { $isRegistrationComplete = false; } // Check if registration is verified $isRegistrationVerified = false; if ($appointment->mcuResult && in_array($appointment->mcuResult->status ?? '', ['verified', 'finalized'])) { $isRegistrationVerified = true; } // Count completed stations foreach ($workstationStages as $stage) { if ($stage['result']) { $status = $stage['result']->status ?? ''; if (in_array($status, ['verified', 'finalized', 'completed'])) { $completedStations++; } // Check if status is 'completed' but has been verified before (for cancelled MCU cases) if ($status === 'completed') { // Check if MCU was cancelled (indicated by mcuResult having cancellation_reason) $isMcuCancelled = $appointment->mcuResult && $appointment->mcuResult->cancellation_reason; // If it has verified_at or MCU was cancelled, don't count as pending verification if ($stage['result']->verified_at || $isMcuCancelled) { // Don't count as pending verification since it was already verified or MCU was cancelled // Debug: Log which workstation has verified_at or MCU was cancelled if ($stage['result']->verified_at) { \Log::info("Workstation {$stage['name']} has verified_at: " . $stage['result']->verified_at); } else { \Log::info("Workstation {$stage['name']} - MCU was cancelled, not counting as pending"); } } else { $pendingVerification++; // Debug: Log which workstation doesn't have verified_at and MCU not cancelled \Log::info( "Workstation {$stage['name']} doesn't have verified_at and MCU not cancelled, counting as pending", ); } } } } $overallPercent = $totalStations > 0 ? ($completedStations / $totalStations) * 100 : 0; @endphp @empty @endforelse
No. No. Registrasi & MR Nama Pasien Jenis Kelamin Umur Tanggal MCU MCU Ke @if ($canSummarize) Progress Pemeriksaan @else Status Verifikasi @endif Aksi
{{ $appointments->firstItem() + $loop->index }}
{{ $appointment->registration_number ?? '-' }} {{ $appointment->patient->medical_record_number ?? '-' }}
{{ $appointment->patient->name }}
@php $companyRel = $appointment->company ?? ($appointment->patient?->company ?? $appointment->mcuResult?->company); $companyName = $companyRel->name ?? null; $jobTitle = $appointment->patient->job_position ?? ($appointment->patient->occupation ?? $appointment->getJobPosition()); @endphp @if ($companyName)
{{ $companyName }} @if ($jobTitle) {{ $jobTitle }} @endif
@else Individu @endif
{{ $appointment->patient->gender == 'male' ? 'Laki-laki' : 'Perempuan' }} {{ $appointment->patient->detailed_age ?: '-' }}
{{ \App\Helpers\DateHelper::formatFull( $appointment->appointment_date, ) }} {{ $appointment->appointment_time ?? '08:00' }}
@php // Hitung urutan MCU berdasarkan kronologis (tanggal + ID untuk handle tanggal sama) $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
Progress: {{ $completedStations }}/{{ $totalStations }}
@foreach ($allStages as $stageName => $stageData) @php // Skip DASS21 if company doesn't use it if ($stageName === 'dass21' && !$appointment->shouldHaveDass21()) { continue; } $statusClass = 'bg-secondary'; $tooltip = 'Menunggu'; if ($stageData['type'] === 'registration') { // Use the same logic as in AppointmentController for consistency $isDataComplete = true; $patient = $appointment->patient; // For quick registration patients, check registration_status first if ($appointment->is_quick_registration && $appointment->registration_status === 'temporary') { $isDataComplete = false; } // Check basic required data if (!$patient->name || !$patient->gender || !$patient->birth_date || !$patient->phone_number) { $isDataComplete = false; } // Check photo if (!$patient->photo) { $isDataComplete = false; } // Check company data if patient has company if ($patient->company_id && !$patient->job_position) { $isDataComplete = false; } // Check additional health data (these are filled once and reused) $hasHealthData = $patient->healthQuestionnaires()->exists(); $hasWorkData = $patient->workActivities()->exists(); $hasFamilyData = $patient->familyHealthHistories()->exists(); $hasLifestyleData = $patient->lifestyleData()->exists(); if (!$hasHealthData || !$hasWorkData || !$hasFamilyData || !$hasLifestyleData) { $isDataComplete = false; } // Check signature if (!$patient->signature_path) { $isDataComplete = false; } // Check vital signs for this specific appointment $hasVitalSigns = false; if ($appointment->physicalExamResult) { $vitalSigns = $appointment->physicalExamResult; if ( $vitalSigns->blood_pressure_systolic || $vitalSigns->blood_pressure_diastolic || $vitalSigns->heart_rate || $vitalSigns->respiratory_rate || $vitalSigns->body_temperature || $vitalSigns->height || $vitalSigns->weight || $vitalSigns->waist_circumference ) { $hasVitalSigns = true; } } if (!$hasVitalSigns) { $isDataComplete = false; } if ($isDataComplete) { // Check if registration has been verified $isVerified = false; if ($appointment->mcuResult && in_array($appointment->mcuResult->status ?? '', ['verified', 'finalized'])) { $isVerified = true; } if ($isVerified) { $statusClass = 'bg-success'; $tooltip = 'Selesai & Diverifikasi'; } else { $statusClass = 'bg-success'; $tooltip = 'Selesai - Menunggu Verifikasi'; } } else { $statusClass = 'bg-warning'; $tooltip = 'Menunggu Data Tambahan'; } } elseif ($stageData['type'] === 'finalization') { if ($stageData['result'] && in_array($stageData['result']->status ?? '', ['finalized'])) { $statusClass = 'bg-success'; $tooltip = 'Selesai'; } elseif ($appointment->status === 'completed') { $statusClass = 'bg-info'; $tooltip = 'Menunggu Finalisasi'; } } else { // For workstation stages, check if they have actual workstation results if ($stageData['result']) { $status = $stageData['result']->status ?? ''; if (in_array($status, ['verified', 'finalized'])) { $statusClass = 'bg-success'; $tooltip = $stageData['name'] . ' - Selesai & Diverifikasi'; } elseif ($status === 'completed') { // Check if it has been verified before (for cancelled MCU cases) // Also check if MCU was cancelled (indicated by mcuResult having cancellation_reason) $isMcuCancelled = $appointment->mcuResult && $appointment->mcuResult->cancellation_reason; if ($stageData['result']->verified_at || $isMcuCancelled) { $statusClass = 'bg-success'; if ($stageData['result']->verified_at) { $tooltip = $stageData['name'] . ' - Selesai & Diverifikasi (verified_at: ' . \App\Helpers\DateHelper::formatShort($stageData['result']->verified_at) . ' ' . $stageData['result']->verified_at->format('H:i') . ')'; } else { $tooltip = $stageData['name'] . ' - Selesai & Diverifikasi (MCU dibatalkan, siap untuk verifikasi ulang)'; } } else { $statusClass = 'bg-warning'; $tooltip = $stageData['name'] . ' - Menunggu Verifikasi'; } } elseif (in_array($status, ['pending_verification'])) { $statusClass = 'bg-info'; $tooltip = $stageData['name'] . ' - Menunggu Verifikasi'; } elseif ($status === 'draft') { $statusClass = 'bg-secondary'; $tooltip = $stageData['name'] . ' - Data Tersimpan (Belum Pemeriksaan)'; } elseif ($status === 'in_progress') { $statusClass = 'bg-warning'; $tooltip = $stageData['name'] . ' - Sedang Diproses'; } else { $statusClass = 'bg-secondary'; $tooltip = $stageData['name'] . ' - Belum Dimulai'; } } else { // No workstation result yet - should be gray (not started) $statusClass = 'bg-secondary'; $tooltip = $stageData['name'] . ' - Belum Dimulai'; } } @endphp {{ $stageData['short'] }} @endforeach
@if ($pendingVerification > 0)
{{ $pendingVerification }} Menunggu Verifikasi
@endif
@canRoute ('verification.patient.detail') @endcanRoute
Tidak ada data yang cocok dengan pencarian.
{{ $appointments->links('partials.tables.pagination') }}
@push('styles') @endpush @endsection