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

84 lines
3.4 KiB
C#

namespace adas_core.Domain.Models;
/// <summary>
/// Represents the location of a patient within a healthcare or clinical context.
/// Implements <see cref="IEquatable{PatientLocation}"/> to provide type-specific equality comparison between patient location instances.
/// </summary>
public class PatientLocation : IEquatable<PatientLocation>
{
public PatientLocation(string? unitName, string? bed, string? room)
{
UnitName = unitName;
Bed = bed;
Room = room;
}
public PatientLocation(string? unitName, string? bed)
{
UnitName = unitName;
Bed = bed;
Room = bed;
}
public PatientLocation()
{
// Constructor vacío
}
public string? UnitName { get; init; }
public string? Bed { get; set; }
public string? Room { get; init; }
/// <summary>
/// Determines whether the specified <see cref="PatientLocation"/> is equal to the current instance by comparing the <c>UnitName</c>, <c>Bed</c>, and <c>Room</c> properties.
/// </summary>
/// <param name="other">The <see cref="PatientLocation"/> to compare with the current instance.</param>
/// <returns><see langword="true"/> when all three properties (<c>UnitName</c>, <c>Bed</c>, and <c>Room</c>) match; otherwise, <see langword="false"/>. Returns <see langword="false"/> if <paramref name="other"/> is <see langword="null"/>.</returns>
public bool Equals(PatientLocation? other)
{
return UnitName == other?.UnitName && Bed == other?.Bed && Room == other?.Room;
}
/// <summary>
/// Determines whether the current instance is considered empty by checking that both the <see cref="UnitName"/> and <see cref="Bed"/> values are null or empty strings.
/// </summary>
/// <returns><see langword="true"/> if both <c>UnitName</c> and <c>Bed</c> are null or empty; otherwise, <see langword="false"/>.</returns>
public bool IsEmpty()
{
return string.IsNullOrEmpty(UnitName) && string.IsNullOrEmpty(Bed);
}
/// <summary>
/// Determines whether the unit name, bed, and room fields are all null or empty, indicating the entity is fully empty.
/// </summary>
/// <returns><c>true</c> if <see cref="UnitName"/>, <see cref="Bed"/>, and <see cref="Room"/> are all null or empty; otherwise, <c>false</c>.</returns>
public bool IsFullEmpty()
{
return string.IsNullOrEmpty(UnitName) && string.IsNullOrEmpty(Bed) && string.IsNullOrEmpty(Room);
}
/// <summary>
/// Returns a human-readable string representation of the PatientLocation, including the unit name, room, and bed.
/// </summary>
/// <returns>A formatted string in the form "PatientLocation[Unit: {UnitName},room: {Room} ,bed: {Bed}]".</returns>
public override string ToString()
{
return "PatientLocation[Unit: " + UnitName + ",room: " + Room + " ,bed: " + Bed + "]";
}
//public override bool Equals(object? obj)
//{
// return obj is PatientLocation objPl && Equals(objPl);
//}
//public override int GetHashCode()
//{
// var hashCode = 511378865;
// if (UnitName != null)
// hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(UnitName);
// // ReSharper disable once NonReadonlyMemberInGetHashCode
// if (Bed != null) hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Bed);
// return hashCode;
//}
}