using MongoDB.Bson;
namespace adas_core.Domain.Models;
///
/// Represents a diagnosis associated with a patient, encapsulating the relevant diagnostic information.
///
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;
}
///
/// Returns a string representation of the instance, including its core fields
/// (id, time, patientId, messageTime, startTime, endTime) and conditionally appending optional properties
/// (codingSystem, label, code, state, category) only when they have non-empty values.
///
/// A formatted string in the form PatientDiagnosis[field1: value1, field2: value2, ...]
/// containing the diagnosis data; optional fields are omitted when null or empty.
public override string ToString()
{
List 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) + "]";
}
}