#nullable enable
using Baya.Domain.Common;
using Baya.Domain.Entities.Identity;

namespace Baya.Domain.Entities.Verification;

/// <summary>
/// The master per-nurse verification record and the <b>single source of verification truth</b>. Its
/// <see cref="Status"/> rolls up the per-step outcomes; the derived <c>nurse_profiles.is_verified</c>
/// boolean is flipped only inside the finalize transaction when every required step has passed (and
/// reversed on suspension). The legacy <c>nurse_profiles.verification_status</c> column was deliberately
/// cut — never reintroduce a second copy of this state.
/// </summary>
public class NurseVerification : BaseEntity<long>, IAuditable
{
    public long NurseId { get; set; }

    /// <summary>Read-projection navigation (nurse name / identity for the admin queue). The finalize/suspend
    /// flip loads the tracked profile separately, so this is not the write path for <c>is_verified</c>.</summary>
    public NurseProfile Nurse { get; set; } = null!;

    public VerificationStatus Status { get; set; } = VerificationStatus.NotStarted;

    public DateTimeOffset? SubmittedAt { get; set; }
    public DateTimeOffset? ApprovedAt { get; set; }
    public DateTimeOffset? RejectedAt { get; set; }
    public DateTimeOffset? SuspendedAt { get; set; }

    public string? RejectionReason { get; set; }

    /// <summary>The admin who last drove a manual decision (review/suspend).</summary>
    public int? ReviewedByAdminId { get; set; }

    public string? InternalNotes { get; set; }

    public DateTimeOffset? DeletedAt { get; set; }

    public ICollection<VerificationStep> Steps { get; set; } = new List<VerificationStep>();
}
