using adas_core.Domain.Enums;
using Newtonsoft.Json;

namespace adas_core.Domain.Models.Recording;

public class RecordingData
{
    public Patient? Patient { get; set; }
    public int RoomId { get; set; }
    public DateTime? StartRecordingTime { get; set; }
    public DateTime? StopRecordingTime { get; set; }
    public DateTime? EventTime { get; set; }
    public AlarmEnum.Type? AlarmType { get; set; }
    public AlarmEnum.Severity Severity { get; set; } = AlarmEnum.Severity.None;
    public string? AlarmDescription { get; set; }
    public string? AlarmName { get; set; }
    public string Store { get; set; } = string.Empty;
    public int Retry { get; set; }
    public string Status { get; set; } = string.Empty;

    public string GenerateStore()
    {
        return Store = $"{RoomId}_{DateTime.Now:yyyyMMdd-HHmmss}";
    }

    public override string ToString()
    {
        try
        {
            return JsonConvert.SerializeObject(this, Formatting.None);
        }
        catch
        {
            return base.ToString()!;
        }
    }
}