using adas_core.Domain.Enums;
using adas_core.Domain.Models.DTO;
using adas_core.Domain.Models.Filter;
using adas_core.Domain.Models.Masters;
using adas_core.Domain.Models.MongoModels;
using adas_core.Domain.Models.Responses;
using MongoDB.Bson;
namespace adas_core.Application.Services.Interfaces;
public interface IUnitService
{
///
/// Asynchronously retrieves all units, with an option to include their associated POCs.
///
/// Indicates whether the returned units should include their associated POCs.
/// A task representing the asynchronous operation, containing the list of units.
Task> GetAll(bool withPocs = false);
///
/// Asynchronously retrieves a compact list of all units, returning minimal summary information for each unit.
///
/// A task that represents the asynchronous operation. The task result contains a list of objects with the compact information of all units.
Task> GetAllCompact();
///
/// Retrieves a compact representation of a unit info by its identifier.
///
/// The unique identifier of the unit to retrieve.
/// A task that represents the asynchronous operation, containing the compact unit information.
Task GetOneCompact(ObjectId id);
// Task GetByCodeSysAndCode(string unit);
///
/// Asynchronously retrieves a by its name.
///
/// The name of the unit to look up.
/// A task that represents the asynchronous operation. The task result contains the matching if found; otherwise, null.
Task GetByName(string unit);
// Task GetByPointOfCare(PointOfCare pointOfCare);
///
/// Retrieves information for a unit identified by the specified , returning when no matching unit is found.
///
/// The unique identifier of the unit to look up.
/// Optional locale used to localize the returned unit data.
/// When , populates the related lists on the returned unit.
/// When , includes the unit's points of contact in the result.
/// A task that yields the located , or if no unit matches the given id.
Task GetInfo(ObjectId id, LocaleEnum? dataLocale, bool fillLists = true, bool withPoCs = false);
///
/// Retrieves information about a unit identified by the specified , optionally including related points of contact and devices.
///
/// The identifier of the unit to retrieve information for.
/// Indicates whether related points of contact should be included in the result. Defaults to true.
/// Indicates whether related devices should be included in the result. Defaults to true.
/// A task that represents the asynchronous operation. The task result contains the Unit if found, or null if no unit matches the specified identifier.
Task GetInfo(ObjectId id, bool withPoCs = true, bool withDevices = true);
///
/// Asynchronously retrieves the unit associated with the specified patient identifier, returning null when no matching unit exists.
///
/// The unique identifier of the patient whose unit is being looked up.
/// A task that represents the asynchronous lookup, containing the matching if found, or null if no unit is associated with the patient.
Task FindByPatientId(ObjectId patientId);
// Task?> FindByLocation(PatientLocation location);
///
/// Asynchronously finds and returns a matching the specified identifier.
///
/// The unique identifier of the to retrieve. May be null.
/// A task that represents the asynchronous operation. The task result contains the if found; otherwise, null.
Task FindById(ObjectId? id);
///
/// Asynchronously retrieves a entity matching the specified name.
///
/// The name used to look up the unit. Can be null.
/// A task that resolves to the matching if found; otherwise, null.
Task FindByName(string? name);
///
/// Asynchronously retrieves a by matching either its unit name or point-of-contact (POC) name.
/// Returns null if no matching unit is found.
///
/// The unit name to search for. May be null.
/// The point-of-contact (POC) name to search for. May be null.
/// A containing the matched , or null if no unit is found.
Task FindByUnitNameOrPocName(string? name, string? pocName);
//Task FindByPointOfCare(PointOfCare pointOfCare);
///
/// Inserts a single into the underlying data store and returns the resulting entity wrapped in a task.
///
/// The instance to be inserted.
/// A task that resolves to the inserted , or null if the insertion did not produce a result.
Task InsertOne(Unit unit);
///
/// Updates the specified unit in the system.
///
/// The unit containing the updated information to persist.
/// A task that returns the updated , or null if the unit was not found.
Task UpdateUnit(Unit unit);
///
/// Asynchronously retrieves the collection of units associated with the specified master list identifier and master list type.
/// Returns null when no matching units are found.
///
/// The unique identifier of the master list whose units should be retrieved.
/// The type of the master list used to scope the unit lookup.
/// A task that returns an of when matches exist, or null when no matching units are found.
Task?> FindUnitsByMasterListId(ObjectId masterListId, MasterListType masterListType);
///
/// Asynchronously counts the number of units associated with the specified master list, filtered by the given master list type.
///
/// The unique identifier of the master list whose units should be counted.
/// The type of the master list used to scope the count to the appropriate unit category.
/// A that represents the asynchronous operation, containing the total number of units matching the specified master list.
Task CountUnitsByMasterListId(ObjectId masterListId, MasterListType masterListType);
///
/// Asynchronously retrieves the collection of units associated with the specified master list identifier.
///
/// The identifier of the master list whose units are to be retrieved.
/// A task that represents the asynchronous operation, containing the collection of units that belong to the specified master list.
Task> FindUnitsByMasterListId(ObjectId masterListId);
///
/// Updates the unit master list based on the provided unit ID list DTO.
///
/// The DTO containing the list of unit IDs to be used for updating the master list.
/// A task that represents the asynchronous operation. The task result contains the updated , or null if the update was not applicable.
Task UpdateUnitMasterList(UpdateUnitIdListDto updateUnitListDto);
///
/// Asynchronously updates the configuration for the specified unit using the provided configuration data.
///
/// The parsed identifier of the unit whose configuration will be updated.
/// The new configuration values to apply to the unit.
/// A task that resolves to true if the configuration was successfully updated; otherwise, false.
Task UpdateConfiguration(ObjectId unitIdParsed, UnitConfiguration unitConfiguration);
///
/// Asynchronously deletes a unit identified by the provided entity's identifier.
///
/// The unit entity whose identifier is used to locate and delete the record.
/// A that represents the asynchronous operation, containing a value indicating whether the unit was successfully deleted.
Task DeleteUnitById(Unit unit);
///
/// Updates the information of an existing unit identified by , including its name, title, and optionally its configuration object ID.
/// Returns the updated unit, or null when no matching unit is found.
///
/// The identifier of the unit to update.
/// The new name to assign to the unit.
/// The new title to assign to the unit.
/// An optional configuration object ID to associate with the unit.
/// A task that yields the updated , or null if the unit does not exist.
Task UpdateUnitInfo(ObjectId unitId, string name, string title, string? configObsId = null);
///
/// Retrieves a paginated list of units based on the provided filter, optionally including their associated points of contact.
///
/// The pagination filter that defines the page size, page number, and any additional query criteria.
/// A flag indicating whether the response should include the points of contact associated with each unit.
/// A task that represents the asynchronous operation, containing the paginated response of units.
Task> GetPaginatedUnits(PaginationFilter filter, bool withPoCs);
}