rama creada apartir de master en j
This commit is contained in:
@@ -20,11 +20,15 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient;
|
||||
|
||||
namespace adas_core.Application.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Provides the concrete implementation of the <see cref="IObservationService"/> contract,
|
||||
/// encapsulating the business logic required to manage and expose observation-related operations.
|
||||
/// </summary>
|
||||
public class ObservationService : IObservationService
|
||||
{
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly CacheSettings? _cacheSettings;
|
||||
|
||||
|
||||
private readonly IAlarmService _alarmService;
|
||||
private readonly List<string> _allergies;
|
||||
private readonly ILocalAuditService _auditService;
|
||||
@@ -91,7 +95,7 @@ public class ObservationService : IObservationService
|
||||
Lazy<ICalculatedObservationsService> calculatedObservationsService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILocalAuditService auditService,
|
||||
IPointOfCareService pointOfCareService,
|
||||
IPointOfCareService pointOfCareService,
|
||||
ICacheService cacheService
|
||||
)
|
||||
|
||||
@@ -129,21 +133,35 @@ public class ObservationService : IObservationService
|
||||
_subscriberGroupedService = subscriberGroupedService;
|
||||
_calculatedObservationsService = calculatedObservationsService;
|
||||
_pointOfCareService = pointOfCareService;
|
||||
_cacheSettings = cacheSettings.Value;
|
||||
_cacheSettings = cacheSettings.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent observations for a specified patient by delegating to the observation repository's aggregation pipeline.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="num">The maximum number of recent observations to return. Defaults to 2.</param>
|
||||
/// <param name="filterObservations">An optional list of observation codes/names used to narrow down which observations are considered.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of the patient's most recent <see cref="PatientObservation"/> entries.</returns>
|
||||
public async Task<List<PatientObservation>> FindLastObservations(ObjectId patientId, int num = 2,
|
||||
List<string>? filterObservations = null)
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
var result =
|
||||
await _observationRepository.AggregatedPatientLastObservations(patientId, num, filterObservations);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent aggregated patient observations, using a cache-aside pattern to avoid recomputing results within the configured TTL. Field names in <paramref name="filterObservations"/> are normalized (null or whitespace names are dropped) before being used to compute the cache key.
|
||||
/// </summary>
|
||||
/// <param name="patientId">Identifier of the patient whose latest observations are being requested.</param>
|
||||
/// <param name="filterObservations">Optional list of fields to filter the aggregated observations by; entries with null or whitespace names are ignored when building the cache key. When null, an empty field set is used.</param>
|
||||
/// <param name="ct">Cancellation token forwarded to the cache and repository operations.</param>
|
||||
/// <returns>A task containing the list of <see cref="PatientObservation"/> values, either served from cache or freshly aggregated from the repository on a cache miss.</returns>
|
||||
private async Task<List<PatientObservation>> AggregatedLastObsCached(
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations,
|
||||
CancellationToken ct = default)
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
// Normalizar campos
|
||||
var fieldNames = (filterObservations ?? new())
|
||||
@@ -173,11 +191,20 @@ public class ObservationService : IObservationService
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent observations for a patient from the aggregated cache, optionally filtered by specific fields, and optionally enriched through a name-based mapping.
|
||||
/// When <paramref name="mapped"/> is <c>false</c>, the raw cached observations are returned directly; otherwise each observation is individually mapped and those that yield no result are excluded from the output.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The identifier of the patient whose latest observations are being queried.</param>
|
||||
/// <param name="filterObservations">Optional list of fields used to restrict which observations are retrieved from the cache.</param>
|
||||
/// <param name="mapped">When <c>true</c> (default), applies a name-based mapping to each observation; when <c>false</c>, returns the raw results as they come from the cache.</param>
|
||||
/// <param name="ct">Cancellation token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task containing the list of patient observations, either as raw cached entries or as mapped values depending on <paramref name="mapped"/>.</returns>
|
||||
public async Task<List<PatientObservation>> FindLastObservationsByField(
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations = null,
|
||||
bool mapped = true,
|
||||
CancellationToken ct = default)
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations = null,
|
||||
bool mapped = true,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
//lista RAW desde la caché
|
||||
var raw = await AggregatedLastObsCached(patientId, filterObservations, ct);
|
||||
@@ -197,11 +224,22 @@ public class ObservationService : IObservationService
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the specified patient observation by name by delegating to the configuration observation service using the by-name mapping mode.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation to be mapped.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the mapped <see cref="PatientObservation"/>, or null if no matching mapping is found.</returns>
|
||||
public async Task<PatientObservation?> MapObservationsByName(PatientObservation obs)
|
||||
{
|
||||
return await _configObservationService.Map(obs, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a <see cref="PatientObservation"/> through a sequence of configuration, units, and calculated observations services to produce a fully mapped observation, returning <c>null</c> if any mapping step yields no result or if an error occurs.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation to be mapped.</param>
|
||||
/// <param name="onlyByName">When <c>true</c>, restricts the mapping to name-based lookups only.</param>
|
||||
/// <returns>A task containing the mapped <see cref="PatientObservation"/>, or <c>null</c> if the observation is ignored, not found, or an exception is raised during processing.</returns>
|
||||
public async Task<PatientObservation?> MapObservation(PatientObservation obs, bool onlyByName = false)
|
||||
{
|
||||
try
|
||||
@@ -297,6 +335,13 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a nurse observation by mapping it, persisting it via the observation repository,
|
||||
/// updating the latest-observations cache, broadcasting the change, and creating an audit log entry.
|
||||
/// If mapping returns a null result or an observation with a null name, the method logs the error and returns without inserting.
|
||||
/// Any exception thrown during the operation is caught and logged.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation provided by the nurse to be mapped, persisted, cached, broadcast, and audited.</param>
|
||||
public async Task InsertNurseObservation(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -311,13 +356,13 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
await _observationRepository.InsertOneAsync(obs2);
|
||||
|
||||
|
||||
var (key, ttl) = CacheKeys.LatestObservationsKeyWithTtl(
|
||||
_cacheSettings,
|
||||
obs2.PatientId,
|
||||
[obs2.Name]
|
||||
);
|
||||
|
||||
|
||||
// GET → MISS → LOCK → AGGREGATE → SET
|
||||
var result = _cacheService.GetOrSetObjectAsync(
|
||||
key,
|
||||
@@ -326,7 +371,7 @@ public class ObservationService : IObservationService
|
||||
return obs2;
|
||||
},
|
||||
ttl, default);
|
||||
|
||||
|
||||
_ = SendObsBroadcast(obs2);
|
||||
await _auditService.CreateAuditLogAsync(_httpContextAccessor.HttpContext?.User!, null, obs2);
|
||||
}
|
||||
@@ -336,8 +381,16 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new patient observation only when its value differs from the most recent observation recorded for the same observation name; otherwise the existing record is kept and no insertion is performed.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the observation used to look up the latest existing value for the patient.</param>
|
||||
/// <param name="observation">The patient observation to compare against the most recent value and to insert when a change is detected.</param>
|
||||
/// <param name="persistObs">Indicates whether the new observation should be persisted when inserted.</param>
|
||||
/// <param name="mapObs">Indicates whether the new observation should be mapped when inserted.</param>
|
||||
/// <returns>A task that resolves to <c>true</c> if the observation was inserted because the value changed, or <c>false</c> if the most recent observation already has the same value and no insertion was made.</returns>
|
||||
public async Task<bool> InsertIfChanged(string name, PatientObservation observation, bool persistObs = true,
|
||||
bool mapObs = true)
|
||||
bool mapObs = true)
|
||||
{
|
||||
var changedList = await FindLastObservations(observation.PatientId, 1, [name]);
|
||||
var changed = changedList.All(o => observation.Value != o.Value);
|
||||
@@ -349,6 +402,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Broadcasts a list of patient observations to all display subscribers whose registered locations match the specified patient location by unit name, bed, and room. Subscribers without any registered locations are excluded from the broadcast.
|
||||
/// </summary>
|
||||
/// <param name="obsList">The list of patient observations to send to matching subscribers.</param>
|
||||
/// <param name="location">The patient location used to identify subscribers to notify.</param>
|
||||
public Task SendObsBroadcast(List<PatientObservation> obsList, PatientLocation location)
|
||||
{
|
||||
// Display Subscription
|
||||
@@ -361,12 +419,18 @@ public class ObservationService : IObservationService
|
||||
|
||||
|
||||
foreach (var subscriber in displaySubscribers)
|
||||
foreach (var obs in obsList)
|
||||
_ = _clientMessageService.SendAsync(subscriber.Id, OperationType.Observation, obs);
|
||||
foreach (var obs in obsList)
|
||||
_ = _clientMessageService.SendAsync(subscriber.Id, OperationType.Observation, obs);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcasts a list of patient observations to all display subscribers whose location identifiers match the specified point of care identifier.
|
||||
/// Subscribers with null or empty location identifiers are excluded, and each observation is dispatched asynchronously to every matching subscriber.
|
||||
/// </summary>
|
||||
/// <param name="obsList">The collection of patient observations to be sent to the matched subscribers.</param>
|
||||
/// <param name="pocId">The point of care identifier used to filter the subscribers by their configured location identifiers.</param>
|
||||
public Task SendObsBroadcast(List<PatientObservation> obsList, ObjectId pocId)
|
||||
{
|
||||
// Display Subscription
|
||||
@@ -377,12 +441,17 @@ public class ObservationService : IObservationService
|
||||
|
||||
|
||||
foreach (var subscriber in displaySubscribers)
|
||||
foreach (var obs in obsList)
|
||||
_ = _clientMessageService.SendAsync(subscriber.Id, OperationType.Observation, obs);
|
||||
foreach (var obs in obsList)
|
||||
_ = _clientMessageService.SendAsync(subscriber.Id, OperationType.Observation, obs);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcasts a patient observation to all display subscribers whose location matches the patient's point of care.
|
||||
/// The method skips the broadcast if the observation has no name, and falls back to looking up the patient by id when it is not included in the observation.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation to broadcast. May include the patient or require a lookup via <see cref="BasePatientObservation.PatientId"/>.</param>
|
||||
public async Task SendObsBroadcast(BasePatientObservation obs)
|
||||
{
|
||||
if (obs.Name == null) return;
|
||||
@@ -409,8 +478,18 @@ public class ObservationService : IObservationService
|
||||
_ = _clientMessageService.SendAsync(subscriber.Id, OperationType.Observation, obs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a batch of patient observations by attaching patient, parent data, and message metadata,
|
||||
/// then persists them asynchronously through the calculated observations mapping service. Missing
|
||||
/// observation or message timestamps default to <see cref="DateTime.UtcNow"/>, and any errors during
|
||||
/// processing are logged without being rethrown.
|
||||
/// </summary>
|
||||
/// <param name="observations">The list of patient observations to be processed and inserted.</param>
|
||||
/// <param name="patient">The patient to whom the observations belong.</param>
|
||||
/// <param name="messageTime">The timestamp associated with the source message.</param>
|
||||
/// <param name="observationData">Optional parent observation metadata used to populate the parent data of each observation.</param>
|
||||
public async void ProcessObservations(List<PatientObservation> observations, Patient patient,
|
||||
DateTime messageTime, ObservationData? observationData = null)
|
||||
DateTime messageTime, ObservationData? observationData = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -464,11 +543,25 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously saves nurse observations from the provided API request by executing the save operation on a background thread.
|
||||
/// </summary>
|
||||
/// <param name="request">The API request containing the nurse observation data to be persisted.</param>
|
||||
/// <returns>A task that represents the asynchronous nurse observation save operation.</returns>
|
||||
public Task SaveRequestNurseObsAsync(ApiRequest request)
|
||||
{
|
||||
return Task.Run(() => SaveRequestNurseObs(request));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes and persists an inbound medical API request (HL7), routing <c>ORU_R40</c> alerts to the alarm service
|
||||
/// and <c>ORU_R01</c> observations to the appropriate handler (intravenous lines, allergies, drainage, isolation,
|
||||
/// position, diagnosis, or generic observations) based on the observation code. Throws when both patient and
|
||||
/// location are missing or when the request type is not supported, and silently returns when no matching patient
|
||||
/// is found.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The incoming API request containing patient/location identifiers, message type, and observation data.</param>
|
||||
/// <exception cref="ApiRequestException">Thrown when both the patient number and location are null or empty, or when the request type is not valid for observations.</exception>
|
||||
public async Task SaveRequest(ApiRequest apiRequest)
|
||||
{
|
||||
if (
|
||||
@@ -563,6 +656,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously saves the provided API request by executing the save operation on a background thread.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request to be saved.</param>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
public Task SaveRequestAsync(ApiRequest apiRequest)
|
||||
{
|
||||
//return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest); }));
|
||||
@@ -570,17 +668,35 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all <see cref="PatientObservation"/> records associated with the specified patient by delegating to the observation repository.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <returns>An <see cref="IAsyncCursor{PatientObservation}"/> that iterates over the matching patient observations.</returns>
|
||||
public async Task<IAsyncCursor<PatientObservation>> FindByPatientIdAsync(ObjectId patientId)
|
||||
{
|
||||
return await _observationRepository.FindByPatientIdAsync(patientId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves patient observations filtered by the specified patient identifier, coding system, and name.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="codingSystem">The coding system used to classify the observations.</param>
|
||||
/// <param name="name">The name associated with the observations to filter by.</param>
|
||||
/// <returns>An asynchronous cursor over the matching <see cref="PatientObservation"/> documents.</returns>
|
||||
public async Task<IAsyncCursor<PatientObservation>> FindByPatientIdAndCodingSystemAsync(ObjectId patientId,
|
||||
string codingSystem, string name)
|
||||
string codingSystem, string name)
|
||||
{
|
||||
return await _observationRepository.FindByPatientIdAndCodingSystemAsync(patientId, codingSystem, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all observations associated with the specified patient identifier, clears the related cache entries, and records an audit log.
|
||||
/// If no observations exist for the given patient, the method returns without performing any deletion, cache invalidation, or audit logging.
|
||||
/// Any exception encountered during the process is logged and swallowed without being rethrown.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient whose observations should be deleted.</param>
|
||||
public async Task DeleteByPatientId(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -594,7 +710,7 @@ public class ObservationService : IObservationService
|
||||
await _observationRepository.DeleteByPatientId(id);
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeyPatterns.ByPatient("patients:latestObs", id.ToString()));
|
||||
|
||||
|
||||
await _auditService.CreateAuditLogAsync(_httpContextAccessor.HttpContext?.User!, deletedObservationList,
|
||||
null);
|
||||
}
|
||||
@@ -604,6 +720,10 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Archives a patient observation by persisting it to the archive repository, removing it from the active observations, and invalidating the related cache entries for the patient's latest observations.
|
||||
/// </summary>
|
||||
/// <param name="observation">The patient observation to be archived.</param>
|
||||
public async Task Archive(PatientObservation observation)
|
||||
{
|
||||
await _observationArchiveRepository.InsertOneAsync(observation);
|
||||
@@ -612,11 +732,19 @@ public class ObservationService : IObservationService
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified patient by delegating to the archive operation keyed by the patient's identifier.
|
||||
/// </summary>
|
||||
/// <param name="patient">The patient to be archived. Its identifier is used to locate and archive the corresponding record.</param>
|
||||
public async Task Archive(Patient patient)
|
||||
{
|
||||
await ArchiveByPatientId(patient.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Archives all observations associated with the specified patient by copying them into the archive repository with newly generated identifiers, then removes the originals and invalidates the related cache entries.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient whose observations should be archived.</param>
|
||||
public async Task ArchiveByPatientId(ObjectId id)
|
||||
{
|
||||
_logger.LogDebug("Archive Observations by Patient Id {id}", id);
|
||||
@@ -634,63 +762,123 @@ public class ObservationService : IObservationService
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent active intravenous lines observations for a patient, aggregated by location.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose intravenous lines observations are being queried.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains a list of <see cref="PatientObservation"/> objects, which may include null entries, representing the latest active intravenous lines observations grouped by location.</returns>
|
||||
public async Task<List<PatientObservation?>> FindLastIntravenousLinesObservationByLocation(ObjectId patientId)
|
||||
{
|
||||
return await _observationRepository.AggregatedPatientActiveIntravenousLinesObservations(patientId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent observation time for all patients by delegating to the observation repository.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a dictionary mapping patient <see cref="ObjectId"/> values to their last observation <see cref="DateTime"/>.</returns>
|
||||
public async Task<Dictionary<ObjectId, DateTime>> FindAllLastPatientObservationTime()
|
||||
{
|
||||
return await _observationRepository.FindAllLastPatientObservationTime();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing patient observation if it exists in the repository, invalidates the related cache entries, and records an audit log of the change.
|
||||
/// If no observation with the specified identifier is found, the method performs no action.
|
||||
/// </summary>
|
||||
/// <param name="observation">The patient observation containing the updated data to be persisted.</param>
|
||||
public async Task UpdateObservation(PatientObservation observation)
|
||||
{
|
||||
var obs = await _observationRepository.FindById(observation.Id);
|
||||
if (obs != null)
|
||||
{
|
||||
await _observationRepository.Update(observation);
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeyPatterns.ByPatient("patients:latestObs",observation.PatientId.ToString()));
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeyPatterns.ByPatient("patients:latestObs", observation.PatientId.ToString()));
|
||||
|
||||
await _auditService.CreateAuditLogAsync(_httpContextAccessor.HttpContext?.User!, obs, observation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent patient observation recorded before the specified date, optionally filtered by observation name.
|
||||
/// Returns <c>null</c> when no matching observation exists.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observation history is being queried.</param>
|
||||
/// <param name="date">The upper bound date; only observations recorded prior to this date are considered.</param>
|
||||
/// <param name="obsName">The optional name of the observation to filter by. When <c>null</c>, observations of any name are considered.</param>
|
||||
/// <returns>The latest <see cref="PatientObservation"/> recorded before the specified date, or <c>null</c> if none was found.</returns>
|
||||
public async Task<PatientObservation?> FindLastBeforeDate(ObjectId patientId, DateTime date, string? obsName)
|
||||
{
|
||||
return await _observationRepository.FindLastObservationBeforeDate(patientId, obsName, date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves any patient observations matching the specified patient, date, and optional observation name by delegating to the underlying observation repository.
|
||||
/// Returns null when no matching observations are found for the given criteria.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="date">The date used to find observations recorded on the same day.</param>
|
||||
/// <param name="obsName">The optional name of the observation to filter by; when null, observations of any name on the given date are considered.</param>
|
||||
/// <returns>A task that resolves to a list of matching <see cref="PatientObservation"/> instances, or null if no observations match the specified criteria.</returns>
|
||||
public async Task<List<PatientObservation>?> FindAnyWithSameDate(ObjectId patientId, DateTime date,
|
||||
string? obsName)
|
||||
string? obsName)
|
||||
{
|
||||
return await _observationRepository.FindAnyWithSameDate(patientId, obsName, date);
|
||||
}
|
||||
|
||||
//TODO To implement
|
||||
/// <summary>
|
||||
/// Retrieves all patient observations recorded before the specified date by delegating to the observation repository.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="date">The cutoff date; observations recorded before this date will be returned.</param>
|
||||
/// <param name="filterObservations">An optional list of observation identifiers to filter the results.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of <see cref="PatientObservation"/> entries found before the specified date.</returns>
|
||||
public async Task<List<PatientObservation>> FindAllBeforeDate(ObjectId patientId, DateTime date,
|
||||
List<string>? filterObservations = null)
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
return await _observationRepository.FindAnyBeforeDate(patientId, date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the latest unique observation values for a specified patient and observation name, delegating the lookup to the underlying observation repository.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="name">The name of the observation to search for.</param>
|
||||
/// <param name="expires">An optional expiration value (in seconds) applied to the query.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of the latest unique <see cref="PatientObservation"/> values.</returns>
|
||||
public async Task<List<PatientObservation>> FindLatestUniqueValuesByName(ObjectId patientId, string name,
|
||||
int? expires)
|
||||
int? expires)
|
||||
{
|
||||
return await _observationRepository.FindLatestUniqueValuesByName(patientId, name, expires);
|
||||
}
|
||||
|
||||
//TODO To implement
|
||||
/// <summary>
|
||||
/// Retrieves all patient observations recorded after the specified date, optionally filtered by a list of observation types.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being retrieved.</param>
|
||||
/// <param name="date">The cutoff date; only observations recorded after this date will be returned.</param>
|
||||
/// <param name="filterObservations">An optional list of observation identifiers used to narrow the returned results.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of patient observations matching the criteria.</returns>
|
||||
/// <exception cref="NotImplementedException">Thrown when the method is invoked, as the implementation has not yet been provided.</exception>
|
||||
public Task<List<PatientObservation>> FindAllAfterDate(ObjectId patientId, DateTime date,
|
||||
List<string>? filterObservations = null)
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the most recent non-expired patient observations matching the specified name, optionally filtered by an end-after threshold and limited in count.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="name">The name of the observation to filter by.</param>
|
||||
/// <param name="endAfter">Optional threshold used to restrict which observations are considered; if null, no end-after filter is applied.</param>
|
||||
/// <param name="num">Optional maximum number of observations to return; if null, all matching observations are returned.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing an enumerable collection of matching <see cref="PatientObservation"/> instances.</returns>
|
||||
public async Task<IEnumerable<PatientObservation>> FindLastNotExpiredObservatonsByPatient(ObjectId patientId,
|
||||
string name, int? endAfter = null, int? num = null)
|
||||
string name, int? endAfter = null, int? num = null)
|
||||
{
|
||||
return await _observationRepository.FindLastNotExpiredObservatonsByPatient(patientId, name, endAfter, num);
|
||||
}
|
||||
@@ -721,6 +909,10 @@ public class ObservationService : IObservationService
|
||||
_logger.LogDebug("found observations {count} ", count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the repository to mark a list of patient observations as expired, invalidates the corresponding cache entries, and creates audit log entries capturing the pre-update state of each observation.
|
||||
/// </summary>
|
||||
/// <param name="patientObservations">The list of patient observations to be marked as expired.</param>
|
||||
public async Task UpdateExpiredObservations(List<PatientObservation> patientObservations)
|
||||
{
|
||||
await _observationRepository.UpdateExpiredObservations(patientObservations);
|
||||
@@ -735,6 +927,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves observations that are currently marked as not expired but should be expired based on their configured expiration thresholds.
|
||||
/// For each candidate observation, the patient is validated; missing patients trigger cleanup of their observations and cached entries. Observations with missing names or unparsable expiration values are skipped, and only those whose expected expiration time (observation time plus configured minutes) has passed are yielded.
|
||||
/// </summary>
|
||||
/// <returns>An asynchronous stream of <see cref="PatientObservation"/> instances that are not expired in storage but whose effective expiration time has elapsed.</returns>
|
||||
public async IAsyncEnumerable<PatientObservation> FindNotExpiredObservationsShouldBeExpired()
|
||||
{
|
||||
var expiringObservations = await _configObservationService.GetAllConfigs();
|
||||
@@ -765,7 +962,7 @@ public class ObservationService : IObservationService
|
||||
|
||||
continue;
|
||||
}
|
||||
if(current.Name == null) continue;
|
||||
if (current.Name == null) continue;
|
||||
await _configObservationService.GetConfigObservationItemsByName(current.Name);
|
||||
var configObs = expiringObservations?
|
||||
.FirstOrDefault();
|
||||
@@ -781,6 +978,9 @@ public class ObservationService : IObservationService
|
||||
_logger.LogDebug("expired observations retrieved {count} observations", count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all observation configurations and expires those whose <c>Expires</c> value is set to a positive number, ignoring configurations with a null or non-positive expiry.
|
||||
/// </summary>
|
||||
public async Task ExpireObservations()
|
||||
{
|
||||
//TODO expire each section
|
||||
@@ -792,6 +992,9 @@ public class ObservationService : IObservationService
|
||||
.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expires patient observations that should no longer be active and recalculates the latest observation values per configured field. Sets a global flag while running to signal that expiration is in progress, processes expirations in batches of 1000 to limit memory usage, and clears the patient observations cache once finished; any error is logged and swallowed without rethrowing.
|
||||
/// </summary>
|
||||
public async Task ExpireObservationsAndRecalculateAsync()
|
||||
{
|
||||
try
|
||||
@@ -821,7 +1024,7 @@ public class ObservationService : IObservationService
|
||||
lastPatientObservationsByName)
|
||||
await InsertObservation(obs, false, false); //Not really insert, only makes calcs
|
||||
}
|
||||
|
||||
|
||||
var obsToExpireList = new List<PatientObservation>();
|
||||
var i = 0;
|
||||
var count = 0;
|
||||
@@ -844,7 +1047,7 @@ public class ObservationService : IObservationService
|
||||
obsToExpireList.Add(current);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeyPatterns.ForEntity(CacheEnum.EntityType.PatientObservations));
|
||||
|
||||
_logger.LogDebug("number of expired observations should be expired:{count}", count);
|
||||
@@ -858,25 +1061,45 @@ public class ObservationService : IObservationService
|
||||
GlobalData.AddData("isCheckingExpiration", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates multiple observation records by replacing the specified old object identifier with a new one for the given name identifier.
|
||||
/// </summary>
|
||||
/// <param name="nameId">The name identifier of the field whose value should be updated across matching records.</param>
|
||||
/// <param name="id">The new <see cref="ObjectId"/> value to assign to the matching records.</param>
|
||||
/// <param name="oldId">The existing <see cref="ObjectId"/> value to be replaced.</param>
|
||||
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
|
||||
{
|
||||
await _observationRepository.UpdateManyObjectId(nameId, id, oldId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a simple patient observation into the repository and records an audit log entry for the operation using the current HTTP context user.
|
||||
/// </summary>
|
||||
/// <param name="observation">The patient observation to insert.</param>
|
||||
public async Task InsertSimpleObservation(PatientObservation observation)
|
||||
{
|
||||
await _observationRepository.InsertOneAsync(observation);
|
||||
await _auditService.CreateAuditLogAsync(_httpContextAccessor.HttpContext?.User!, null, observation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a paginated list of patient observations for a specific patient within an optional date range, optionally filtering by observation names and supporting both active and archived collections.
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose observations are being queried.</param>
|
||||
/// <param name="startDate">The inclusive lower bound of the observation time range. Falls back to <see cref="DateTime.MinValue"/> when null.</param>
|
||||
/// <param name="endDate">The exclusive upper bound of the observation time range. Falls back to <see cref="DateTime.MaxValue"/> when null.</param>
|
||||
/// <param name="filterObservations">Optional list of observation names to restrict the results to. When null or empty, no name-based filter is applied.</param>
|
||||
/// <param name="fromArchived">When true, queries the archived observation collection; otherwise, queries the active observation collection.</param>
|
||||
/// <param name="filter">Optional pagination settings controlling the page number and page size of the returned results.</param>
|
||||
/// <returns>A task that resolves to the list of <see cref="PatientObservation"/> records matching the specified criteria.</returns>
|
||||
public async Task<List<PatientObservation>> FindAllBetweenDates(
|
||||
ObjectId patientId,
|
||||
DateTime? startDate = null,
|
||||
DateTime? endDate = null,
|
||||
List<string>? filterObservations = null,
|
||||
bool fromArchived = false,
|
||||
PaginationFilter? filter = null
|
||||
)
|
||||
ObjectId patientId,
|
||||
DateTime? startDate = null,
|
||||
DateTime? endDate = null,
|
||||
List<string>? filterObservations = null,
|
||||
bool fromArchived = false,
|
||||
PaginationFilter? filter = null
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -887,13 +1110,13 @@ public class ObservationService : IObservationService
|
||||
var filterBuilder = Builders<PatientObservation>.Filter;
|
||||
|
||||
var conditions = new List<FilterDefinition<PatientObservation>>
|
||||
{
|
||||
filterBuilder.Eq(o => o.PatientId, patientId),
|
||||
filterBuilder.Ne(o => o.Name, null),
|
||||
//filterBuilder.In(o => o.Name, filterObservations ?? new List<string?>()),
|
||||
filterBuilder.Gt(o => o.Time, startDate ?? DateTime.MinValue),
|
||||
filterBuilder.Lt(o => o.Time, endDate ?? DateTime.MaxValue)
|
||||
};
|
||||
{
|
||||
filterBuilder.Eq(o => o.PatientId, patientId),
|
||||
filterBuilder.Ne(o => o.Name, null),
|
||||
//filterBuilder.In(o => o.Name, filterObservations ?? new List<string?>()),
|
||||
filterBuilder.Gt(o => o.Time, startDate ?? DateTime.MinValue),
|
||||
filterBuilder.Lt(o => o.Time, endDate ?? DateTime.MaxValue)
|
||||
};
|
||||
|
||||
if (filterObservations != null && filterObservations.Any())
|
||||
conditions.Add(filterBuilder.In(o => o.Name, filterObservations));
|
||||
@@ -920,6 +1143,10 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously processes alert expiration and powers off beacon LEDs for points of care that are not currently in use.
|
||||
/// Skips patients located in virtual/moved/deleted/pushed/unknown locations and ignores emulated beacons and configurations with disabled alarms.
|
||||
/// </summary>
|
||||
public async Task ExpireAlertsAndPowerOffAsync()
|
||||
{
|
||||
try
|
||||
@@ -1001,6 +1228,11 @@ public class ObservationService : IObservationService
|
||||
GlobalData.AddData("isCheckingAlertsExpiration", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a paginated collection of patient observations from the repository, returning both the requested page of data and the total document count to support client-side pagination.
|
||||
/// </summary>
|
||||
/// <param name="filter">The pagination filter that specifies the page number and page size used to compute the skip/limit range.</param>
|
||||
/// <returns>A <see cref="PaginationResponse{PatientObservation}"/> containing the page of patient observations along with pagination metadata.</returns>
|
||||
public async Task<PaginationResponse<PatientObservation>> GetPaginatedObservations(PaginationFilter filter)
|
||||
{
|
||||
var result = _observationRepository.GetPaginatedObservations(filter);
|
||||
@@ -1018,6 +1250,13 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Executes the configured retention policy actions for a given patient observation, deleting older entries
|
||||
/// based on the resolved policy (days, seconds, count, or none) and auditing the deleted observations. The
|
||||
/// method performs an early return when the retention configuration is unavailable, the policy value is missing,
|
||||
/// or the observation name is empty, and logs any errors that occur during processing.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation used to resolve the retention policy and identify which records to delete.</param>
|
||||
private async Task DoRetentionActions(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -1046,7 +1285,7 @@ public class ObservationService : IObservationService
|
||||
|
||||
foreach (var observation in deletedObs)
|
||||
await _auditService.CreateAuditLogAsync(_httpContextAccessor.HttpContext?.User!, observation, null);
|
||||
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeyPatterns.ByPatient("patients:latestObs", obs.PatientId.ToString()));
|
||||
|
||||
}
|
||||
@@ -1056,6 +1295,13 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a patient observation by identifying matching subscriber groups, regenerating the grouped
|
||||
/// observation, updating the group's last grouped observation, notifying all group members, and
|
||||
/// clearing the related cache entries. Skips groups where the observation name is not contained
|
||||
/// in the group's names or where the group does not consider the observation relevant.
|
||||
/// </summary>
|
||||
/// <param name="obs">The incoming patient observation used to find and update matching groups.</param>
|
||||
private async void CheckForGroupedObs(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -1097,9 +1343,9 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
//wsg.TimerReestart();
|
||||
|
||||
|
||||
await _cacheService.DeleteByPatternAsync(CacheKeys.GroupedObs(obs.PatientId, obs.Name ?? string.Empty));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -1109,6 +1355,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes an intravenous line observation for a patient from the provided API request, extracting catheter type and location from the observation text and mapping additional observations to insertion, removal, and duration details. The observation is only persisted when the line status is recognized as <c>Insertado</c> (Inserted) or <c>Retirado</c> (Removed); otherwise the method logs an error or exits without inserting.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the observation text, parent data, message time, and additional observations used to build the intravenous line record.</param>
|
||||
/// <param name="patient">The patient to associate the resulting observation with.</param>
|
||||
private async Task ProcessIntravenousLinesObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
var isInsertable = false;
|
||||
@@ -1128,7 +1379,8 @@ public class ObservationService : IObservationService
|
||||
PatientId = patient.Id,
|
||||
ParentData = new ParentDataClass
|
||||
{
|
||||
Code = apiRequest.ObservationData?.Code, CodingSystem = apiRequest.ObservationData?.CodingSystem
|
||||
Code = apiRequest.ObservationData?.Code,
|
||||
CodingSystem = apiRequest.ObservationData?.CodingSystem
|
||||
},
|
||||
MessageTime = apiRequest.MessageTime
|
||||
};
|
||||
@@ -1187,6 +1439,13 @@ public class ObservationService : IObservationService
|
||||
await InsertObservation(obs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes allergies observation data from the API request and persists it as a patient observation.
|
||||
/// Validates that observation data and timestamps are present, maps SNOMED-coded allergy entries to allergy types, values, and notes,
|
||||
/// and short-circuits when the patient reports "no known allergies" (Sin alergias conocidas).
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the observation data and coded allergy entries to process.</param>
|
||||
/// <param name="patient">The patient associated with the allergies observation being recorded.</param>
|
||||
private async Task ProcessAllergiesObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
_logger.LogDebug("INSERT AllergiesObservation");
|
||||
@@ -1291,6 +1550,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Processes an isolation observation when the incoming request contains an observation with the text "Aislamiento" and a non-null timestamp, normalizing the value by replacing semicolons with commas and persisting it as a <c>PatientObservation</c> under the "Isolation" name and "ADAS" coding system. If the observation value is null, an error is logged and the method returns without inserting.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The incoming API request whose <c>ObservationData</c> is inspected for the isolation marker text and timestamp.</param>
|
||||
/// <param name="patient">The patient associated with the observation, used to assign the patient identifier to the new record.</param>
|
||||
private async Task ProcessIsolationObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
if (apiRequest.ObservationData is { Text: "Aislamiento", Time: not null })
|
||||
@@ -1317,6 +1581,13 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a postural changes observation (<c>CAMBIOS POSTURALES</c>) from the API request, mapping it to a <see cref="PatientObservation"/> entry and persisting it.
|
||||
/// Falls back to the single <c>Observation</c> or the first item of <c>Observations</c> when the observation data value is empty, and skips processing when the value or time is missing.
|
||||
/// Replaces semicolons with commas in the value before insertion to ensure proper formatting.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The incoming API request containing the observation data, observations collection, and message timestamp to be processed.</param>
|
||||
/// <param name="patient">The patient associated with the observation; its identifier is stored in the resulting <see cref="PatientObservation"/>.</param>
|
||||
private async Task ProcessPositionObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
if (apiRequest.ObservationData != null &&
|
||||
@@ -1359,6 +1630,11 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Processes and persists a drainage observation for the given patient, mapping incoming observation codes to drainage-specific properties such as type, height, location, and volume. Validates that required observation data and the value object are present before building and inserting the observation; logs a warning and exits early if validation fails.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the observation data, time, and the list of observations to be processed.</param>
|
||||
/// <param name="patient">The patient associated with the drainage observation being recorded.</param>
|
||||
private async Task ProcessDrainageObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
_logger.LogDebug("INSERT DrainageObservation");
|
||||
@@ -1432,6 +1708,13 @@ public class ObservationService : IObservationService
|
||||
* Las obs que se insertan de forma manual desde nurse deben seguir la logica contraria a las obs
|
||||
* recibidas desde el censo
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Saves manual nurse observations following the logic opposite to that of observations received from the census.
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the data required to locate the patient and the observations to be saved.</param>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="apiRequest"/> is null.</exception>
|
||||
public async Task SaveRequestNurseObs(ApiRequest apiRequest)
|
||||
{
|
||||
var patient = await _patientService.FindPatientByApiRequest(apiRequest);
|
||||
@@ -1451,8 +1734,15 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stops manual recordings for a patient when there are no active recording alarms, based on the patient's point of care configuration and the observation configuration list.
|
||||
/// </summary>
|
||||
/// <param name="patient">The patient whose recordings are being evaluated.</param>
|
||||
/// <param name="configs">The list of point of care configurations used to locate the configuration associated with the patient.</param>
|
||||
/// <param name="obsConfigList">The observation configurations from which the recording end-after time is derived, falling back to <paramref name="defaultValue"/> when no recording alarms are configured.</param>
|
||||
/// <param name="defaultValue">The default end-after value applied when no observation configuration specifies a recording alarm.</param>
|
||||
private async Task CheckRecordings(Patient patient, List<PointOfCare> configs,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
//paramos grabación si no hay alarmas activas y hay una grabación
|
||||
var recordingEndAfter = obsConfigList
|
||||
@@ -1502,8 +1792,17 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the relay state for a patient based on observation configurations and active alarms, and powers off
|
||||
/// the configured relays when no active "ADAS_ALARM" observations remain within the configured end-after window.
|
||||
/// Falls back to the provided default value when no observation configurations define an <c>OpenDoor</c> alarm,
|
||||
/// and skips relay control when the patient has no associated point of care.
|
||||
/// </summary>
|
||||
/// <param name="patient">The patient whose relay state is being evaluated; must have a valid <c>PointOfCareId</c>.</param>
|
||||
/// <param name="obsConfigList">Collection of observation configurations used to determine the relay end-after threshold via the <c>OpenDoor</c> alarm.</param>
|
||||
/// <param name="defaultValue">Fallback value used for the relay end-after threshold when no <c>OpenDoor</c> alarm configuration is present.</param>
|
||||
private async Task CheckRelay(Patient patient,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
var relayEndAfter = obsConfigList
|
||||
.Where(c => c.Alarm is { OpenDoor: not null })
|
||||
@@ -1542,8 +1841,14 @@ public class ObservationService : IObservationService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the patient has any active beacon alarms and, if none are found and the patient is assigned to a point of care, powers off the beacon LED.
|
||||
/// </summary>
|
||||
/// <param name="patient">The patient whose beacon state is being evaluated; its identifier and point of care assignment are used to locate recent observations and target the beacon.</param>
|
||||
/// <param name="obsConfigList">The list of observation configurations used to determine the maximum beacon end-after value from the alarms that are both enabled and have their beacon enabled, falling back to <paramref name="defaultValue"/> when no configuration matches or the beacon is null.</param>
|
||||
/// <param name="defaultValue">The fallback value used for the beacon end-after period when no configuration provides a value or when the matching configuration's beacon is null.</param>
|
||||
private async Task CheckBeacon(Patient patient,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
var beaconEndAfter = obsConfigList
|
||||
.Where(c => c.Alarm is { Enabled: true, Beacon.Enabled: true })
|
||||
|
||||
Reference in New Issue
Block a user