using adas_core.Domain.Models.Pumps;
using MongoDB.Bson;

namespace adas_core.Application.Repositories.Interfaces;

public interface IPumpObservationRepository
{
    Task InsertAsync(PumpObservation obs);
    Task InsertManyAsync(IEnumerable<PumpObservation> observations);

    Task<IEnumerable<PumpObservation>> FindByDeviceIdAsync(
        string deviceId,
        DateTime? from = null,
        DateTime? to = null,
        int? limit = null);

    Task<PumpObservation?> FindLastByDeviceIdAsync(string deviceId);
    Task<Dictionary<ObjectId, DateTime>> FindAllLastPatientObservationTimeAsync();

    Task<IEnumerable<PumpObservation>> FindByPatientId(ObjectId? patientId);

    Task<List<PumpObservation>> AggregatedPatientLastObservations(ObjectId patientId, int num = 100);
    Task DeleteByPatientId(ObjectId? patientId);
    Task<long> DeleteOlderThanDaysAsync(int days, string? name = null);
    Task<long> DeleteKeepLastNAsync(int maxCount);
    
    Task<long> UpdateManyObjectIdByFieldAsync(string fieldName, ObjectId newId, ObjectId? oldId);
}