@props(['vaccine', 'tipo', 'rut']) @php $estadoDocumento = null; $iconoEstado = '❌'; $textoEstado = 'No subido'; $claseEstado = 'text-muted'; if ($vaccine && $vaccine['preview'] !== null) { if (in_array($tipo, ['Influenza', 'Covid']) && isset($vaccine['date'])) { try { $fechaVacuna = \Carbon\Carbon::parse($vaccine['date']); $now = now(); // Lógica Influenza if ($tipo === 'Influenza') { $currentMarch = \Carbon\Carbon::create($now->year, 3, 1)->startOfDay(); $lastMarch = \Carbon\Carbon::create($now->year - 1, 3, 1)->startOfDay(); $currentApril = \Carbon\Carbon::create($now->year, 4, 30)->endOfDay(); if ($fechaVacuna->greaterThanOrEqualTo($currentMarch)) { $estadoDocumento = 'valid'; } elseif ($fechaVacuna->greaterThanOrEqualTo($lastMarch) && $now->lessThanOrEqualTo($currentApril)) { $estadoDocumento = 'expiring'; } else { $estadoDocumento = 'expired'; } } // Lógica Covid elseif ($tipo === 'Covid') { $elevenMonthsAgo = $now->copy()->subMonths(11)->startOfDay(); $twelveMonthsAgo = $now->copy()->subMonths(12)->startOfDay(); if ($fechaVacuna->lessThanOrEqualTo($elevenMonthsAgo) && $fechaVacuna->greaterThan($twelveMonthsAgo)) { $estadoDocumento = 'expiring'; } elseif ($fechaVacuna->year === $now->year || $fechaVacuna->greaterThan($twelveMonthsAgo)) { $estadoDocumento = 'valid'; } else { $estadoDocumento = 'expired'; } } // Asignación de diseño if ($estadoDocumento === 'expiring') { $iconoEstado = '⏰'; $textoEstado = 'Próx. a vencer'; $claseEstado = 'text-warning'; } elseif ($estadoDocumento === 'expired') { $iconoEstado = '⚠️'; $textoEstado = 'Vencido'; $claseEstado = 'text-danger'; } else { $iconoEstado = '✅'; $textoEstado = 'Vigente'; $claseEstado = 'text-success'; } } catch (\Exception $e) { $iconoEstado = '✅'; $textoEstado = 'Subido'; $claseEstado = 'text-success'; } } else { $iconoEstado = '✅'; $textoEstado = 'Subido'; $claseEstado = 'text-success'; } } @endphp @if (!$vaccine || $vaccine['preview'] === null)
No subido
S/I
@else
{{-- Icono de estado --}}
{{ $iconoEstado }}
{{ $textoEstado }}
{{-- Botones --}}
@if ($vaccine['preview']) Ver @endif
{{-- Mostrar fechas según el tipo --}} @if (isset($vaccine['date']))
@if ($tipo === 'Hepatitis B' && isset($vaccine['fecha_2']) && isset($vaccine['fecha_3']))
{{ \Carbon\Carbon::parse($vaccine['date'])->format('d/m/Y') }}
(3 dosis)
@else {{-- Fechas Covid, Influenza y Fotografía --}}
@php try { $fechaFormateada = \Carbon\Carbon::parse($vaccine['date'])->format('d/m/Y'); } catch (\Exception $e) { $fechaFormateada = 'Fecha inválida'; } @endphp {{ $fechaFormateada }} {{-- Mostrar estado adicional para Influenza y Covid --}} @if (in_array($tipo, ['Influenza', 'Covid'])) @if ($estadoDocumento === 'expired') Vencida @elseif ($estadoDocumento === 'expiring') Por vencer @endif @elseif ($tipo === 'Fotografía') Foto @endif
@endif
@endif
@endif @push('scripts') @endpush