=== 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
@@ -24,6 +24,7 @@ namespace adas_core.module.LightBeacons.Services;
/// It interacts with the point of care service to determine which beacons are associated with specific locations and maintains an in-memory cache of the current color state of each location's beacon.
/// The service also handles CRUD operations for light beacon configurations stored in a MongoDB repository.
/// </summary>
/// <!-- aidoc:v1 sig=3a68be9 -->
public class LightBeaconService : ILightBeaconService
{
private readonly IClientMessageService _clientMessageService;
@@ -44,6 +45,7 @@ public class LightBeaconService : ILightBeaconService
/// <param name="subscribersService">The subscribers service for managing subscribers.</param>
/// <param name="pointOfCareService">The point of care service for retrieving point of care information.</param>
/// <param name="lightBeaconRepository">The light beacon repository for managing light beacon data.</param>
/// <!-- aidoc:v1 sig=9216b6b body=faa90fc -->
public LightBeaconService(
IOptions<ApiSettings> apiSettings,
ILogger<LightBeaconService> logger,
@@ -82,6 +84,10 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="pocId">The ID of the point of care for which to power off the LED.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Documentation claims the method 'checks if there are any associated beacons' and 'sends a command to turn off the LED for each associated beacon', but the code only checks if the POC is null and calls PowerOffLed(poc) once." -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Documentation claims the method 'updates the in-memory cache to reflect that the beacon is now off for the specified location', but there is no cache update visible in the code." -->
public async Task PowerOffLed(ObjectId pocId)
{
var poc = await _pointOfCareService.FindById(pocId);
@@ -100,6 +106,7 @@ public class LightBeaconService : ILightBeaconService
/// <param name="beacon">The light beacon configuration to insert.</param>
/// <returns>The inserted light beacon configuration, or null if the insertion failed.</returns>
/// <exception cref="Exception">Thrown if a light beacon with the same name already exists.</exception>
/// <!-- aidoc:v1 sig=1e12f08 body=64da6ee -->
public async Task<LightBeacon?> InsertOne(LightBeacon beacon)
{
var beaconFound = await _lightBeaconRepository.GetByName(beacon.Name);
@@ -113,6 +120,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="filter">The pagination filter to apply when retrieving the light beacons.</param>
/// <returns>A paginated response containing the light beacons that match the specified filter.</returns>
/// <!-- aidoc:v1 sig=415719d body=b8cd5a5 -->
public async Task<PaginationResponse<LightBeacon>> GetPaginatedBeacons(PaginationFilter filter)
{
var usedRelayIds = await _pointOfCareService.FindAllIdBeaconsInUse();
@@ -158,6 +166,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="textToSearch">The text to search for in the names of the light beacons.</param>
/// <returns>A list of light beacons whose names contain the specified search text.</returns>
/// <!-- aidoc:v1 sig=31a792d body=850cd31 -->
public async Task<List<LightBeacon>> GetSearchByName(string textToSearch)
{
return await _lightBeaconRepository.GetSearchByName(textToSearch);
@@ -169,6 +178,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="beacon">The light beacon object with updated properties.</param>
/// <returns>The updated light beacon configuration, or null if the update failed.</returns>
/// <!-- aidoc:v1 sig=44d83e6 body=0b996e1 -->
public async Task<LightBeacon?> UpdateOne(LightBeacon beacon)
{
await _lightBeaconRepository.UpdateOneAsync(beacon.Id, beacon);
@@ -181,6 +191,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="poc">The point of care for which to power off the LED.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=3da8578 body=b74440d -->
public async Task PowerOffLed(PointOfCare poc)
{
if (_locationsWithColor.TryGetValue(poc.Id, out var lightBeaconColor) &&
@@ -209,6 +220,7 @@ public class LightBeaconService : ILightBeaconService
/// Generates a color alert for a patient observation by determining the appropriate color based on the observation's status and configured colors for warnings and alerts.
/// </summary>
/// <param name="obs">The patient observation for which to generate the color alert.</param>
/// <!-- aidoc:v1 sig=c0724e7 body=242d283 -->
public void GenerateColorAlert(PatientObservation obs)
{
try
@@ -294,6 +306,8 @@ public class LightBeaconService : ILightBeaconService
/// <param name="pocId">The ID of the point of care for which to send the color command.</param>
/// <param name="color">The color to set on the light beacon.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Documentation claims the method checks for associated beacons and sends a color command for each associated beacon, but the code only checks if the point of care is null and calls a single SendColor overload without any beacon check or iteration." -->
public async Task SendColor(ObjectId pocId, LightBeaconColor color)
{
var poc = await _pointOfCareService.FindById(pocId);
@@ -308,6 +322,7 @@ public class LightBeaconService : ILightBeaconService
/// <param name="poc">The point of care for which to send the color command.</param>
/// <param name="color">The color to set on the light beacon.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=5217200 body=5ad71ce -->
public async Task SendColor(PointOfCare poc, LightBeaconColor color)
{
try
@@ -361,6 +376,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="pocId">The ID of the point of care for which to retrieve the color state.</param>
/// <returns>A task representing the asynchronous operation, with the current color state of the light beacon.</returns>
/// <!-- aidoc:v1 sig=e927281 body=f729d62 -->
public async Task<LightBeaconColor> GetColor(ObjectId pocId)
{
var poc = await _pointOfCareService.FindById(pocId);
@@ -373,6 +389,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="poc">The point of care for which to retrieve the color state.</param>
/// <returns>A task representing the asynchronous operation, with the current color state of the light beacon.</returns>
/// <!-- aidoc:v1 sig=9ff58e8 body=3531e3b -->
public async Task<LightBeaconColor> GetColor(PointOfCare poc)
{
try
@@ -403,6 +420,7 @@ public class LightBeaconService : ILightBeaconService
/// <param name="poc">The point of care for which to send the color command.</param>
/// <param name="color">The color to set on the light beacon.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=e30390e body=ebb3633 -->
public async Task SendBeaconBroadcast(PointOfCare poc, LightBeaconColor color)
{
var subscribers = _subscribersService.GetSubscribers()
@@ -420,6 +438,7 @@ public class LightBeaconService : ILightBeaconService
/// <param name="pocId">The ID of the point of care for which to send the color command.</param>
/// <param name="color">The color to set on the light beacon.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=e72960d body=fd03c04 -->
public async Task SendBeaconBroadcast(ObjectId pocId, LightBeaconColor color)
{
var poc = await _pointOfCareService.FindById(pocId);
@@ -433,6 +452,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="body">The body of the message to send.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=df9f7f5 body=365678a -->
private async Task SendMessage(string body)
{
if (string.IsNullOrEmpty(Url))
@@ -465,6 +485,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="lightBeaconId">The ID of the light beacon to retrieve.</param>
/// <returns>A task representing the asynchronous operation, with a result of the light beacon device instance if found; otherwise, null.</returns>
/// <!-- aidoc:v1 sig=f305e9f body=070796e -->
private async Task<LightBeaconDevice?> GetBeacon(ObjectId lightBeaconId)
{
var cfg = await _lightBeaconRepository.GetById(lightBeaconId);
@@ -491,6 +512,7 @@ public class LightBeaconService : ILightBeaconService
/// </summary>
/// <param name="dictionary"></param>
/// <returns></returns>
/// <!-- aidoc:v1 sig=ee90706 body=21dd886 -->
public static string DictionaryToString(ConcurrentDictionary<ObjectId, LightBeaconColor> dictionary)
{
var builder = new StringBuilder();