@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)