using MongoDB.Bson;

namespace adas_core.Domain.Models;

public class PatientDiagnosis
{
    public ObjectId Id { get; set; }

    public ObjectId PatientId { get; set; }

    public DateTime Time { get; set; }

    public DateTime? UpdateDate { get; set; }

    //MSH Time of HL7
    public DateTime MessageTime { get; set; }

    public string? CodingSystem { get; set; }

    public string? Description { get; set; }

    public string? Label { get; set; }

    public string? Code { get; set; }

    public string? State { get; set; }

    public string? Category { get; set; }

    public DateTime? StartTime { get; set; }

    public DateTime? EndTime { get; set; }

    //Deprecated
    public string? DiagnosisCode
    {
        get => Code;
        set => Code = value;
    }

    //Deprecated
    public string? DiagnosisSystem
    {
        get => CodingSystem;
        set => CodingSystem = value;
    }

    public override string ToString()
    {
        List<string> items =
        [
            $"id: {Id}",
            $"time: {Time}",
            $"patientid: {PatientId}"
        ];
        if (!string.IsNullOrEmpty(CodingSystem)) items.Add($"label: {CodingSystem}");
        if (!string.IsNullOrEmpty(Label)) items.Add($"label: {Label}");
        if (!string.IsNullOrEmpty(Code)) items.Add($"diagnosisCode: {Code}");
        if (!string.IsNullOrEmpty(State)) items.Add($"state: {State}");
        if (!string.IsNullOrEmpty(Category)) items.Add($"category: {Category}");
        items.Add($"messageTime: {MessageTime}");
        items.Add($"startTime: {StartTime}");
        items.Add($"startTime: {StartTime}");
        items.Add($"endTime: {EndTime}");

        return "PatientDiagnosis[" + string.Join(", ", items) + "]";
    }
}