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

Hasil MCU Pasien

@endsection @section('content')
Jenis Pasien
@php // Build filter parameters - exclude date filters when company filter is active $hasCompanyFilter = request()->has('company_id') && request()->company_id !== 'all'; $baseParams = []; if (request()->has('search')) { $baseParams['search'] = request()->search; } if (request()->has('status')) { $baseParams['status'] = request()->status; } // Only include date filters if no company filter is active if (!$hasCompanyFilter) { if (request()->has('date_filter')) { $baseParams['date_filter'] = request()->date_filter; } if (request()->has('date_from')) { $baseParams['date_from'] = request()->date_from; } if (request()->has('date_to')) { $baseParams['date_to'] = request()->date_to; } } // Tentukan tombol mana yang aktif $isAllTime = !request()->has('patient_type') && request('date_filter') === 'all'; $isToday = !request()->has('patient_type') && !request()->has('date_filter') && !request()->has('date_from') && !request()->has('date_to') && !request()->has('search') && !request()->has('company_id'); @endphp @canRoute ('mcu-results.index') Korporat
{{ $counts['corporate'] }}
@endcanRoute @canRoute ('mcu-results.index') Individu
{{ $counts['individual'] }}
@endcanRoute @canRoute ('mcu-results.index') Semua
{{ $counts['total'] }}
@endcanRoute @canRoute ('mcu-results.index') Semua Hari Ini
{{ $todayCount }}
@endcanRoute
Filter Perusahaan
@if (request()->has('patient_type')) @endif @if (request()->has('search')) @endif @if (request()->has('status')) @endif @php // Only include date filters if no patient type filter is active $hasPatientTypeFilter = request()->has('patient_type'); @endphp @if (!$hasPatientTypeFilter) @if (request()->has('date_filter')) @endif @if (request()->has('date_from')) @endif @if (request()->has('date_to')) @endif @endif
Filter Booking MCU
@if (request()->has('patient_type')) @endif @if (request()->has('search')) @endif @if (request()->has('status')) @endif @if (request()->has('company_id')) @endif @php // Only include date filters if no patient type filter is active $hasPatientTypeFilter = request()->has('patient_type'); @endphp @if (!$hasPatientTypeFilter) @if (request()->has('date_filter')) @endif @if (request()->has('date_from')) @endif @if (request()->has('date_to')) @endif @endif
Pilih perusahaan terlebih dahulu untuk mengaktifkan filter ini
Hasil MCU Pasien
@php $quickDateValue = $filterDate ?? ''; @endphp
{{ $results->total() }} Hasil {{ \App\Helpers\DateHelper::formatDate(now()) }}

Daftar Hasil MCU yang Telah Selesai

@if (request()->has('company_id') || request()->has('date_filter') || request()->has('booking_company_id') || request()->has('booking_invitation_id') || request()->has('search') || request()->has('patient_type') || request()->has('status'))
Filter Aktif: @if (request('patient_type')) @switch (request('patient_type')) @case ('corporate') Pasien Korporat @break @case ('individual') Pasien Individu @break @endswitch @endif @if (request('company_id') && request('company_id') !== 'all') Perusahaan: {{ $companies->find(request('company_id'))->name ?? 'N/A' }} @endif @if (request('date_filter') && request('date_filter') !== 'all') @switch (request('date_filter')) @case ('today') Hari Ini @break @case ('this_week') Minggu Ini @break @case ('this_month') Bulan Ini @break @endswitch @endif @if (request('booking_company_id') && request('booking_company_id') !== 'all') Booking: {{ $bookingCompanies->find(request('booking_company_id'))->name ?? 'N/A' }} @endif @if (request('booking_invitation_id') && request('booking_invitation_id') !== '') @php $selectedInvitation = $bookingInvitations->find(request('booking_invitation_id')); @endphp @if ($selectedInvitation) Booking MCU: {{ $selectedInvitation->company->name }}, {{ \App\Helpers\DateHelper::formatShort($selectedInvitation->mcu_date) }} @endif @endif @if (request('search')) Pencarian: "{{ request('search') }}" Semua riwayat MCU @endif @if (request('status') && request('status') !== 'all') Status: {{ ucfirst(request('status')) }} @endif
@php $selectedInvitation = null; $hasDownloadableResults = false; $downloadableCount = 0; if (request('booking_invitation_id') && request('booking_invitation_id') !== '') { $selectedInvitation = $bookingInvitations->find(request('booking_invitation_id')); if ($selectedInvitation) { $employeeIds = $selectedInvitation->employees->pluck('patient_id')->filter(); if ($employeeIds->isNotEmpty()) { $downloadableCount = \App\Models\McuResult::whereIn('patient_id', $employeeIds) ->whereIn('status', ['finalized', 'published']) ->whereHas('appointment', function ($q) use ($selectedInvitation) { $q->where('status', '!=', 'cancelled'); if ($selectedInvitation->mcu_date) { $q->where('appointment_date', '>=', $selectedInvitation->mcu_date); } }) ->count(); $hasDownloadableResults = $downloadableCount > 0; } } } @endphp @canRoute ('mcu-results.downloadBulkByBooking') @endcanRoute @canRoute ('mcu-results.index') Reset Filter @endcanRoute
@if ($selectedInvitation && !$hasDownloadableResults) Tidak ada hasil MCU yang dapat diunduh (seluruh hasil masih berstatus Draft) @elseif ($selectedInvitation && $hasDownloadableResults) Tombol download siap digunakan ({{ $downloadableCount }} hasil Finalized) @else Pilih filter booking MCU terlebih dahulu untuk mengaktifkan tombol download @endif
@if ($hasDuplicateCompanyGroup && app(\App\Services\RoleAccess::class)->allows( auth()->user(), 'mcu-results.movePatientsToDuplicateCompany' ))
Duplikasi Perusahaan Terdeteksi: {{ $duplicateCompanySourceName ?? 'N/A' }}
Pilih pasien yang dicentang di tabel, lalu pilih perusahaan tujuan untuk memindahkan data.
@canRoute ('mcu-results.movePatientsToDuplicateCompany')
@csrf Pasien terpilih: 0
@endcanRoute
@elseif ($hasDuplicateCompanyGroup)
Terjadi duplikasi nama perusahaan untuk filter yang sedang dipilih. Untuk memindahkan pasien, silakan hubungi super admin.
@endif
Download Bulk PDF: @if ($selectedInvitation && $hasDownloadableResults) Tombol ini akan mengunduh {{ $downloadableCount }} hasil MCU yang telah selesai (Finalized) dari booking MCU {{ $selectedInvitation->company->name }} tanggal {{ \App\Helpers\DateHelper::formatShort( $selectedInvitation->mcu_date, ) }} dalam format ZIP. @elseif ($selectedInvitation && !$hasDownloadableResults) Seluruh hasil MCU untuk booking MCU {{ $selectedInvitation->company->name }} tanggal {{ \App\Helpers\DateHelper::formatShort( $selectedInvitation->mcu_date, ) }} masih berstatus Draft. Tombol download akan otomatis aktif setelah minimal 1 hasil MCU berstatus Finalized. @else Pilih filter booking MCU terlebih dahulu untuk mengaktifkan tombol download. @endif
@endif @if (request()->filled('search'))
Menampilkan semua riwayat MCU untuk pencarian "{{ request('search') }}" — filter tanggal diabaikan. Ditemukan {{ $results->total() }} hasil.
@endif
@foreach (request()->except(['search', 'page']) as $key => $value) @if ($value !== null && $value !== '') @endif @endforeach
@if (request()->filled('search')) @canRoute ('mcu-results.index') @endcanRoute @endif
@if (!request()->filled('search')) Pencarian nama akan menampilkan semua riwayat MCU pasien lintas tanggal. @endif
@if ($hasDuplicateCompanyGroup && app(\App\Services\RoleAccess::class)->allows( auth()->user(), 'mcu-results.movePatientsToDuplicateCompany' )) @endif @forelse ($results as $result) @if ($hasDuplicateCompanyGroup && app(\App\Services\RoleAccess::class)->allows( auth()->user(), 'mcu-results.movePatientsToDuplicateCompany' )) @endif @empty @endforelse
No. No. Hasil Nama Pasien Perusahaan Tanggal MCU Status Kesehatan Status MCU KePilihAksi
{{ $loop->iteration + ($results->currentPage() - 1) * $results->perPage() }} {{ $result->result_number }}
{{ $result->patient->name }}
{{ $result->patient->medical_record_number }}
{{ $result->appointment->registration_number }}
Tanggal Lahir: {{ $result->patient->birth_date ? \App\Helpers\DateHelper::formatShort($result->patient->birth_date) : 'N/A' }}
@php $displayCompany = $result->appointment?->company ?? ($result->company ?? $result->patient?->company); $displayJobPosition = $result->patient?->job_position ?? ($result->patient?->occupation ?? $result->appointment?->getJobPosition()); @endphp @if ($displayCompany)
{{ $displayCompany->name }} @if ($displayJobPosition)
{{ $displayJobPosition }} @endif
@else Individu @endif
@if ($result->status === 'finalized' && $result->finalized_at) {{ \App\Helpers\DateHelper::formatShort( $result->finalized_at, ) }}
MCU: {{ $result->examination_date ? \App\Helpers\DateHelper::formatShort($result->examination_date) : 'N/A' }} @else {{ $result->examination_date ? \App\Helpers\DateHelper::formatShort($result->examination_date) : 'N/A' }} @endif
@php // Normalisasi class badge untuk semua variasi status kesehatan $status = $result->health_status; $healthStatusClass = match ($status) { 'fit', 'fit_for_the_job' => 'bg-success', 'fit_with_treatment', 'fit_with_note', 'fit_for_the_job_with_treatment', 'fit_for_the_job_with_note' => 'bg-warning', 'temporary_unfit', 'unfit' => 'bg-danger', default => 'bg-secondary', }; // Tampilkan teks Title Case tanpa underscore untuk semua status $healthStatusMap = [ 'fit' => 'Fit', 'fit_with_treatment' => 'Fit With Treatment', 'temporary_unfit' => 'Temporary Unfit', 'unfit' => 'Unfit', 'fit_for_the_job' => 'Fit For The Job', 'fit_for_the_job_with_treatment' => 'Fit For The Job With Treatment', 'fit_with_note' => 'Fit With Note', 'fit_for_the_job_with_note' => 'Fit For The Job With Note', ]; $healthStatusText = $healthStatusMap[$status] ?? ucwords(str_replace('_', ' ', (string) $status)); @endphp {{ $healthStatusText }} @php $statusClass = match ($result->status) { 'finalized' => 'bg-success', 'published' => 'bg-primary', 'draft' => 'bg-warning', default => 'bg-secondary', }; $statusText = match ($result->status) { 'finalized' => 'Finalized', 'published' => 'Published', 'draft' => $result->cancellation_reason ? 'Dibatalkan' : 'Draft', default => ucfirst($result->status), }; // Add indicator for re-verified results // Tambahkan indikator untuk hasil yang diverifikasi ulang if ($result->status === 'finalized' && $result->cancellation_reason && $result->finalized_at) { $statusText = 'Finalized (Re-verified)'; } @endphp {{ $statusText }} @if ($result->status === 'finalized' && $result->cancellation_reason && $result->finalized_at)
Diverifikasi ulang: {{ \App\Helpers\DateHelper::formatFull($result->finalized_at) }} {{ $result->finalized_at->format('H:i') }} @endif
@php $mcuOrder = $result->patient->appointments ->filter(function ($apt) use ($result) { return $apt->status !== 'cancelled' && ($apt->appointment_date < $result->appointment->appointment_date || ($apt->appointment_date->eq($result->appointment->appointment_date) && $apt->id <= $result->appointment->id)); }) ->count(); $previousMcu = $result->patient->appointments ->filter(function ($apt) use ($result) { return $apt->status !== 'cancelled' && ($apt->appointment_date < $result->appointment->appointment_date || ($apt->appointment_date->eq($result->appointment->appointment_date) && $apt->id < $result->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
@canRoute ('mcu-results.show') @endcanRoute @if ($result->status === 'finalized' || $result->status === 'published') @canRoute ('mcu-results.printPdf') @endcanRoute @canRoute ('mcu-results.downloadPdf') @endcanRoute @endif
@endsection @push('styles') @endpush @push('scripts') @endpush