using adas_core.Domain.Enums;
using MongoDB.Bson;

namespace adas_core.Domain.Models.Pumps
{
    /// <summary>
    /// Estado actual de alarmas activas por bomba.
    /// Una fila por alarma activa (DeviceId + AlarmType o AlarmCodeMdc).
    /// Se actualiza vía PumpService: start/continue → upsert, end → delete.
    /// </summary>
    public class PumpAlarmState
    {
        public ObjectId Id { get; set; }

        // Bomba
        public string? DeviceId { get; set; }

        // Paciente (si la bomba lo envía)
        public ObjectId? PatientId { get; set; }

        // Tipo / Identificador de alarma
        public PumpEnum.AlarmType? AlarmType { get; set; }
        public string? AlarmCodeMdc { get; set; }

        // Estado actual
        public string? AlarmDescription { get; set; }
        public string? AlarmPriority { get; set; }     // PL/PM/PH
        public string? AlarmState { get; set; }        // active / inactive / latched
        public PumpEnum.EventPhase? LastPhase { get; set; }  // start / continue / end

        // Timestamps
        public DateTime FirstSeen { get; set; } = DateTime.UtcNow;
        public DateTime LastUpdated { get; set; } = DateTime.UtcNow;

        // Contexto (opcional)
        public string? AlertSourceMdc { get; set; }
        public string? InfusionId { get; set; }
    }
}