Files
adas-core/adas-core.Domain/Models/PatientDiagnosis.cs
T
2026-06-26 10:29:23 +02:00

78 lines
2.5 KiB
C#

using MongoDB.Bson;
namespace adas_core.Domain.Models;
/// <summary>
/// Represents a diagnosis associated with a patient, encapsulating the relevant diagnostic information.
/// </summary>
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;
}
/// <summary>
/// Returns a string representation of the <see cref="PatientDiagnosis"/> 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.
/// </summary>
/// <returns>A formatted string in the form <c>PatientDiagnosis[field1: value1, field2: value2, ...]</c>
/// containing the diagnosis data; optional fields are omitted when null or empty.</returns>
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) + "]";
}
}