using adas_core.Application.Services.Interfaces;
using adas_core.Domain.Enums;
using adas_core.Domain.Models;
using adas_core.Domain.Models.Pumps;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MongoDB.Bson;
namespace adas_core.Application.Customizations.CHUO;
///
/// Provides calculated observation data by implementing the contract.
///
///
/// Instances are constructed with an used to resolve dependencies required by the implementation.
///
///
public class CalculatedObservations(IServiceProvider serviceProvider) : ICalculatedObservations
{
private readonly ILogger _logger =
serviceProvider.GetRequiredService>();
///
/// Asynchronously calculates the active bolus for the specified patient.
///
/// The unique identifier of the patient for whom the active bolus is being calculated.
///
public Task CalculateActiveBolus(ObjectId patientId)
{
return Task.CompletedTask;
}
///
/// Asynchronously maps the provided instance, returning the same instance as the result.
///
/// The pump observation to map.
/// A containing the provided pump observation.
///
public async Task Map(PumpObservation pumpObservation)
{
return await Task.FromResult(pumpObservation);
}
///
/// Calculates medicine observations for the specified patient based on the provided active medicines.
///
/// The list of medicines currently active for the patient.
/// The identifier of the patient for whom the observation is calculated.
///
public Task CalculateMedicineObservation(List activeMedicines, ObjectId patientId)
{
return Task.CompletedTask;
}
///
/// Resolves time inconsistencies between a new patient observation and the most recent one, returning a corrected observation when a discrepancy is detected.
///
/// The new patient observation to compare and reconcile against the last stored observation.
/// A task that yields the corrected , or null when no time inconsistency is found.
/// Thrown because the method has not been implemented yet.
///
public Task FixTimeInconsistencyWithLast(PatientObservation newObservation)
{
throw new NotImplementedException();
}
///
/// Retrieves the active treatment records associated with the specified patient.
///
/// The unique identifier of the patient whose active treatments are being requested.
/// A task that represents the asynchronous operation. The task result contains a collection of nullable objects representing the patient's active treatments.
/// Thrown to indicate that the method has not yet been implemented.
///
public Task> GetActiveTreatmentsByPatient(ObjectId id)
{
throw new NotImplementedException();
}
///
/// Maps a patient observation by returning it as-is, logging the operation as a trace entry.
///
/// The patient observation to map.
/// Indicates whether mapping should be performed by name only.
/// A task containing the provided observation.
///
public Task Map(T obs, bool onlyByName = false) where T : BasePatientObservation
{
_logger.LogTrace("Mapping {name} observation {obs}", obs.Name, obs);
return Task.FromResult(obs);
}
///
/// Maps the specified to a resulting instance asynchronously.
///
/// The patient treatment to be mapped.
/// A task that represents the asynchronous mapping operation, containing the resulting .
/// Thrown when the method is invoked, as the mapping has not been implemented.
///
public Task Map(PatientTreatment treatment)
{
throw new NotImplementedException();
}
///
/// Maps a instance to a result.
///
/// The patient diagnosis to be mapped.
/// A task representing the asynchronous operation, containing the mapped .
/// Thrown because the mapping logic has not yet been implemented.
///
public Task Map(PatientDiagnosis diagnosis)
{
throw new NotImplementedException();
}
///
/// Performs a pre-mapping step on a list of patient observations before they are inserted.
/// Currently acts as a pass-through, returning the provided list unchanged as a completed task, but can be overridden to apply transformations or validations.
///
/// The list of patient observations to be pre-mapped prior to insertion.
/// A completed task containing the provided list of patient observations.
///
public Task> PreMapList(List listToInsert)
{
return Task.FromResult(listToInsert);
}
///
/// Maps a source alarm onto a , returning the observation as-is without applying the alarm's changes.
///
/// The existing patient observation to be returned.
/// The alarm to be associated with the observation (currently not applied).
/// A completed containing the original observation.
///
public Task MapSourceAlarm(PatientObservation obs, PatientObservationAlarm alarmToInsert)
{
return Task.FromResult(obs);
}
///
/// Sends an alarm notification for the specified patient observation, identified by the given name and optional alarm code.
///
/// The patient observation that triggers the alarm.
/// The name of the alarm to send.
/// The optional alarm code providing additional classification for the alarm.
///
public Task SendAlarm(PatientObservation obs, string name, AlarmEnum.Name? code)
{
return Task.CompletedTask;
}
//public Task> MapList(List obsToInsert)
//{
// throw new NotImplementedException();
//}
}