=== 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
@@ -21,6 +21,7 @@ namespace adas_core.Application.Services;
/// <summary>
/// Provides functionality for recording operations as defined by the <see cref="IRecordingService"/> contract.
/// </summary>
/// <!-- aidoc:v1 sig=5872d8b -->
public class RecordingService : IRecordingService
{
private readonly IAuthService _authService;
@@ -95,6 +96,7 @@ public class RecordingService : IRecordingService
/// <param name="poc">The point of care associated with the recording.</param>
/// <returns>A task that resolves to <c>true</c> if the cancel request succeeded; otherwise, <c>false</c>.</returns>
/// <exception cref="Exception">Thrown when the recording API URL is not defined or the authentication token is null or empty.</exception>
/// <!-- aidoc:v1 sig=34368ee body=ee5471e -->
public async Task<bool> SendCancelRecordingToRecordingApi(Patient patient, PointOfCare poc)
{
var token = await _authService.GetToken();
@@ -125,6 +127,7 @@ public class RecordingService : IRecordingService
/// <param name="poc">The point of care where the recording was performed.</param>
/// <param name="manualRecording">The manual recording whose start and stop times are forwarded to the queue.</param>
/// <param name="start">A flag indicating whether the recording is being started or stopped.</param>
/// <!-- aidoc:v1 sig=f624109 body=55cd11e -->
public async Task SendRecordingData(Patient patient, PointOfCare poc, ManualRecording manualRecording,
bool start)
{
@@ -140,6 +143,7 @@ public class RecordingService : IRecordingService
/// <param name="poc">The point of care where the recording was captured.</param>
/// <param name="automaticRecording">The automatic recording payload, including alarm name, start/stop/event timestamps, severity, and description.</param>
/// <returns>A task that resolves to <c>true</c> if the recording data was queued successfully; otherwise, <c>false</c> when the alarm name cannot be parsed or the send operation fails.</returns>
/// <!-- aidoc:v1 sig=3c0ea0c body=f69af0b -->
public async Task<bool> SendAutoRecordingData(Patient patient, PointOfCare poc, RecordingData automaticRecording)
{
try
@@ -178,6 +182,7 @@ public class RecordingService : IRecordingService
/// <param name="start">Flag indicating whether the recording is a start event; defaults to true.</param>
/// <param name="type">The alarm type for the recording; defaults to <see cref="AlarmEnum.Type.Manual"/>.</param>
/// <exception cref="Exception">Thrown when the point of care status is not <see cref="StatusEnum.PointOfCare.InUse"/>, including the serialized point of care in the message.</exception>
/// <!-- aidoc:v1 sig=e6985f2 body=01a1208 -->
public async Task SendRecordingDataToQueue(Patient patient, PointOfCare poc, DateTime? date, DateTime? endDate,
DateTime? eventDate, AlarmEnum.Name? alarmName, AlarmEnum.Severity severity, string? alarmDescription,
bool start = true, AlarmEnum.Type type = AlarmEnum.Type.Manual)
@@ -242,6 +247,8 @@ public class RecordingService : IRecordingService
/// </summary>
/// <param name="roomId">The identifier of the room whose recordings should be fetched.</param>
/// <returns>A task that resolves to a list of <see cref="RecordingData"/> for the room, an empty list when the request fails or the room has no recordings, or <c>null</c> when the recording API URL or authentication token is not configured or when the maximum number of retries is reached.</returns>
/// <!-- aidoc-review:v1 severity=low kind=wrong_returns
/// "The documentation states the method returns null 'when the maximum number of retries is reached', but the post-loop check `if (retryCount == _rabbitMqSettings.MaxRetries)` is unreachable: after all retries throw HttpRequestException, `retryCount` is `MaxRetries + 1`, so the null branch is skipped and an empty list is returned instead." -->
public async Task<List<RecordingData>?> GetRecordings(int roomId)
{
var retryCount = 1;
@@ -331,6 +338,7 @@ public class RecordingService : IRecordingService
/// </summary>
/// <param name="apiRequest">The API request whose recording data and patient information will be sent to the Recording API.</param>
/// <exception cref="Exception">Rethrown via Task.FromException when a non-HTTP error occurs while sending the recording request.</exception>
/// <!-- aidoc:v1 sig=655d140 body=ec1d813 -->
public async Task SaveRequestAsync(ApiRequest apiRequest)
{
var retryCount = 1;
@@ -420,6 +428,7 @@ public class RecordingService : IRecordingService
/// </summary>
/// <param name="apiRequest">The API request to save.</param>
/// <exception cref="NotImplementedException">Always thrown because the method has not been implemented.</exception>
/// <!-- aidoc:v1 sig=3385bba body=bfa6f2f -->
public Task SaveRequest(ApiRequest apiRequest)
{
//return Task.CompletedTask;
@@ -442,6 +451,7 @@ public class RecordingService : IRecordingService
/// <param name="alarmDescription">A textual description of the alarm.</param>
/// <param name="alarm">The alarm type, defaulting to <see cref="AlarmEnum.Type.Manual"/> when not specified.</param>
/// <returns>A configured <see cref="RecordingData"/> instance, or <c>null</c> if any required identifier is invalid.</returns>
/// <!-- aidoc:v1 sig=912bcd8 body=3236ae1 -->
private RecordingData? GenerateRecordingData(Patient patient, PointOfCare poc, DateTime? startDate,
DateTime? endDate, DateTime? eventTime, int? minToExpired, AlarmEnum.Name? alarmName,
AlarmEnum.Severity severity,
@@ -502,6 +512,7 @@ public class RecordingService : IRecordingService
/// and silently returns when the patient cannot be resolved.
/// </summary>
/// <param name="recording">The list of recording entries to broadcast; the first item is used to resolve the patient and room context.</param>
/// <!-- aidoc:v1 sig=f4cef29 body=92782d1 -->
private async Task SendRecordingBroadcast(List<RecordingData> recording)
{
if (!recording.IsNullOrEmpty())
@@ -534,6 +545,7 @@ public class RecordingService : IRecordingService
/// </summary>
/// <param name="plainText">The text to encode.</param>
/// <returns>The Base64 encoded representation of the input text.</returns>
/// <!-- aidoc:v1 sig=7418cfd body=746e11b -->
protected static string Base64Encode(string plainText)
{
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);