using adas_core.Domain.Enums;
using adas_core.Domain.Models;
using adas_core.Domain.Models.DTO;
using adas_core.Domain.Models.Filter;
using adas_core.Domain.Models.GroupedObservations;
using adas_core.Domain.Models.MongoModels;
using adas_core.Domain.Models.Pumps;
using adas_core.Domain.Models.Responses;
using MongoDB.Bson;
namespace adas_core.Application.Services.Interfaces;
public interface IConfigObservationService
{
///
/// Retrieves a identified by the specified coding system and code.
/// Returns null when no matching configuration observation is found.
///
/// The coding system used to identify the configuration observation (e.g., ICD, SNOMED).
/// The code within the given coding system that uniquely identifies the configuration observation.
/// A if a match is found; otherwise, null.
Task GetByCodeSysAndCode(string codingSystem, string code);
///
/// Asynchronously retrieves a identified by the given name.
/// Returns when no matching configuration observation is found.
///
/// The name of the configuration observation to retrieve.
/// A that yields the matching , or if no observation is found.
Task Get(string name);
///
/// Retrieves the associated with the specified patient observation, optionally restricting the lookup to a match performed by name only.
///
/// The patient observation whose corresponding configuration observation is being requested.
/// When true, limits the lookup to a name-based match; otherwise, other matching criteria may be applied.
/// A task that represents the asynchronous operation. The task result contains the matching , or null if no matching observation is found.
Task Get(T obs, bool onlyByName = false) where T : BasePatientObservation;
///
/// Performs retention actions for the specified patient observation and returns the resulting retention outcome.
///
/// The patient observation of type on which retention actions will be executed.
/// A task that represents the asynchronous retention operation. The task result contains the produced by the retention actions, or null when no retention result is produced.
Task RetentionActions(T obs) where T : BasePatientObservation;
///
/// Maps a patient observation to a corresponding target observation of the same type, optionally restricting the lookup to name-based matching only.
///
/// The source patient observation to be mapped.
/// When set to true, the mapping is performed using the observation's name only; otherwise, additional matching criteria are considered. Defaults to false.
/// A task that represents the asynchronous operation. The task result contains the mapped patient observation of type , or null if no matching observation is found.
Task Map(T obs, bool onlyByName = false) where T : BasePatientObservation;
///
/// Asynchronously maps the specified to a populated instance, returning when the treatment cannot be resolved.
///
/// The to be mapped.
/// A that yields the mapped , or if no mapping result is available.
Task Map(PatientTreatment treatment);
///
/// Determines the status of a grouped observation field based on the provided result, value, and optional threshold range.
///
/// The grouped field associated with the observation.
/// The result of the grouped observation used to evaluate the status.
/// The name of the field or value being evaluated.
/// The value associated with the grouped observation.
/// The optional minimum threshold for the value.
/// The optional maximum threshold for the value.
/// A task that represents the asynchronous operation. The task result contains the evaluated for the grouped observation.
Task GroupedObservationStatus(GroupedField groupedField, GroupedObservationEnum.Result result,
string name, object value, double? min, double? max);
///
/// Retrieves all configuration observations asynchronously.
///
/// The cancellation token used to cancel the asynchronous operation.
/// A task that represents the asynchronous operation. The task result contains a collection of objects representing all available configurations.
Task> GetAllConfigs(CancellationToken ct = default);
///
/// Retrieves a paginated collection of items based on the supplied filter criteria.
///
/// The pagination filter that defines the page size, page number, and query criteria used to retrieve the configuration observations.
/// A task that represents the asynchronous operation, containing a with the requested items and pagination metadata.
Task> GetPaginatedItems(PaginationFilter filter);
///
/// Retrieves all configuration observations in a compact format.
///
/// A task representing the asynchronous operation that returns a containing the compact representation of all configuration observations.
Task GetAllCompact();
///
/// Retrieves a configuration observation by its unique identifier.
///
/// The unique identifier of the configuration observation to retrieve.
/// A task that represents the asynchronous operation. The task result contains the if a matching record is found, or null if no configuration exists for the specified id.
Task GetConfigById(ObjectId id);
///
/// Asynchronously retrieves a list of configuration names associated with the specified identifier.
///
/// The identifier used to look up the associated configuration names.
/// A task that represents the asynchronous operation. The task result contains a list of configuration names.
Task> GetConfigNames(string id);
///
/// Asynchronously retrieves the list of available configuration names.
///
/// A task that represents the asynchronous operation, containing a list of configuration names.
Task> GetConfigNames();
///
/// Updates an existing configuration observation and returns the updated result.
///
/// The configuration observation containing the data to update.
/// A task that resolves to the updated , or null when no matching configuration is found.
Task UpdateConfig(ConfigObservation configObservation);
///
/// Asynchronously creates a new configuration based on the provided observation data.
///
/// The observation data used to create the configuration.
/// A task that represents the asynchronous operation, containing the created , or null if the configuration could not be created.
Task CreateConfig(ConfigObservation configObservation);
///
/// Asynchronously removes the configuration item with the specified name.
///
/// The name of the configuration item to remove.
/// A task that represents the asynchronous operation. The task result contains a describing the removed item, or null if no matching item was found.
Task RemoveConfigItem(string itemName);
///
/// Asynchronously removes the configuration item identified by the specified identifier and returns the resulting observation.
///
/// The unique identifier of the configuration item to remove.
/// A task that represents the asynchronous operation. The task result contains the describing the removed configuration item, or null if no matching item was found.
Task RemoveConfigItem(ObjectId id);
///
/// Retrieves the configuration observation items associated with the specified name.
///
/// The name used to look up the configuration observation items.
/// A task that represents the asynchronous operation. The result contains a collection of items matching the provided name, or null if no matching items are found.
Task?> GetConfigObservationItem(string name);
///
/// Retrieves a single configuration observation item based on the provided code, coding system, name, and original name.
///
/// The code used to identify the configuration observation item.
/// The coding system associated with the code.
/// The name of the configuration observation item.
/// The original name of the configuration observation item.
/// A task that represents the asynchronous operation. The task result contains the matching , or null if no item is found.
Task GetSingleConfigObservationItem(string? code, string? codingSystem, string? name,
string? originalName);
///
/// Asynchronously deletes a single configuration observation item from the underlying store.
///
/// The configuration observation item to be deleted.
/// A task that represents the asynchronous operation. The task result contains a boolean value indicating whether the deletion was successful.
Task DeleteSingleConfigObservationItem(ConfigObservation configObservationItem);
///
/// Retrieves configuration observation items that match the specified name.
///
/// The name used to filter the configuration observation items.
/// A task that represents the asynchronous operation. The task result contains the collection of items matching the specified name.
Task> GetConfigObservationItemsByName(string name);
}