<?php
declare(strict_types=1);

namespace App\Modules\PlayerAffairs\Models;

use App\Core\Model;

class PlayerMedicalRecord extends Model
{
    protected static string $table = 'player_medical_records';
    protected static string $primaryKey = 'id';
    protected static bool $timestamps = true;
    protected static bool $softDelete = false;
    protected static bool $autoTrackAuthor = false;

    protected static array $fillable = [
        'player_id',
        'record_type',
        'exam_date',
        'expiry_date',
        'doctor_name',
        'clinic_name',
        'result',
        'restrictions',
        'document_id',
        'notes',
        'created_by',
    ];

    /**
     * Get record types with Arabic labels.
     */
    public static function getRecordTypes(): array
    {
        return [
            'fitness_cert'   => 'شهادة لياقة',
            'medical_exam'   => 'فحص طبي',
            'blood_test'     => 'تحليل دم',
            'cardiac_screen' => 'فحص قلب',
            'other'          => 'أخرى',
        ];
    }

    /**
     * Get medical results with Arabic labels.
     */
    public static function getResults(): array
    {
        return [
            'fit'         => 'لائق',
            'conditional' => 'لائق بشروط',
            'unfit'       => 'غير لائق',
        ];
    }

    /**
     * Get all medical records for a specific player, ordered by exam_date DESC.
     */
    public static function getForPlayer(int $playerId): array
    {
        return static::query()
            ->where('player_id', '=', $playerId)
            ->orderBy('exam_date', 'DESC')
            ->get();
    }
}
