namespace adas_core.Domain.Models.Observations;

public class FullObservation : Observation
{
    public DateTime LastObservationDate;

    public DateTime ObservationDate;
    public string? Text { get; set; }
    public required object Value { get; set; }
    public object? LastValue { get; set; }
    public double? Min { get; set; }
    public double? Max { get; set; }

    public double? MinAlert { get; set; }
    public double? MaxAlert { get; set; }

    public double? MinWarn { get; set; }
    public double? MaxWarn { get; set; }

    public static FullObservation? From(List<PatientObservation> obs)
    {
        if (obs.Count > 0)
            return new FullObservation
            {
                Text = obs[0].Name,
                Value = obs[0].Value,
                Min = obs[0].Min,
                Max = obs[0].Max,
                ObservationDate = obs[0].Time,
                LastValue = obs.Count > 1 ? obs[1].Value : null,
                LastObservationDate = obs.Count > 1 ? obs[1].Time : DateTime.MinValue
            };
        return null;
    }
}