using adas_core.Domain.Models;
using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;

namespace adas_core.Application.Services.Interfaces;

public interface IDiagnosisService : IApiRequestService
{
    /// <summary>
    /// Retrieves all diagnoses associated with the specified patient identifier.
    /// </summary>
    /// <param name="patientId">The unique identifier of the patient whose diagnoses are being retrieved.</param>
    /// <returns>A task representing the asynchronous operation, containing a list of <see cref="PatientDiagnosis"/> records for the specified patient; an empty list is returned if no diagnoses are found.</returns>
    Task<List<PatientDiagnosis>> GetByPatientId(ObjectId patientId);
    /// <summary>
    /// Deletes records associated with the specified patient identifier.
    /// </summary>
    /// <param name="id">The unique identifier of the patient whose related records should be removed.</param>
    Task DeleteByPatientId(ObjectId id);
    /// <summary>
    /// Asynchronously archives the specified patient, marking the patient record as archived rather than permanently deleting it.
    /// </summary>
    /// <param name="patient">The patient to archive.</param>
    Task Archive(Patient patient);
    /// <summary>
    /// Archives the records associated with the specified patient identifier.
    /// </summary>
    /// <param name="id">The unique identifier of the patient whose records will be archived.</param>
    Task ArchiveByPatientId(ObjectId id);
    /// <summary>
    /// Processes a diagnosis observation for the specified patient based on the supplied API request data.
    /// </summary>
    /// <param name="apiRequest">The API request containing the diagnosis observation payload and contextual information to process.</param>
    /// <param name="patient">The patient to whom the diagnosis observation pertains.</param>
    Task ProcessDiagnosisObservation(ApiRequest apiRequest, Patient patient);
    /// <summary>
    /// Persists the specified API request along with its associated patient data.
    /// </summary>
    /// <param name="apiRequest">The API request to be saved.</param>
    /// <param name="patient">The patient associated with the API request.</param>
    Task SaveRequest(ApiRequest apiRequest, Patient patient);
    /// <summary>
    /// Processes the provided list of patient diagnoses for the specified patient at the given message time.
    /// </summary>
    /// <param name="diagnosis">The list of patient diagnoses to be processed.</param>
    /// <param name="patient">The patient associated with the diagnoses.</param>
    /// <param name="messageTime">The timestamp of the message triggering the diagnosis processing.</param>
    Task ProcessDiagnosis(List<PatientDiagnosis> diagnosis, Patient patient, DateTime messageTime);
    /// <summary>
    /// Updates multiple records by replacing the <paramref name="oldId"/> with the new <paramref name="id"/> in the field identified by <paramref name="nameId"/>.
    /// </summary>
    /// <param name="nameId">The identifier of the field or property whose ObjectId values will be updated.</param>
    /// <param name="id">The new ObjectId value to assign to the matching records.</param>
    /// <param name="oldId">The existing ObjectId value to be replaced in the matching records.</param>
    Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId);
}