Files
adas-core/adas-core.Domain/Models/Observations/DoubleObservation.cs
T

35 lines
1.5 KiB
C#

using adas_core.Domain.Utils;
namespace adas_core.Domain.Models.Observations;
/// <summary>
/// Represents an observation that captures a double-precision floating-point measurement or value.
/// Inherits from the base <see cref="Observation"/> type, providing a specialized observation variant for numeric data of type <see cref="double"/>.
/// </summary>
/// <!-- aidoc:v1 sig=bb4c3dc -->
public class DoubleObservation : Observation
{
public double? Value { get; set; }
public double? LastValue { get; set; }
/// <summary>
/// Creates a <see cref="DoubleObservation"/> from a list of <see cref="PatientObservation"/> instances, using the first element's value as the primary <c>Value</c> and the second element's value as the <c>LastValue</c> when available.
/// </summary>
/// <param name="obs">The list of patient observations to convert. At least one element is required to produce a result.</param>
/// <returns>A <see cref="DoubleObservation"/> populated with the converted double values, or <c>null</c> if the list is empty.</returns>
/// <!-- aidoc:v1 sig=0b5761e body=41f15e7 -->
public static DoubleObservation? From(List<PatientObservation> obs)
{
if (obs.Count > 0)
{
var val = new DoubleObservation
{
Value = obs[0].Value.ToDouble()
};
if (obs.Count > 1) val.LastValue = obs[1].Value.ToDouble();
return val;
}
return null;
}
}