namespace adas_core.Domain.Models;

public class HistoricalLocation : IEquatable<HistoricalLocation>
{
    // Propiedades con get y set para que MongoDB pueda escribir en ellas
    public DateTime? AdmTime { get; set; }
    public PatientLocation? PatientLocation { get; set; }

    // Constructor vacío necesario para la deserialización de MongoDB
    public HistoricalLocation() { }

    // Tu constructor actual
    public HistoricalLocation(DateTime admTime, PatientLocation patientLocation)
    {
        AdmTime = admTime;
        PatientLocation = patientLocation ?? throw new ArgumentNullException(nameof(patientLocation));
    }

    public bool Equals(HistoricalLocation? other)
    {
        if (other == null) return false;
        return AdmTime == other.AdmTime &&
               (PatientLocation?.Equals(other.PatientLocation) ?? other.PatientLocation == null);
    }

    public bool IsEmpty() => !AdmTime.HasValue && (PatientLocation == null || PatientLocation.IsEmpty());

    public bool IsFull() => AdmTime.HasValue && PatientLocation != null && !PatientLocation.IsFullEmpty();

    public override string ToString() => $"HistoricalLocation[AdmTime: {AdmTime}, PatientLocation: {PatientLocation}]";
}