using adas_core.Domain.Models;
using adas_core.Domain.Models.GroupedObservations;
using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;

namespace adas_core.Application.Repositories.Interfaces;

public interface IAlarmRepository : IMongoRepository<PatientObservationAlarm>
{
    /// <summary>
    /// Retrieves the most recent aggregated patient observations as alarm records, optionally filtered to a specific set of fields.
    /// </summary>
    /// <param name="patientId">The unique identifier of the patient whose last observations should be aggregated.</param>
    /// <param name="filterObservations">An optional list of fields used to restrict which observation types are included in the aggregation; when null, all available observations are considered.</param>
    /// <returns>A task that resolves to the list of aggregated <see cref="PatientObservationAlarm"/> entries representing the patient's latest observations.</returns>
    Task<List<PatientObservationAlarm>> AggregatedPatientLastObservationsByField(ObjectId patientId,
            List<Field>? filterObservations = null);

    /// <summary>
    /// Retrieves aggregated, non-expired patient observation alarms for a specific patient, optionally filtered by a set of fields and evaluated against the supplied configuration alarms.
    /// </summary>
    /// <param name="patientId">The unique identifier of the patient whose observation alarms are being retrieved.</param>
    /// <param name="filterObservations">An optional list of fields used to restrict which observations are considered. If null, no field-based filtering is applied.</param>
    /// <param name="configAlarm">The list of configuration observation definitions used to build and aggregate the resulting alarms.</param>
    /// <returns>A task that represents the asynchronous operation, containing a list of aggregated <see cref="PatientObservationAlarm"/> entries for the patient.</returns>
    Task<List<PatientObservationAlarm>> AggregatedPatientNotExpiredObservationsByField(ObjectId patientId,
            List<Field>? filterObservations, List<ConfigObservation> configAlarm);
}