using adas_core.Domain.Enums; using adas_core.Domain.Models; using adas_core.Domain.Models.Pumps; using MongoDB.Bson; namespace adas_core.Application.Services.Interfaces; public interface ICalculatedObservations { /// /// Asynchronously maps a patient observation to a corresponding target type, optionally restricting the mapping to name-based matching only. /// /// The source patient observation to be mapped. /// When set to true, the mapping is performed considering only the observation name; otherwise, additional mapping criteria are applied. Defaults to false. /// A that represents the asynchronous mapping operation. The result is the mapped observation of type , or null when no matching mapping is found. Task Map(T obs, bool onlyByName = false) where T : BasePatientObservation; /// /// Asynchronously maps the specified to a result. /// /// The patient treatment instance to map. /// A task that represents the asynchronous mapping operation. The task result contains the mapped . Task Map(PatientTreatment treatment); /// /// Asynchronously maps a to a representation. /// /// The patient diagnosis to be mapped. /// A task that represents the asynchronous mapping operation, containing the mapped . Task Map(PatientDiagnosis diagnosis); /// /// Asynchronously maps the specified to a result. /// /// The to be mapped. /// A representing the asynchronous operation, containing the mapped . Task Map(PumpObservation pumpObservation); /// /// Asynchronously calculates a medicine observation for a patient based on their active medicines. /// /// The list of medicines currently active for the patient. /// The unique identifier of the patient whose observation is being calculated. Task CalculateMedicineObservation(List activeMedicines, ObjectId patientId); /// /// Calculates the active bolus for the specified patient. /// /// The unique identifier of the patient whose active bolus is to be calculated. Task CalculateActiveBolus(ObjectId patientId); /// /// Retrieves the active treatments associated with a specific patient by their unique identifier. /// /// The unique identifier of the patient whose active treatments are being queried. /// A task that represents the asynchronous operation, containing a collection of nullable entries that represent the active treatments for the specified patient. Task> GetActiveTreatmentsByPatient(ObjectId id); /// /// Resolves time inconsistencies between the new observation and the last stored observation, returning a corrected version when applicable. /// /// The new patient observation to validate and reconcile against the previous observation's time information. /// A task that yields the fixed , or null when no time inconsistency is detected or no correction is required. Task FixTimeInconsistencyWithLast(PatientObservation newObservation); /// /// Performs pre-insertion mapping on a list of patient observations, transforming or preparing the data before it is persisted. /// /// The list of patient observations to be pre-mapped prior to insertion. /// A task that represents the asynchronous operation, containing the mapped list of patient observations. Task> PreMapList(List listToInsert); /// /// Maps the source alarm onto the specified patient observation and returns the resulting observation. /// /// The patient observation to which the source alarm will be mapped. /// The patient observation alarm to insert and map as the source alarm. /// A task representing the asynchronous operation, containing the patient observation with the source alarm mapped. Task MapSourceAlarm(PatientObservation obs, PatientObservationAlarm alarmToInsert); /// /// Sends an alarm associated with the specified patient observation, optionally classified by an alarm code. /// /// The patient observation that triggered the alarm. /// The name associated with the alarm. /// An optional alarm code categorizing the type of alarm to send. Task SendAlarm(PatientObservation obs, string name, AlarmEnum.Name? code); }