=== 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:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -17,6 +17,22 @@ namespace adas_core.Application.Services;
/// Uses <see cref="IRecordingAlertRepository"/> and <see cref="IRecordingAlertArchiveRepository"/> for alert persistence, and lazily resolves <see cref="IPatientService"/> through <paramref name="patientService"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=6c23cec -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'configObservationService' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'recordingAlertRepository' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'recordingAlertArchiveRepository' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'logger' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'clientMessageService' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'subscribersService' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'httpContextAccessor' is not documented with a <param> tag." -->
/// <!-- aidoc-review:v1 severity=medium kind=missing_param
/// "Constructor parameter 'auditService' is not documented with a <param> tag." -->
public class RecordingAlertService(
Lazy<IPatientService> patientService,
IConfigObservationService configObservationService,
@@ -34,6 +50,7 @@ public class RecordingAlertService(
/// </summary>
/// <param name="patient">The patient to be archived.</param>
/// <returns>A task that represents the asynchronous archive operation.</returns>
/// <!-- aidoc:v1 sig=0afe718 body=be01ba0 -->
public async Task Archive(Patient patient)
{
await ArchiveByPatientId(patient.Id);
@@ -44,6 +61,7 @@ public class RecordingAlertService(
/// to the archive repository and then deleting them from the source repository.
/// </summary>
/// <param name="id">The unique identifier of the patient whose recording alerts should be archived.</param>
/// <!-- aidoc:v1 sig=3385472 body=286b52c -->
public async Task ArchiveByPatientId(ObjectId id)
{
logger.LogDebug("Archive Recording Alerts by Patient Id {id}", id);
@@ -61,6 +79,7 @@ public class RecordingAlertService(
/// Deletes all recording alerts associated with the specified patient identifier by delegating to the recording alert repository.
/// </summary>
/// <param name="id">The unique identifier of the patient whose recording alerts should be removed.</param>
/// <!-- aidoc:v1 sig=09e4e41 body=b6d232c -->
public async Task DeleteByPatientId(ObjectId id)
{
logger.LogDebug("Delete Recording Alerts by Patient Id {id}", id);
@@ -73,6 +92,7 @@ public class RecordingAlertService(
/// <param name="patientId">The unique identifier of the patient whose recording alerts are being queried.</param>
/// <param name="num">The maximum number of recent alerts to return. Defaults to 2.</param>
/// <returns>A task that represents the asynchronous operation, containing a list of the patient's most recent <see cref="PatientRecordingAlert"/> entries.</returns>
/// <!-- aidoc:v1 sig=8d69c21 body=4613a27 -->
public async Task<List<PatientRecordingAlert>> FindLastRecordingAlert(ObjectId patientId, int num = 2)
{
return await recordingAlertRepository.AggregatedPatientLastObservations(patientId, num);
@@ -84,6 +104,7 @@ public class RecordingAlertService(
/// </summary>
/// <param name="apiRequest">The API request to save.</param>
/// <returns>A task that represents the asynchronous save operation.</returns>
/// <!-- aidoc:v1 sig=a3706aa body=c8d77ba -->
public Task SaveRequestAsync(ApiRequest apiRequest)
{
return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest); }));
@@ -95,6 +116,7 @@ public class RecordingAlertService(
/// </summary>
/// <param name="apiRequest">The API request containing patient or location identifiers and the recording alerts to persist.</param>
/// <exception cref="ApiRequestException">Thrown when <paramref name="apiRequest"/>.Type is not a valid type for Observations.</exception>
/// <!-- aidoc:v1 sig=229d8cd body=d93e92b -->
public async Task SaveRequest(ApiRequest apiRequest)
{
if (string.IsNullOrEmpty(apiRequest.PatientNumber) && string.IsNullOrEmpty(apiRequest.Location?.UnitName) &&
@@ -164,6 +186,7 @@ public class RecordingAlertService(
/// <param name="nameId">The name identifier used to filter the records to update.</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 in the matching records.</param>
/// <!-- aidoc:v1 sig=72ce1ca body=c1620c4 -->
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
{
await recordingAlertRepository.UpdateManyObjectId(nameId, id, oldId);
@@ -173,6 +196,7 @@ public class RecordingAlertService(
/// Inserts a new patient recording alert by persisting it, creating an audit log entry, broadcasting the alert, and executing any associated retention actions.
/// </summary>
/// <param name="recAlert">The patient recording alert to be inserted and processed.</param>
/// <!-- aidoc:v1 sig=4687f06 body=311839c -->
private async Task InsertRecordingAlert(PatientRecordingAlert recAlert)
{
logger.LogDebug("Insert {recAlert}", recAlert);
@@ -186,6 +210,7 @@ public class RecordingAlertService(
/// Asynchronously broadcasts a patient observation to subscribers whose registered locations include the patient's point of care, sending a recording alert when the observation is a recording alert and a generic observation otherwise. The method returns early without sending any message if the observation has no name, the patient cannot be resolved, or the patient has no point of care assigned.
/// </summary>
/// <param name="recAlert">The patient observation to broadcast to matching subscribers.</param>
/// <!-- aidoc:v1 sig=6f93bc2 body=b6d7077 -->
private async Task SendObsBroadcast(BasePatientObservation recAlert)
{
if (recAlert.Name == null) return;
@@ -210,6 +235,7 @@ public class RecordingAlertService(
/// </summary>
/// <param name="recAlert">The patient recording alert whose retention actions will be evaluated and applied.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the resolved <see cref="RetentionPolicy"/> value is not handled by the switch statement.</exception>
/// <!-- aidoc:v1 sig=90f8187 body=a64ba52 -->
private async Task DoRetentionActions(PatientRecordingAlert recAlert)
{
var result = await configObservationService.RetentionActions(recAlert);