Class RecordingService
- Namespace
- adas_core.Application.Services
- Assembly
- adas-core.Application.dll
Provides functionality for recording operations as defined by the IRecordingService contract.
public class RecordingService : IRecordingService, IApiRequestService
- Inheritance
-
RecordingService
- Implements
- Inherited Members
- Extension Methods
Constructors
RecordingService(IOptions<RabbitMqSettings>, IOptions<RecordingSettings>, ILogger<RecordingService>, IHttpClientFactory, IPublisherService, IAuthService, IOptions<ApiSettings>, IClientMessageService, ISubscribersService, Lazy<IPatientService>)
public RecordingService(IOptions<RabbitMqSettings> rabbitMqSettings, IOptions<RecordingSettings> recordingSettings, ILogger<RecordingService> logger, IHttpClientFactory httpClientFactory, IPublisherService publisherService, IAuthService authService, IOptions<ApiSettings> apiSettings, IClientMessageService clientMessageService, ISubscribersService subscribersService, Lazy<IPatientService> patientService)
Parameters
rabbitMqSettingsIOptions<RabbitMqSettings>recordingSettingsIOptions<RecordingSettings>loggerILogger<RecordingService>httpClientFactoryIHttpClientFactorypublisherServiceIPublisherServiceauthServiceIAuthServiceapiSettingsIOptions<ApiSettings>clientMessageServiceIClientMessageServicesubscribersServiceISubscribersServicepatientServiceLazy<IPatientService>
Methods
Base64Encode(string)
Encodes the specified plain text to a Base64 string using UTF-8 encoding.
protected static string Base64Encode(string plainText)
Parameters
plainTextstringThe text to encode.
Returns
- string
The Base64 encoded representation of the input text.
GetRecordings(int)
Asynchronously retrieves the list of in-progress recordings for the specified room from the recording API.
Performs token-based authentication, retries transient HTTP request failures up to the configured maximum, and falls back to an empty list or null when the API is unreachable, the room has no recordings, or retries are exhausted.
public Task<List<RecordingData>?> GetRecordings(int roomId)
Parameters
roomIdintThe identifier of the room whose recordings should be fetched.
Returns
- Task<List<RecordingData>>
A task that resolves to a list of RecordingData for the room, an empty list when the request fails or the room has no recordings, or
nullwhen the recording API URL or authentication token is not configured or when the maximum number of retries is reached.
SaveRequest(ApiRequest)
Saves the specified API request. The method is not yet implemented.
public Task SaveRequest(ApiRequest apiRequest)
Parameters
apiRequestApiRequestThe API request to save.
Returns
Exceptions
- NotImplementedException
Always thrown because the method has not been implemented.
SaveRequestAsync(ApiRequest)
Sends the recording data from the given API request to the Recording API with authentication, retrying on failure up to the configured maximum and routing unsuccessful requests to the error queue. Clears the access token on 401 responses, maps the returned video data into a recording broadcast message on success, and falls back to the error queue when retries are exhausted or a connection error occurs.
public Task SaveRequestAsync(ApiRequest apiRequest)
Parameters
apiRequestApiRequestThe API request whose recording data and patient information will be sent to the Recording API.
Returns
Exceptions
- Exception
Rethrown via Task.FromException when a non-HTTP error occurs while sending the recording request.
SendAutoRecordingData(Patient, PointOfCare, RecordingData)
Sends automatic recording data for the specified patient and point of care to the recording data queue.
Validates that the alarm name can be parsed to AlarmEnum.Name; returns false if the name is invalid or if an exception occurs during the send operation.
public Task<bool> SendAutoRecordingData(Patient patient, PointOfCare poc, RecordingData automaticRecording)
Parameters
patientPatientThe patient associated with the automatic recording.
pocPointOfCareThe point of care where the recording was captured.
automaticRecordingRecordingDataThe automatic recording payload, including alarm name, start/stop/event timestamps, severity, and description.
Returns
- Task<bool>
A task that resolves to
trueif the recording data was queued successfully; otherwise,falsewhen the alarm name cannot be parsed or the send operation fails.
SendCancelRecordingToRecordingApi(Patient, PointOfCare)
Sends a cancel recording request to the recording API for the specified patient and point of care. Throws an exception if the recording API URL is not configured or a valid authentication token cannot be obtained.
public Task<bool> SendCancelRecordingToRecordingApi(Patient patient, PointOfCare poc)
Parameters
patientPatientThe patient whose recording in progress should be cancelled.
pocPointOfCareThe point of care associated with the recording.
Returns
Exceptions
- Exception
Thrown when the recording API URL is not defined or the authentication token is null or empty.
SendRecordingData(Patient, PointOfCare, ManualRecording, bool)
Sends the manual recording data to the processing queue, forwarding the recording's start and stop times along with the patient and point of care information.
public Task SendRecordingData(Patient patient, PointOfCare poc, ManualRecording manualRecording, bool start)
Parameters
patientPatientThe patient associated with the manual recording.
pocPointOfCareThe point of care where the recording was performed.
manualRecordingManualRecordingThe manual recording whose start and stop times are forwarded to the queue.
startboolA flag indicating whether the recording is being started or stopped.
Returns
SendRecordingDataToQueue(Patient, PointOfCare, DateTime?, DateTime?, DateTime?, Name?, Severity, string?, bool, Type)
Sends recording data for a patient to the recording message queue, broadcasting the recording after a successful send. Validates the patient number when the start-without-patient-number feature is disabled, ensures the point of care is in use, defaults a missing alarm description to "UNKNOWN", and retries the send on transient HTTP connection failures up to the configured maximum, routing the last failure to the error recording queue.
public 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 = Type.Manual)
Parameters
patientPatientThe patient whose recording is being sent; its patient number is validated when required.
pocPointOfCareThe point of care (box) that must be in use to allow the recording to be sent.
dateDateTime?Optional recording date used to build the recording payload.
endDateDateTime?Optional end date used to build the recording payload.
eventDateDateTime?Optional event date used to build the recording payload.
alarmNameAlarmEnum.Name?Optional alarm name to associate with the recording.
severityAlarmEnum.SeverityThe alarm severity for the recording.
alarmDescriptionstringOptional alarm description; when null or empty it is replaced with "UNKNOWN".
startboolFlag indicating whether the recording is a start event; defaults to true.
typeAlarmEnum.TypeThe alarm type for the recording; defaults to Manual.