using System.Text.Json.Serialization;
using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;

namespace adas_core.Domain.Models.DTO;

/// <summary>
/// Represents a data transfer object that encapsulates information about a unit.
/// </summary>
/// <!-- aidoc:v1 sig=6fcba76 -->
public class UnitInfoDto
{
    /// <summary>
    /// Initializes a new instance of the <see cref="UnitInfoDto"/> data transfer object, enabling JSON deserialization via the <see cref="JsonConstructorAttribute"/>.
    /// </summary>
    /// <!-- aidoc:v1 sig=e9065d4 body=4448e1d -->
    [JsonConstructor]
    public UnitInfoDto()
    {
    }

    /// <summary>
    /// Initializes a new instance of <see cref="UnitInfoDto"/> from the supplied <paramref name="unit"/>,
    /// projecting its identifier and name into the DTO with safe empty-string defaults for the display fields.
    /// </summary>
    /// <param name="unit">The optional <see cref="Unit"/> whose values populate the DTO; when null, the string properties default to <see cref="string.Empty"/>.</param>
    /// <!-- aidoc:v1 sig=98aa992 body=1d6ed29 -->
    public UnitInfoDto(Unit? unit)
    {
        Id = unit?.Id;
        Name = unit?.Name ?? string.Empty;
        Title = unit?.Name ?? string.Empty;
    }

    public ObjectId? Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public string? ConfigObservationId { get; set; }
    public long? Admissions { get; set; }
    public long? Discharges { get; set; }
    public long? Displays { get; set; }
    public long? Patients { get; set; }
    public long? PointOfCares { get; set; }
    public long? VirtualPointOfCares { get; set; }
}