using adas_core.Domain.Enums; using adas_core.Domain.Models; using adas_core.Domain.Models.GroupedObservations; using adas_core.Domain.Models.MongoModels; using MongoDB.Bson; namespace adas_core.Application.Services.Interfaces; public interface IAlarmService : IApiRequestService { /// /// Retrieves the most recent patient observations for the specified patient, optionally filtered by a set of fields. /// /// The identifier of the patient whose last observations should be retrieved. /// An optional list of fields to restrict the returned observations; when null, no field filter is applied. /// A task that resolves to the list of the patient's most recent records. public Task> FindLastObservationsByField(ObjectId patientId, List? filterObservations = null); /// /// Retrieves the most recent non-expired patient observation alarms for a specific patient, based on the provided alarm fields and configuration. /// /// The unique identifier of the patient whose alarms are being queried. /// The list of fields used to identify and filter the patient observation alarm data. /// The list of configuration observations that define the alarm criteria, including expiration rules. /// A task that represents the asynchronous operation, containing the list of the latest non-expired entries for the patient. Task> FindLastValuesNotExpired(ObjectId patientId, List dataAlarmfields, List configAlarm); /// /// Maps a patient observation alarm, optionally restricting the lookup to name-based matching only. Returns a null result when no matching alarm is found. /// /// The patient observation alarm to be mapped. /// When true, limits the mapping to lookups performed by name only. /// A task that resolves to the mapped patient observation alarm, or null if no corresponding alarm is found. public Task MapObservation(PatientObservationAlarm obs, bool onlyByName = false); /// /// Maps the given patient observation alarm to a corresponding record by name, returning a null result when no matching observation is found. /// /// The patient observation alarm to be mapped by name. /// A task containing the mapped , or null if no matching observation exists. public Task MapObservationsByName(PatientObservationAlarm obs); /// /// Asynchronously calculates an alarm test result based on the provided patient observation value. /// /// The base patient observation value used as input for the alarm evaluation. /// The name that identifies the alarm test to be calculated. Task CalculateAlarmTest(BasePatientObservationValue source, string name); /// /// Sends an alarm notification associated with the specified patient observation, using the provided name, optional code, severity, and type. /// /// The patient observation that triggers the alarm. /// The display name of the alarm. /// The optional alarm code identifier, or null when not applicable. /// The severity level assigned to the alarm. /// The type category of the alarm. /// A task that represents the asynchronous alarm sending operation. Task SendAlarm(PatientObservation obs, string name, AlarmEnum.Name? code, AlarmEnum.Severity severity, AlarmEnum.Type type); /// /// Asynchronously checks the observation alarm for the specified patient observation. /// /// The patient observation to evaluate for alarm conditions. Task CheckObservationAlarm(PatientObservation obs4); /// /// Processes a collection of patient observation alarms, associating them with the corresponding observations and patient, and recording the processing time. /// /// The list of patient observation alarms to be processed. /// The list of patient observations related to the alarms. /// The patient to whom the observations and alarms belong. /// The timestamp associated with the message being processed. /// Optional additional observation data used during processing. Task ProcessAlarmObservations(List alarmObservations, List observations, Patient patient, DateTime messageTime, ObservationData? observationData = null); }