using Health.Domain.Entities;

namespace Health.Application.HealthArchives;

public sealed record HealthArchiveSurgeryDto(
    Guid Id,
    string Type,
    DateOnly? Date);

public sealed record HealthArchiveSurgeryInput(
    string Type,
    DateOnly? Date);

public sealed record HealthArchiveDto(
    Guid Id,
    Guid UserId,
    string? Diagnosis,
    string? SurgeryType,
    DateOnly? SurgeryDate,
    IReadOnlyList<HealthArchiveSurgeryDto> Surgeries,
    IReadOnlyList<string> Allergies,
    IReadOnlyList<string> DietRestrictions,
    IReadOnlyList<string> ChronicDiseases,
    string? FamilyHistory,
    DateTime UpdatedAt);

public sealed record HealthArchiveUpdateRequest(
    string? Diagnosis,
    string? SurgeryType,
    DateOnly? SurgeryDate,
    IReadOnlyList<string>? Allergies,
    IReadOnlyList<string>? DietRestrictions,
    IReadOnlyList<string>? ChronicDiseases,
    string? FamilyHistory,
    IReadOnlyList<HealthArchiveSurgeryInput>? Surgeries = null);

public interface IHealthArchiveService
{
    Task<HealthArchiveDto?> GetAsync(Guid userId, CancellationToken ct);
    Task<HealthArchiveDto> GetOrCreateAsync(Guid userId, CancellationToken ct);
    Task<HealthArchiveDto> UpdateAsync(Guid userId, HealthArchiveUpdateRequest request, CancellationToken ct);
    Task<object> ExecuteAiActionAsync(Guid userId, string action, HealthArchiveUpdateRequest request, CancellationToken ct);
}

public interface IHealthArchiveRepository
{
    Task<HealthArchive?> GetByUserIdAsync(Guid userId, CancellationToken ct);
    Task AddAsync(HealthArchive archive, CancellationToken ct);
    Task SaveChangesAsync(CancellationToken ct);
}
