=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -24,6 +24,7 @@ namespace adas_core.Application.Services;
|
||||
/// Provides the concrete implementation of the <see cref="IObservationService"/> contract,
|
||||
/// encapsulating the business logic required to manage and expose observation-related operations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=974bc4c -->
|
||||
public class ObservationService : IObservationService
|
||||
{
|
||||
private readonly ICacheService _cacheService;
|
||||
@@ -170,6 +171,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=6f6283b body=92c1221 -->
|
||||
public async Task<List<PatientObservation>> FindLastObservations(ObjectId patientId, int num = 2,
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
@@ -185,6 +187,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=06c6fa6 body=f861637 -->
|
||||
private async Task<List<PatientObservation>> AggregatedLastObsCached(
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations,
|
||||
@@ -227,6 +230,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=8272c2c body=9cf7a87 -->
|
||||
public async Task<List<PatientObservation>> FindLastObservationsByField(
|
||||
ObjectId patientId,
|
||||
List<Field>? filterObservations = null,
|
||||
@@ -256,6 +260,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=5df4888 body=c476eb8 -->
|
||||
public async Task<PatientObservation?> MapObservationsByName(PatientObservation obs)
|
||||
{
|
||||
return await _configObservationService.Map(obs, true);
|
||||
@@ -267,6 +272,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=70a9515 body=67bca22 -->
|
||||
public async Task<PatientObservation?> MapObservation(PatientObservation obs, bool onlyByName = false)
|
||||
{
|
||||
try
|
||||
@@ -311,6 +317,10 @@ public class ObservationService : IObservationService
|
||||
/// <param name="obs">Observation</param>
|
||||
/// <param name="persistObs"></param>
|
||||
/// <param name="mapObs">True if it needs to be inserted</param>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_param_role
|
||||
/// "mapObs is documented as 'True if it needs to be inserted' but the code shows it controls whether to map the observation via MapObservation" -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=missing_param
|
||||
/// "persistObs parameter has no description; it controls whether the observation is persisted to the repository" -->
|
||||
public async Task InsertObservation(PatientObservation obs, bool persistObs = true, bool mapObs = true)
|
||||
{
|
||||
try
|
||||
@@ -369,6 +379,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=975cc72 body=34767d6 -->
|
||||
public async Task InsertNurseObservation(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -416,6 +427,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=ca5a8c1 body=049bcaf -->
|
||||
public async Task<bool> InsertIfChanged(string name, PatientObservation observation, bool persistObs = true,
|
||||
bool mapObs = true)
|
||||
{
|
||||
@@ -434,6 +446,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=9af0676 body=1e5ea24 -->
|
||||
public Task SendObsBroadcast(List<PatientObservation> obsList, PatientLocation location)
|
||||
{
|
||||
// Display Subscription
|
||||
@@ -458,6 +471,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=2fbfda1 body=8d7eaaa -->
|
||||
public Task SendObsBroadcast(List<PatientObservation> obsList, ObjectId pocId)
|
||||
{
|
||||
// Display Subscription
|
||||
@@ -479,6 +493,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=1e50a7a body=505987b -->
|
||||
public async Task SendObsBroadcast(BasePatientObservation obs)
|
||||
{
|
||||
if (obs.Name == null) return;
|
||||
@@ -515,6 +530,10 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
|
||||
/// "States 'persists them asynchronously through the calculated observations mapping service', but the mapping service only maps observations; actual persistence is performed by InsertObservation in fire-and-forget tasks." -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
|
||||
/// "States 'any errors during processing are logged without being rethrown', but the final Task.WhenAll is fire-and-forget (assigned to `_`), so exceptions thrown by InsertObservation tasks are not caught by the outer try/catch and will not be logged here." -->
|
||||
public async void ProcessObservations(List<PatientObservation> observations, Patient patient,
|
||||
DateTime messageTime, ObservationData? observationData = null)
|
||||
{
|
||||
@@ -575,6 +594,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=bad7899 body=cf9afd9 -->
|
||||
public Task SaveRequestNurseObsAsync(ApiRequest request)
|
||||
{
|
||||
return Task.Run(() => SaveRequestNurseObs(request));
|
||||
@@ -589,6 +609,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=229d8cd body=04a5ed7 -->
|
||||
public async Task SaveRequest(ApiRequest apiRequest)
|
||||
{
|
||||
if (
|
||||
@@ -688,6 +709,7 @@ public class ObservationService : IObservationService
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request to be saved.</param>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=a3706aa body=a312b13 -->
|
||||
public Task SaveRequestAsync(ApiRequest apiRequest)
|
||||
{
|
||||
//return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest); }));
|
||||
@@ -700,6 +722,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=3727a3e body=8e212ac -->
|
||||
public async Task<IAsyncCursor<PatientObservation>> FindByPatientIdAsync(ObjectId patientId)
|
||||
{
|
||||
return await _observationRepository.FindByPatientIdAsync(patientId);
|
||||
@@ -712,6 +735,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=6e7afc6 body=835e601 -->
|
||||
public async Task<IAsyncCursor<PatientObservation>> FindByPatientIdAndCodingSystemAsync(ObjectId patientId,
|
||||
string codingSystem, string name)
|
||||
{
|
||||
@@ -724,6 +748,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=09e4e41 body=c5228ee -->
|
||||
public async Task DeleteByPatientId(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -751,6 +776,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=026c725 body=ac22ce5 -->
|
||||
public async Task Archive(PatientObservation observation)
|
||||
{
|
||||
await _observationArchiveRepository.InsertOneAsync(observation);
|
||||
@@ -763,6 +789,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=0afe718 body=be01ba0 -->
|
||||
public async Task Archive(Patient patient)
|
||||
{
|
||||
await ArchiveByPatientId(patient.Id);
|
||||
@@ -772,6 +799,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=3385472 body=a839154 -->
|
||||
public async Task ArchiveByPatientId(ObjectId id)
|
||||
{
|
||||
_logger.LogDebug("Archive Observations by Patient Id {id}", id);
|
||||
@@ -794,6 +822,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=867a12b body=af359b4 -->
|
||||
public async Task<List<PatientObservation?>> FindLastIntravenousLinesObservationByLocation(ObjectId patientId)
|
||||
{
|
||||
return await _observationRepository.AggregatedPatientActiveIntravenousLinesObservations(patientId);
|
||||
@@ -803,6 +832,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=115ac00 body=d447d05 -->
|
||||
public async Task<Dictionary<ObjectId, DateTime>> FindAllLastPatientObservationTime()
|
||||
{
|
||||
return await _observationRepository.FindAllLastPatientObservationTime();
|
||||
@@ -814,6 +844,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=c0ac237 body=3e235cb -->
|
||||
public async Task UpdateObservation(PatientObservation observation)
|
||||
{
|
||||
var obs = await _observationRepository.FindById(observation.Id);
|
||||
@@ -835,6 +866,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=babda83 body=e05ec66 -->
|
||||
public async Task<PatientObservation?> FindLastBeforeDate(ObjectId patientId, DateTime date, string? obsName)
|
||||
{
|
||||
return await _observationRepository.FindLastObservationBeforeDate(patientId, obsName, date);
|
||||
@@ -848,6 +880,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=15a1606 body=8af3163 -->
|
||||
public async Task<List<PatientObservation>?> FindAnyWithSameDate(ObjectId patientId, DateTime date,
|
||||
string? obsName)
|
||||
{
|
||||
@@ -862,6 +895,8 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=mentions_removed_behavior
|
||||
/// "The filterObservations parameter is documented as filtering the results, but the method body does not pass it to the repository call (only patientId and date are forwarded), so no filtering actually occurs." -->
|
||||
public async Task<List<PatientObservation>> FindAllBeforeDate(ObjectId patientId, DateTime date,
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
@@ -875,6 +910,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=fbdab74 body=6467bab -->
|
||||
public async Task<List<PatientObservation>> FindLatestUniqueValuesByName(ObjectId patientId, string name,
|
||||
int? expires)
|
||||
{
|
||||
@@ -890,6 +926,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=a2b1d09 body=bfa6f2f -->
|
||||
public Task<List<PatientObservation>> FindAllAfterDate(ObjectId patientId, DateTime date,
|
||||
List<string>? filterObservations = null)
|
||||
{
|
||||
@@ -904,6 +941,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=fa7c1b4 body=d00a4ef -->
|
||||
public async Task<IEnumerable<PatientObservation>> FindLastNotExpiredObservatonsByPatient(ObjectId patientId,
|
||||
string name, int? endAfter = null, int? num = null)
|
||||
{
|
||||
@@ -916,6 +954,7 @@ public class ObservationService : IObservationService
|
||||
/// current time
|
||||
/// mark as expired in bd.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=076e4fe body=3b48a1e -->
|
||||
public async Task CheckAndExpireObservations()
|
||||
{
|
||||
var count = 0;
|
||||
@@ -940,6 +979,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=606ff2e body=5f2ea53 -->
|
||||
public async Task UpdateExpiredObservations(List<PatientObservation> patientObservations)
|
||||
{
|
||||
await _observationRepository.UpdateExpiredObservations(patientObservations);
|
||||
@@ -959,6 +999,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=08302b5 body=277c7e5 -->
|
||||
public async IAsyncEnumerable<PatientObservation> FindNotExpiredObservationsShouldBeExpired()
|
||||
{
|
||||
var expiringObservations = await _configObservationService.GetAllConfigs();
|
||||
@@ -1008,6 +1049,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=085cd58 body=23edba8 -->
|
||||
public async Task ExpireObservations()
|
||||
{
|
||||
//TODO expire each section
|
||||
@@ -1022,6 +1064,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=b7c6d53 body=adc503e -->
|
||||
public async Task ExpireObservationsAndRecalculateAsync()
|
||||
{
|
||||
try
|
||||
@@ -1094,6 +1137,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=72ce1ca body=46d3367 -->
|
||||
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
|
||||
{
|
||||
await _observationRepository.UpdateManyObjectId(nameId, id, oldId);
|
||||
@@ -1103,6 +1147,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=983d9dc body=cfd144b -->
|
||||
public async Task InsertSimpleObservation(PatientObservation observation)
|
||||
{
|
||||
await _observationRepository.InsertOneAsync(observation);
|
||||
@@ -1119,6 +1164,8 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_param_role
|
||||
/// "startDate is documented as 'inclusive lower bound' but the code uses filterBuilder.Gt(o => o.Time, ...), which is exclusive (strict greater-than). Records with Time == startDate are NOT included in results." -->
|
||||
public async Task<List<PatientObservation>> FindAllBetweenDates(
|
||||
ObjectId patientId,
|
||||
DateTime? startDate = null,
|
||||
@@ -1174,6 +1221,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=e82bf03 body=a65a543 -->
|
||||
public async Task ExpireAlertsAndPowerOffAsync()
|
||||
{
|
||||
try
|
||||
@@ -1260,6 +1308,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=09d4b6c body=3ba0256 -->
|
||||
public async Task<PaginationResponse<PatientObservation>> GetPaginatedObservations(PaginationFilter filter)
|
||||
{
|
||||
var result = _observationRepository.GetPaginatedObservations(filter);
|
||||
@@ -1284,6 +1333,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=b72421f body=75a9bf8 -->
|
||||
private async Task DoRetentionActions(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -1329,6 +1379,7 @@ public class ObservationService : IObservationService
|
||||
/// 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>
|
||||
/// <!-- aidoc:v1 sig=6945ee7 body=3ec5c18 -->
|
||||
private async void CheckForGroupedObs(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -1387,6 +1438,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=6d902c0 body=6131bea -->
|
||||
private async Task ProcessIntravenousLinesObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
var isInsertable = false;
|
||||
@@ -1473,6 +1525,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=87cd8c3 body=b361033 -->
|
||||
private async Task ProcessAllergiesObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
_logger.LogDebug("INSERT AllergiesObservation");
|
||||
@@ -1582,6 +1635,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=3e77398 body=f0f74d8 -->
|
||||
private async Task ProcessIsolationObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
if (apiRequest.ObservationData is { Text: "Aislamiento", Time: not null })
|
||||
@@ -1615,6 +1669,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=0d9f42f body=316c55d -->
|
||||
private async Task ProcessPositionObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
if (apiRequest.ObservationData != null &&
|
||||
@@ -1662,6 +1717,7 @@ public class ObservationService : IObservationService
|
||||
/// </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>
|
||||
/// <!-- aidoc:v1 sig=0d44621 body=0ec2fb5 -->
|
||||
private async Task ProcessDrainageObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
_logger.LogDebug("INSERT DrainageObservation");
|
||||
@@ -1742,6 +1798,8 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_exception
|
||||
/// "ArgumentNullException is documented but the method does not throw it; if apiRequest is null, accessing apiRequest.PatientNumber or apiRequest.Location would throw NullReferenceException" -->
|
||||
public async Task SaveRequestNurseObs(ApiRequest apiRequest)
|
||||
{
|
||||
var patient = await _patientService.FindPatientByApiRequest(apiRequest);
|
||||
@@ -1768,6 +1826,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=9902090 body=5b3f7b2 -->
|
||||
private async Task CheckRecordings(Patient patient, List<PointOfCare> configs,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
@@ -1828,6 +1887,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=b9117cf body=d76f723 -->
|
||||
private async Task CheckRelay(Patient patient,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
@@ -1874,6 +1934,7 @@ public class ObservationService : IObservationService
|
||||
/// <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>
|
||||
/// <!-- aidoc:v1 sig=0dd4f68 body=8372da2 -->
|
||||
private async Task CheckBeacon(Patient patient,
|
||||
IEnumerable<ConfigObservation> obsConfigList, int defaultValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user