namespace adas_core.Domain.Models;
///
/// Represents a historical location and provides type-safe equality comparison between instances of .
///
///
/// Implements of to allow instances to be compared for value equality without relying on object identity.
///
public class HistoricalLocation : IEquatable
{
// Propiedades con get y set para que MongoDB pueda escribir en ellas
public DateTime? AdmTime { get; set; }
public PatientLocation? PatientLocation { get; set; }
// Constructor vacío necesario para la deserialización de MongoDB
///
/// Initializes a new instance of the class, which represents a historical record of a location.
///
public HistoricalLocation() { }
// Tu constructor actual
public HistoricalLocation(DateTime admTime, PatientLocation patientLocation)
{
AdmTime = admTime;
PatientLocation = patientLocation ?? throw new ArgumentNullException(nameof(patientLocation));
}
///
/// Determines whether the current instance is equal to another instance,
/// based on the admission time and the patient location (when present, with null locations treated as equal).
///
/// The other instance to compare with this one.
/// true if both the admission time and patient location match; otherwise, false.
public bool Equals(HistoricalLocation? other)
{
if (other == null) return false;
return AdmTime == other.AdmTime &&
(PatientLocation?.Equals(other.PatientLocation) ?? other.PatientLocation == null);
}
///
/// Determines whether this instance is considered empty by verifying that no admission time is set and that the patient location is either null or empty.
///
/// when AdmTime has no value and PatientLocation is or empty; otherwise, .
public bool IsEmpty() => !AdmTime.HasValue && (PatientLocation == null || PatientLocation.IsEmpty());
///
/// Determines whether the instance is in a full state by verifying that an admission time has been set, a patient location is assigned, and the assigned location is not full or empty.
///
/// true when has a value, is not null, and the location is not full or empty; otherwise, false.
public bool IsFull() => AdmTime.HasValue && PatientLocation != null && !PatientLocation.IsFullEmpty();
///
/// Returns a string representation of the HistoricalLocation, including the admission time and patient location.
///
/// A formatted string with the values of AdmTime and PatientLocation.
public override string ToString() => $"HistoricalLocation[AdmTime: {AdmTime}, PatientLocation: {PatientLocation}]";
}