rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
@@ -13,6 +13,12 @@ public class ObservationDemoService(
Lazy<IAlarmService> alarmService)
: IObservationDemoService
{
/// <summary>
/// Generates a list of patient observation alarms based on the provided alarm fields, randomly skipping fields and skipping those with no matching configuration.
/// </summary>
/// <param name="patient">The patient to associate with the generated alarms.</param>
/// <param name="dataAlarmfields">The list of fields used to look up alarm configurations and produce alarms.</param>
/// <returns>A task that represents the asynchronous operation, containing the list of mapped <see cref="PatientObservationAlarm"/> instances that were successfully resolved.</returns>
public async Task<List<PatientObservationAlarm>> GenerateAlarmByField(Patient patient, List<Field> dataAlarmfields)
{
var listToReturn = new List<PatientObservationAlarm>();
@@ -35,7 +41,8 @@ public class ObservationDemoService(
AlarmConfig = conf.Alarm,
InactivationState = new InactivationState
{
Audio = AlarmEnum.AudioVideoState.Enabled, Acknowledge = true,
Audio = AlarmEnum.AudioVideoState.Enabled,
Acknowledge = true,
Visual = AlarmEnum.AudioVideoState.Enabled
},
EventPhase = AlarmEnum.EventPhase.Continue,
@@ -67,6 +74,12 @@ public class ObservationDemoService(
return listToReturn;
}
/// <summary>
/// Generates a list of patient observations for the specified patient based on the provided data fields, using the corresponding configuration items to populate observation values, thresholds, and metadata. Fields without a name or without a matching configuration are skipped. When a configuration includes demo settings, the resulting observation is adjusted with a randomized initial date and, if required, an end time.
/// </summary>
/// <param name="patient">The patient to associate the generated observations with.</param>
/// <param name="dataFields">The list of fields used to look up observation configurations and drive observation generation.</param>
/// <returns>A task that returns the list of generated <see cref="PatientObservation"/> instances; entries are omitted when no configuration is found for a field.</returns>
public async Task<List<PatientObservation>> GenerateObservationByField(Patient patient, List<Field> dataFields)
{
var listToReturn = new List<PatientObservation>();
@@ -135,6 +148,12 @@ public class ObservationDemoService(
return listToReturn;
}
/// <summary>
/// Generates a <see cref="GroupedObservation"/> for the given patient and grouped field, producing time-spaced observations for each configured name and result type based on the field's regularity.
/// </summary>
/// <param name="patient">The patient to associate the generated grouped observation with.</param>
/// <param name="groupedField">The grouped field configuration that defines the names, results, regularity, and maximum number of observations to generate.</param>
/// <returns>A task that returns the populated <see cref="GroupedObservation"/> containing the generated observations.</returns>
public async Task<GroupedObservation> GenerateGroupedObservation(Patient patient, GroupedField groupedField)
{
if (groupedField.Names.IsNullOrEmpty() && groupedField.Name != null) groupedField.Names.Add(groupedField.Name);
@@ -203,6 +222,12 @@ public class ObservationDemoService(
return go;
}
/// <summary>
/// Generates a random value (or list of values) for a given configuration, falling back to "-" when no configuration is available. When the configuration specifies an array, produces multiple random values using the configured count; otherwise returns a single random value.
/// </summary>
/// <param name="firstCof">The configuration observation whose <c>DemoConfig</c> drives the value generation. If null or its <c>DemoConfig</c> is null, the method returns "-".</param>
/// <param name="prevValue">The previous value, passed through to <c>PickSingleValue</c> as context for the new random value generation.</param>
/// <returns>A list of generated values when the configuration indicates an array, or a single generated value otherwise. Null is returned when no value could be picked.</returns>
private static object? GenerateValueRandom(ConfigObservation? firstCof, object? prevValue)
{
if (firstCof?.DemoConfig == null)
@@ -223,6 +248,12 @@ public class ObservationDemoService(
return firstCof.DemoConfig?.ValueIsArray == true ? results : results.FirstOrDefault();
}
/// <summary>
/// Picks a single value from a <see cref="DemoConfig"/> following a defined priority: first selects randomly from a predefined list of options when <c>SetInValue</c> is enabled, otherwise generates a random numeric value within the configured range, optionally applying a percentage-based variation to a previous value. Returns <c>null</c> if the configuration is null, if the options list is empty, or if random value generation is disabled.
/// </summary>
/// <param name="config">The configuration that defines how the value should be selected, including the list of options, the numeric range, and the selection mode.</param>
/// <param name="prevValue">The previously selected value, used as the base for percentage-based variation when generating a new numeric value; ignored when no previous integer value is available.</param>
/// <returns>A randomly selected value from the configured options or a generated numeric value clamped within the defined range; <c>null</c> when the configuration does not allow a value to be produced.</returns>
private static object? PickSingleValue(DemoConfig? config, object? prevValue)
{
if (config == null) return null;