using Health.Domain.Enums;

namespace Health.Domain.Entities;

/// <summary>
/// 用药计划
/// </summary>
public sealed class Medication
{
    public Guid Id { get; set; }
    public Guid UserId { get; set; }
    public string Name { get; set; } = string.Empty;
    public string? Dosage { get; set; }
    public MedicationFrequency Frequency { get; set; }
    public List<TimeOnly> TimeOfDay { get; set; } = []; // PostgreSQL TIME[] 数组
    public DateOnly? StartDate { get; set; }
    public DateOnly? EndDate { get; set; }
    public bool IsActive { get; set; } = true;
    public MedicationSource Source { get; set; }
    public string? Notes { get; set; }
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    public User User { get; set; } = null!;
    public ICollection<MedicationLog> Logs { get; set; } = [];
}

/// <summary>
/// 用药打卡记录
/// </summary>
public sealed class MedicationLog
{
    public Guid Id { get; set; }
    public Guid MedicationId { get; set; }
    public Guid UserId { get; set; }
    public MedicationLogStatus Status { get; set; }
    public TimeOnly ScheduledTime { get; set; }
    public DateTime? ConfirmedAt { get; set; }
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public Medication Medication { get; set; } = null!;
}
