diff --git a/adas-core.Application/Customizations/HGM/CalculatedObservations.cs b/adas-core.Application/Customizations/HGM/CalculatedObservations.cs index 7841995f..59a2b41e 100644 --- a/adas-core.Application/Customizations/HGM/CalculatedObservations.cs +++ b/adas-core.Application/Customizations/HGM/CalculatedObservations.cs @@ -22,6 +22,12 @@ public class CalculatedObservations : ICalculatedObservations private readonly List _nonInvasiveVentilation = []; private readonly Lazy _observationService; + /// + /// Initializes a new instance of the class by resolving its required dependencies from the supplied and loading the configured high-frequency, invasive, and non-invasive ventilation category lists from . + /// + /// The used to resolve , , and a . + /// Thrown when a required dependency cannot be resolved from . + /// public CalculatedObservations(IServiceProvider serviceProvider) { var apiSettings = serviceProvider.GetRequiredService>().Value; diff --git a/adas-core.Application/Customizations/HUVH/UCIA/CalculatedObservations.cs b/adas-core.Application/Customizations/HUVH/UCIA/CalculatedObservations.cs index 984b326f..05682e36 100644 --- a/adas-core.Application/Customizations/HUVH/UCIA/CalculatedObservations.cs +++ b/adas-core.Application/Customizations/HUVH/UCIA/CalculatedObservations.cs @@ -35,6 +35,11 @@ public class CalculatedObservations : ICalculatedObservations private readonly Lazy _treatmentService; + /// + /// Initializes a new instance of the class, which provides calculated observations derived from treatment and medicine data, by resolving its required service dependencies and medication reference lists from . + /// + /// The used to resolve the required service dependencies and configuration options. + /// public CalculatedObservations(IServiceProvider serviceProvider) { _treatmentService = serviceProvider.GetRequiredService>(); diff --git a/adas-core.Application/Customizations/HUVH/UCIN/CalculatedObservations.cs b/adas-core.Application/Customizations/HUVH/UCIN/CalculatedObservations.cs index 13f32041..08a7bfc4 100644 --- a/adas-core.Application/Customizations/HUVH/UCIN/CalculatedObservations.cs +++ b/adas-core.Application/Customizations/HUVH/UCIN/CalculatedObservations.cs @@ -38,6 +38,12 @@ public class CalculatedObservations : ICalculatedObservations private readonly Lazy _treatmentService; + /// + /// Initializes a new instance of the class by resolving its treatment, medicine, observation, logging, and mapping dependencies from the supplied . + /// + /// The used to obtain the dependencies required by this instance. + /// Thrown when a required service cannot be resolved from . + /// public CalculatedObservations(IServiceProvider serviceProvider) { _treatmentService = serviceProvider.GetRequiredService>(); diff --git a/adas-core.Application/Providers/AdasProvider.cs b/adas-core.Application/Providers/AdasProvider.cs index f8244eb8..05b38503 100644 --- a/adas-core.Application/Providers/AdasProvider.cs +++ b/adas-core.Application/Providers/AdasProvider.cs @@ -7,6 +7,13 @@ using Serilog; namespace adas_core.Application.Providers; +/// +/// Represents an ADAS (Advanced Driver Assistance Systems) data provider that retrieves driver assistance observations through the shared infrastructure defined by . +/// +/// +/// The constructor forwards the supplied of type and the of type to , ensuring consistent configuration and HTTP client management across all providers. +/// +/// public class AdasProvider(IOptions providerSettings, IHttpClientFactory httpClientFactory) : BaseProvider(providerSettings, httpClientFactory) { diff --git a/adas-core.Application/Providers/BaseProvider.cs b/adas-core.Application/Providers/BaseProvider.cs index c4dd7875..b11ae8c8 100644 --- a/adas-core.Application/Providers/BaseProvider.cs +++ b/adas-core.Application/Providers/BaseProvider.cs @@ -5,6 +5,10 @@ using Microsoft.Extensions.Options; namespace adas_core.Application.Providers; +/// +/// Provides an abstract base class for provider implementations that consume configuration through and create HTTP clients via . +/// +/// public abstract class BaseProvider( IOptions providerSettings, IHttpClientFactory httpClientFactory) diff --git a/adas-core.Application/Services/AdminPanelService.cs b/adas-core.Application/Services/AdminPanelService.cs index 916a8dd4..fc66111b 100644 --- a/adas-core.Application/Services/AdminPanelService.cs +++ b/adas-core.Application/Services/AdminPanelService.cs @@ -13,6 +13,13 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient; namespace adas_core.Application.Services; +/// +/// Provides the administrative panel operations defined by , integrating patient, admission, discharge, authentication, medicine, point-of-care, unit, display, and configurable observation services. +/// +/// +/// The service receives its collaborators through primary constructor injection, including , , , , , , , , and , along with configuration via and logging through . +/// +/// public class AdminPanelService( IOptions apiSettings, IPatientService patientService, @@ -205,6 +212,12 @@ public class AdminPanelService( return true; } + /// + /// Updates the location of a patient identified by the source location in , relocating any occupant of the target location to the point of care and creating a new record when no matching patient is found. + /// + /// The containing the original and the target values used to find and reassign the patient. + /// A that resolves to true once the update or insertion has completed. + /// public async Task UpdatePatientLocation(AdmPanelRequest request) { var patient = await patientService.FindByLocation(request.OldLocation); diff --git a/adas-core.Application/Services/AdmissionService.cs b/adas-core.Application/Services/AdmissionService.cs index 47b5c337..2256b58a 100644 --- a/adas-core.Application/Services/AdmissionService.cs +++ b/adas-core.Application/Services/AdmissionService.cs @@ -14,6 +14,13 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Provides admission-related operations and coordinates persistence, messaging, and clinical context services to manage the admission workflow. +/// +/// +/// This service implements and composes logging, subscriber notifications, admission data access, client messaging, unit, patient, point-of-care, display, discharge, patient archive, HTTP context, local audit, and master list factory collaborators to fulfill its contract. +/// +/// public class AdmissionService( ILogger logger, ISubscribersService subscribersService, diff --git a/adas-core.Application/Services/AlarmService.cs b/adas-core.Application/Services/AlarmService.cs index 280b7bd8..cfe9d0ff 100644 --- a/adas-core.Application/Services/AlarmService.cs +++ b/adas-core.Application/Services/AlarmService.cs @@ -51,6 +51,28 @@ public class AlarmService : IAlarmService private TimeSpan _interval; + /// + /// Initializes a new instance of the class, injecting required dependencies for alarm processing and optionally starting the internal alarm timer when is . + /// + /// The used to persist and retrieve alarm data. + /// The used for diagnostic logging. + /// The used to access patient information. + /// The used to retrieve observation configuration. + /// A providing deferred access to observation data. + /// The used to publish client notifications. + /// The used to manage alarm subscribers. + /// A providing deferred access to calculated observations. + /// A providing deferred access to the light beacon service. + /// A providing deferred access to the recording service. + /// A providing deferred access to the relay service. + /// The providing access to API configuration. + /// The used to manage unit information. + /// The used to access point-of-care information. + /// The used to access the current HTTP context. + /// The used to record audit entries. + /// A indicating whether the alarm timer should be started during construction. + /// Thrown when is . + /// public AlarmService(IAlarmRepository alarmRepository, ILogger logger, IPatientService patientService, diff --git a/adas-core.Application/Services/AppointmentService.cs b/adas-core.Application/Services/AppointmentService.cs index dbaf9bf3..c34e1708 100644 --- a/adas-core.Application/Services/AppointmentService.cs +++ b/adas-core.Application/Services/AppointmentService.cs @@ -14,6 +14,13 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient; namespace adas_core.Application.Services; +/// +/// Implements to coordinate appointment management operations, persisting data through and while integrating supporting services such as , , , and . +/// +/// +/// Defers initialization of and via , reads configuration through bound to ApiSettings and CacheSettings, logs diagnostics with , and accesses the current request through . It also relies on , , , , and to support auditing, point-of-care workflows, subscriber notifications, messaging, and caching. +/// +/// public class AppointmentService( IAppointmentRepository appointmentRepository, IAppointmentArchiveRepository appointmentArchiveRepository, diff --git a/adas-core.Application/Services/ArchivePatientCarePlanService.cs b/adas-core.Application/Services/ArchivePatientCarePlanService.cs index c1863b89..c98ad904 100644 --- a/adas-core.Application/Services/ArchivePatientCarePlanService.cs +++ b/adas-core.Application/Services/ArchivePatientCarePlanService.cs @@ -7,6 +7,14 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements to provide the application service responsible for archiving patient care plans. +/// Collaborates with for data access, for diagnostics, for HTTP context retrieval, and for local auditing. +/// +/// +/// The collaborators are supplied through the primary constructor, allowing the service to fulfill the contract defined by . +/// +/// public class ArchivePatientCarePlanService( IArchivePatientCarePlanRepository archivedPatientRepository, ILogger logger, diff --git a/adas-core.Application/Services/ArchivePatientObservationsService.cs b/adas-core.Application/Services/ArchivePatientObservationsService.cs index f0d1307d..73d88ff9 100644 --- a/adas-core.Application/Services/ArchivePatientObservationsService.cs +++ b/adas-core.Application/Services/ArchivePatientObservationsService.cs @@ -5,6 +5,13 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements to archive patient observations through the supplied . +/// +/// +/// The archive repository dependency is provided via the primary constructor and is used to perform the underlying archiving operations. +/// +/// public class ArchivePatientObservationsService(IObservationArchiveRepository archivedPatientObservationService) : IArchivedPatientObservationService { diff --git a/adas-core.Application/Services/ArchivedPatientTreatmentService.cs b/adas-core.Application/Services/ArchivedPatientTreatmentService.cs index b8b8af63..36063634 100644 --- a/adas-core.Application/Services/ArchivedPatientTreatmentService.cs +++ b/adas-core.Application/Services/ArchivedPatientTreatmentService.cs @@ -5,6 +5,10 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements and provides archived patient treatment operations using an injected . +/// +/// public class ArchivedPatientTreatmentService(ITreatmentArchiveRepository archivedPatientTreatmentService) : IArchivedPatientTreatmentService { diff --git a/adas-core.Application/Services/AuthService.cs b/adas-core.Application/Services/AuthService.cs index f3886665..7dd2b9a1 100644 --- a/adas-core.Application/Services/AuthService.cs +++ b/adas-core.Application/Services/AuthService.cs @@ -24,6 +24,14 @@ public class AuthService : IAuthService //private LoginResponse? _loginResponse; + /// + /// Initializes a new instance of the class, capturing the recording settings, logger, and authority repository required for authentication operations. + /// + /// The providing access to the configured . + /// The used to log authentication activity. + /// The used to access authority data. + /// Thrown when .Value is . + /// public AuthService(IOptions recordingSettings, ILogger logger, IAuthorityRepository authorityRepository) { diff --git a/adas-core.Application/Services/Caching/NoCacheService.cs b/adas-core.Application/Services/Caching/NoCacheService.cs index 8ea95a2c..026412cb 100644 --- a/adas-core.Application/Services/Caching/NoCacheService.cs +++ b/adas-core.Application/Services/Caching/NoCacheService.cs @@ -115,6 +115,16 @@ namespace adas_core.Application.Services.Caching // GET OR SET - STRING KEY // ============================================================ + /// + /// Retrieves or creates an object asynchronously. When the cache mode is NONE, this method bypasses caching entirely and always invokes to produce the result. + /// + /// The type of the object to retrieve or create. + /// The cache key used to identify the cached object. + /// The asynchronous factory delegate that produces the value when no cached entry exists. + /// An optional indicating the time-to-live for the cache entry. + /// A to observe while waiting for the task to complete. + /// A containing the value produced by . + /// public async Task GetOrSetObjectAsync( string key, Func> factory, @@ -145,6 +155,16 @@ namespace adas_core.Application.Services.Caching // GET OR SET - GroupedField + patientId // ============================================================ + /// + /// Retrieves or creates an object asynchronously for the specified patient. This implementation does not perform caching and always invokes the supplied to produce the result, corresponding to the disabled-cache (NONE) mode. + /// + /// The grouped field that categorizes the object being retrieved. + /// The identifier of the patient to whom the object belongs. + /// The asynchronous factory delegate invoked to produce the object. + /// An optional time-to-live for the cached entry. Ignored because caching is disabled. + /// The token used to observe cancellation of the factory invocation. + /// A task that yields the object produced by . + /// public async Task GetOrSetObjectAsync( GroupedField groupedField, ObjectId patientId, diff --git a/adas-core.Application/Services/Caching/RedisService.cs b/adas-core.Application/Services/Caching/RedisService.cs index 9c94261b..b7f91f4f 100644 --- a/adas-core.Application/Services/Caching/RedisService.cs +++ b/adas-core.Application/Services/Caching/RedisService.cs @@ -28,6 +28,13 @@ namespace adas_core.Application.Services.Caching public IDatabase? Database => _database; private bool _isRedisAvailable; + /// + /// Initializes a new instance of , capturing the bound , , and dependencies, and starting asynchronous Redis connection setup when a connection string is configured. + /// + /// The that exposes the bound whose Redis section drives connection initialization. + /// The used for diagnostic logging. + /// The used to coordinate distributed locks on the Redis instance. + /// public RedisService( IOptions options, ILogger logger, diff --git a/adas-core.Application/Services/CalculatedObservationsService.cs b/adas-core.Application/Services/CalculatedObservationsService.cs index cbd6317c..cb04f05f 100644 --- a/adas-core.Application/Services/CalculatedObservationsService.cs +++ b/adas-core.Application/Services/CalculatedObservationsService.cs @@ -17,6 +17,13 @@ public class CalculatedObservationsService : ICalculatedObservationsService private readonly ILogger? _logger; + /// + /// Initializes a new instance of the , resolving the internal implementation from the configured customization or falling back to . + /// + /// The providing the customization name used to locate the calculation implementation type. + /// The supplied to the resolved customization type's constructor. + /// The used to log warnings when the customization cannot be resolved. + /// public CalculatedObservationsService( IOptions apiSettings, IServiceProvider serviceProvider, diff --git a/adas-core.Application/Services/ConfigObservationService.cs b/adas-core.Application/Services/ConfigObservationService.cs index fadc9e17..2721fe1c 100644 --- a/adas-core.Application/Services/ConfigObservationService.cs +++ b/adas-core.Application/Services/ConfigObservationService.cs @@ -50,6 +50,18 @@ public class ConfigObservationService : IConfigObservationService private bool IgnoreUnknownObservation => _apiSettings.Value.ConfigObservation?.IgnoreUnknownObservation ?? false; + /// + /// Initializes a new instance of the class, storing its required dependencies and reading configuration values from the supplied instances to establish internal operational defaults such as the refresh timeout, unknown treatment handling, and retention policy. + /// + /// The used to access configuration observation data. + /// The providing API configuration values, including the refresh interval and retention policy defaults. + /// The providing cache configuration values. + /// The used for diagnostic logging. + /// The used to perform unit-related operations. + /// The used to access the current HTTP context. + /// The used to record local audit entries. + /// The used for caching operations. + /// public ConfigObservationService( IConfigObservationRepository configObservationRepository, IOptions apiSettings, diff --git a/adas-core.Application/Services/ConfigPumpsService.cs b/adas-core.Application/Services/ConfigPumpsService.cs index 33b347ae..a6dd56d1 100644 --- a/adas-core.Application/Services/ConfigPumpsService.cs +++ b/adas-core.Application/Services/ConfigPumpsService.cs @@ -12,6 +12,14 @@ using Microsoft.Extensions.Options; namespace adas_core.Application.Services; +/// +/// Implements the contract to manage configuration operations for pumps. +/// +/// +/// This service relies on an for data access, an for API configuration, +/// an for diagnostics, an for HTTP context retrieval, and an for auditing operations. +/// +/// public class ConfigPumpsService( IConfigPumpsRepository configPumpsRepository, IOptions apiSettings, diff --git a/adas-core.Application/Services/ConfigUnitsService.cs b/adas-core.Application/Services/ConfigUnitsService.cs index c1f96039..36330d0b 100644 --- a/adas-core.Application/Services/ConfigUnitsService.cs +++ b/adas-core.Application/Services/ConfigUnitsService.cs @@ -10,6 +10,13 @@ using Microsoft.Extensions.Options; namespace adas_core.Application.Services; +/// +/// Implements to manage configuration units, +/// using for data persistence, +/// for API configuration values, +/// and for diagnostic logging. +/// +/// public class ConfigUnitsService( IConfigUnitsRepository configUnitsRepository, IOptions apiSettings, diff --git a/adas-core.Application/Services/DeviceService.cs b/adas-core.Application/Services/DeviceService.cs index 4a2ba1dc..91c039c1 100644 --- a/adas-core.Application/Services/DeviceService.cs +++ b/adas-core.Application/Services/DeviceService.cs @@ -22,6 +22,16 @@ public class DeviceService : IDeviceService private readonly IPointOfCareService _pointOfCareService; private readonly ILogger _logger; + /// + /// Initializes a new instance of the class, injecting the required collaborators used to manage device-related domain operations. + /// + /// The that provides persistence access for devices. + /// The used to coordinate point-of-care operations. + /// The used to emit diagnostic and operational logs. + /// The used to record and query observations. + /// The used to manage configured observation rules. + /// The used to raise and resolve alarms. + /// public DeviceService( IDeviceRepository deviceRepository, IPointOfCareService pointOfCareService, diff --git a/adas-core.Application/Services/DiagnosisService.cs b/adas-core.Application/Services/DiagnosisService.cs index ecd40afa..f2af030d 100644 --- a/adas-core.Application/Services/DiagnosisService.cs +++ b/adas-core.Application/Services/DiagnosisService.cs @@ -37,6 +37,21 @@ public class DiagnosisService : IDiagnosisService private readonly IUnitService _unitService; + /// + /// Initializes a new instance of the , which provides operations for managing diagnoses and their archives. The constructor stores injected collaborators and seeds the diagnosis system identifier and configured diagnosis codes from . + /// + /// A that resolves an for patient lookups. + /// The of providing configuration such as the diagnosis system and diagnosis codes. + /// The used to read and persist diagnoses. + /// The used to read and persist archived diagnoses. + /// The used to record diagnostic information. + /// The used to deliver messages to clients. + /// The used to notify subscribers of diagnosis events. + /// A that resolves an for derived observations. + /// The providing access to the current HTTP context. + /// The used to record local audit entries. + /// The used to manage measurement units. + /// public DiagnosisService( Lazy patientService, IOptions apiSettings, diff --git a/adas-core.Application/Services/DischargeService.cs b/adas-core.Application/Services/DischargeService.cs index ee60aa8f..2f2893df 100644 --- a/adas-core.Application/Services/DischargeService.cs +++ b/adas-core.Application/Services/DischargeService.cs @@ -35,6 +35,20 @@ public class DischargeService : IDischargeService private readonly ISubscribersService _subscribersService; private readonly IUnitService _unitService; + /// + /// Initializes a new instance of the class, which coordinates discharge-related operations by injecting its required collaborators into private fields for logging, persistence, patient access, messaging, auditing, and unit/master list resolution. + /// + /// The used to record diagnostic information for the . + /// The used to manage subscribers tied to discharge events. + /// The used to persist and retrieve discharge records. + /// The wrapping to defer patient service resolution. + /// The used to send client-facing messages. + /// The used to interact with point-of-care operations. + /// The used to access the current HTTP context. + /// The used to record local audit entries. + /// The used to look up unit-related information. + /// The used to create master list services on demand. + /// public DischargeService(ILogger logger, ISubscribersService subscribersService, IDischargeRepository dischargeRepository, @@ -281,6 +295,11 @@ public class DischargeService : IDischargeService } + /// + /// Processes an for patient discharge operations. Based on .Type it handles three cases: "NewDischarge" inserts a new discharge, creates an audit log, and sends a discharge broadcast (only when the patient status is "Altable"); "UpdateDischarge" updates the existing discharge; "DeleteDischarge" deletes the discharge (only when the patient status is "NoAltable"). The method returns early and logs an error when the discharge or patient is null, when the patient cannot be found, or when the corresponding discharge-status validation fails. + /// + /// The API request containing the discharge payload and the operation type to perform. + /// public async Task SaveRequest(ApiRequest apiRequest) { try diff --git a/adas-core.Application/Services/DisplayConfigService.cs b/adas-core.Application/Services/DisplayConfigService.cs index 981463e3..690c78ae 100644 --- a/adas-core.Application/Services/DisplayConfigService.cs +++ b/adas-core.Application/Services/DisplayConfigService.cs @@ -18,6 +18,13 @@ using DisplayConfig = adas_core.Domain.Models.MongoModels.DisplayConfig; namespace adas_core.Application.Services; +/// +/// Implements to coordinate display configuration operations across multiple repositories and supporting services. +/// +/// +/// The service composes card, detail, and chart configuration repositories with display, subscriber, messaging, auditing, and master list services to manage display configuration workflows. It receives for accessing the current HTTP context and uses of to defer initialization of the display service dependency. +/// +/// public class DisplayConfigService( IDisplayConfigRepository displayConfigRepository, Lazy displayService, diff --git a/adas-core.Application/Services/DisplayService.cs b/adas-core.Application/Services/DisplayService.cs index 9ca7d82b..e8a8d111 100644 --- a/adas-core.Application/Services/DisplayService.cs +++ b/adas-core.Application/Services/DisplayService.cs @@ -19,6 +19,13 @@ using MongoDB.Driver; namespace adas_core.Application.Services; +/// +/// Implements , coordinating display management operations +/// across data access (), configuration (), +/// authentication (), audit (), +/// and caching () concerns. +/// +/// public class DisplayService( IDisplayRepository displayRepository, IPointOfCareService pointOfCareService, diff --git a/adas-core.Application/Services/FileService.cs b/adas-core.Application/Services/FileService.cs index cb29f263..1b27430e 100644 --- a/adas-core.Application/Services/FileService.cs +++ b/adas-core.Application/Services/FileService.cs @@ -21,6 +21,12 @@ public class FileService : IFileService private readonly ILogger _logger; private readonly string? _updateDirectory; + /// + /// Initializes a new instance of the class, configuring the file system paths used to read update files and display assets and storing the logger used for diagnostic output. provides file-related operations backed by the supplied configuration. + /// + /// The bound application settings exposed via ; supplies the and paths used to build the working directories. + /// The retained for recording diagnostic and operational events. + /// public FileService( IOptions apiSettings, ILogger logger diff --git a/adas-core.Application/Services/GroupedObservationService.cs b/adas-core.Application/Services/GroupedObservationService.cs index 60016bae..2c07937d 100644 --- a/adas-core.Application/Services/GroupedObservationService.cs +++ b/adas-core.Application/Services/GroupedObservationService.cs @@ -25,6 +25,16 @@ public class GroupedObservationService : IGroupedObservationService private readonly ILogger _logger; private readonly IObservationRepository _observationRepository; + /// + /// Initializes a new instance of the , which coordinates the retrieval, configuration, caching, and logging of grouped observation data, by capturing the supplied dependencies. + /// + /// The used to access underlying observation records. + /// The used to resolve observation configuration. + /// The used to record diagnostic and operational messages. + /// The used to read from and write to the application cache. + /// The providing configurable API options. + /// The whose is stored as the resolved cache configuration. + /// public GroupedObservationService( IObservationRepository observationRepository, IConfigObservationService configObservationService, diff --git a/adas-core.Application/Services/HistoricalConfigChangesService.cs b/adas-core.Application/Services/HistoricalConfigChangesService.cs index 44804535..167a8492 100644 --- a/adas-core.Application/Services/HistoricalConfigChangesService.cs +++ b/adas-core.Application/Services/HistoricalConfigChangesService.cs @@ -10,6 +10,13 @@ using MongoDB.Driver; namespace adas_core.Application.Services; +/// +/// Provides operations for retrieving and managing historical configuration changes, delegating data access to an and coordinating logging, HTTP context, and auditing concerns. +/// +/// +/// Implements and uses for persistence, for diagnostics, for request context, and to record local audit entries. +/// +/// public class HistoricalConfigChangesService( IHistoricalConfigChangesRepository historicalConfigChangesRepository, ILogger logger, diff --git a/adas-core.Application/Services/LocalAuditService.cs b/adas-core.Application/Services/LocalAuditService.cs index fe2df503..5e797b2d 100644 --- a/adas-core.Application/Services/LocalAuditService.cs +++ b/adas-core.Application/Services/LocalAuditService.cs @@ -5,6 +5,10 @@ using Microsoft.Extensions.Logging; namespace adas_core.Application.Services; +/// +/// Implements the local auditing behavior defined by , forwarding audit operations to an inner and recording diagnostic information via an . +/// +/// public class LocalAuditService( IAuditService auditService, ILogger logger) diff --git a/adas-core.Application/Services/MasterListService.cs b/adas-core.Application/Services/MasterListService.cs index 0bdae9ad..f3bc3ac2 100644 --- a/adas-core.Application/Services/MasterListService.cs +++ b/adas-core.Application/Services/MasterListService.cs @@ -38,6 +38,22 @@ public class MasterListService : IMasterListService where T : MasterList, private readonly ISubscribersService _subscribersService; private readonly Lazy _unitService; + /// + /// Initializes a new instance of , a service that coordinates display, patient, unit, admission, discharge, subscriber and client messaging operations. The constructor stores the injected collaborators and, when specifies a display assets path, computes the assets directory via . + /// + /// The used by the service to emit diagnostic messages. + /// The used to resolve additional services at runtime. + /// A that defers creation of the until it is first accessed. + /// The used to manage subscribers. + /// A that defers creation of the until it is first accessed. + /// A that defers creation of the until it is first accessed. + /// A that defers creation of the until it is first accessed. + /// A that defers creation of the until it is first accessed. + /// A that defers creation of the until it is first accessed. + /// The providing access to the configured ; its property initializes the assets directory when not null. + /// The used to access the current HTTP context. + /// The used to record audit entries. + /// public MasterListService( ILogger> logger, IServiceProvider serviceProvider, diff --git a/adas-core.Application/Services/MasterListServiceFactory .cs b/adas-core.Application/Services/MasterListServiceFactory .cs index c0e2668b..7942420a 100644 --- a/adas-core.Application/Services/MasterListServiceFactory .cs +++ b/adas-core.Application/Services/MasterListServiceFactory .cs @@ -11,6 +11,13 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Factory class responsible for creating instances of master list services based on the supplied . +/// +/// +/// Implements and uses for dependency resolution along with for diagnostic logging. +/// +/// public class MasterListServiceFactory( IServiceProvider serviceProvider, ILogger logger, diff --git a/adas-core.Application/Services/MedicineService.cs b/adas-core.Application/Services/MedicineService.cs index a716f29c..b9d9be3e 100644 --- a/adas-core.Application/Services/MedicineService.cs +++ b/adas-core.Application/Services/MedicineService.cs @@ -14,6 +14,13 @@ using MongoDB.Driver; namespace adas_core.Application.Services; +/// +/// Implements and provides the application service responsible for medicine-related operations, coordinating and . +/// +/// +/// Configured via , instrumented with , supplied with the current HTTP context through , and audited by . +/// +/// public class MedicineService( IMedicineRepository medicineRepository, ITreatmentService treatmentService, diff --git a/adas-core.Application/Services/NoticeService.cs b/adas-core.Application/Services/NoticeService.cs index bb81ae60..5af6aee2 100644 --- a/adas-core.Application/Services/NoticeService.cs +++ b/adas-core.Application/Services/NoticeService.cs @@ -10,6 +10,17 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements , providing the coordination logic for managing +/// notices and delivering them through the configured subscriber, messaging, display, and audit subsystems. +/// +/// +/// Instances are created through a primary constructor that receives , +/// , , , +/// , , and +/// as injected collaborators. +/// +/// public class NoticeService( ILogger logger, ISubscribersService subscribersService, diff --git a/adas-core.Application/Services/ObservationDemoService.cs b/adas-core.Application/Services/ObservationDemoService.cs index cec41220..41d08db7 100644 --- a/adas-core.Application/Services/ObservationDemoService.cs +++ b/adas-core.Application/Services/ObservationDemoService.cs @@ -8,6 +8,13 @@ using adas_core.Domain.Utils; namespace adas_core.Application.Services; +/// +/// Provides a demo implementation of that coordinates observation handling using for configuration and a of for deferred alarm access. +/// +/// +/// The service is constructed with an for observation configuration and a lazily-initialized so that alarm functionality is created only on first use. +/// +/// public class ObservationDemoService( IConfigObservationService configObservationService, Lazy alarmService) diff --git a/adas-core.Application/Services/ObservationService.cs b/adas-core.Application/Services/ObservationService.cs index c1d04259..b95bee00 100644 --- a/adas-core.Application/Services/ObservationService.cs +++ b/adas-core.Application/Services/ObservationService.cs @@ -74,6 +74,33 @@ public class ObservationService : IObservationService private readonly ISubscribersService _subscribersService; + /// + /// Initializes a new instance of the class, storing the supplied collaborators in private fields and loading observation-code and cache configuration from the provided options. + /// + /// Provides access to patient data. + /// Provides observation configuration values. + /// Persists and retrieves observations. + /// Accesses archived observations. + /// Provides unit configuration. + /// Performs diagnosis-related operations. + /// The whose values seed the observation code settings. + /// The whose values configure caching behavior. + /// Controls light beacon devices. + /// Operates relay hardware. + /// Manages recordings. + /// Logs activity. + /// Handles grouped observation logic. + /// Raises and manages alarms. + /// Publishes messages to clients. + /// Tracks observation subscribers. + /// Manages grouped observation subscribers. + /// Defers creation of the calculated observations dependency. + /// Exposes the current HTTP context. + /// Writes local audit entries. + /// Handles point-of-care operations. + /// Reads from and writes to the cache. + /// Thrown when is null. + /// public ObservationService( IPatientService patientService, IConfigObservationService configObservationService, diff --git a/adas-core.Application/Services/PatientCarePlanService.cs b/adas-core.Application/Services/PatientCarePlanService.cs index 3d50f987..17a50aad 100644 --- a/adas-core.Application/Services/PatientCarePlanService.cs +++ b/adas-core.Application/Services/PatientCarePlanService.cs @@ -22,6 +22,16 @@ public class PatientCarePlanService : IPatientCarePlanService private readonly IPatientCarePlanRepository _patientCarePlanRepository; private readonly IUserRepository _userRepository; + /// + /// Initializes a new instance of the class, wiring in the dependencies required to manage, archive, and audit patient care plans. + /// + /// The used to record operational and diagnostic information. + /// The used to access patient care plan data. + /// The used to access user information. + /// The used to archive patient care plans. + /// The used to access the current HTTP context. + /// The used to record local audit information. + /// public PatientCarePlanService( ILogger logger, IPatientCarePlanRepository patientCarePlanRepository, diff --git a/adas-core.Application/Services/PatientService.cs b/adas-core.Application/Services/PatientService.cs index aa927aae..e28bd261 100644 --- a/adas-core.Application/Services/PatientService.cs +++ b/adas-core.Application/Services/PatientService.cs @@ -70,6 +70,36 @@ public class PatientService : IPatientService private readonly bool _updatePatientDataWithOru; private readonly bool _updatePatientLocationWithOru; + /// + /// Initializes a new instance of the class, storing its required repositories, services and helpers, and reading configuration values from and . + /// + /// The used to access patient data. + /// The used to access archived patient data. + /// The lazily resolved providing observation operations. + /// The lazily resolved providing treatment operations. + /// The used for point-of-care mappings. + /// The used to manage diagnoses. + /// The used to manage appointments. + /// The lazily resolved providing pump operations. + /// The used to handle recording alerts. + /// The used to manage discharges. + /// The exposing archive and HL7 related configuration values. + /// The exposing list related configuration values. + /// The used to log diagnostics. + /// The used to send client messages. + /// The used to manage subscribers. + /// The used to manage grouped subscribers. + /// The used to manage units. + /// The used to manage displays. + /// The used to manage point-of-care data. + /// The lazily resolved providing admission operations. + /// The used to manage display configuration. + /// The used to manage grouped observations. + /// The used to manage patient care plans. + /// The used to access the current HTTP context. + /// The used to record local audit entries. + /// The used to create master list services. + /// public PatientService( IPatientRepository patientRepository, IPatientArchiveRepository patientArchiveRepository, diff --git a/adas-core.Application/Services/PermissionService.cs b/adas-core.Application/Services/PermissionService.cs index c8cef723..7db76a4c 100644 --- a/adas-core.Application/Services/PermissionService.cs +++ b/adas-core.Application/Services/PermissionService.cs @@ -10,6 +10,11 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements to evaluate user permissions from the configured and the available authority data stores. +/// Resolves , , and through so their construction is deferred until needed. +/// +/// public class PermissionService( IOptions permissionsConfig, ILogger logger, diff --git a/adas-core.Application/Services/PoCMappingService.cs b/adas-core.Application/Services/PoCMappingService.cs index c30689a1..48d71a80 100644 --- a/adas-core.Application/Services/PoCMappingService.cs +++ b/adas-core.Application/Services/PoCMappingService.cs @@ -21,6 +21,12 @@ public class PoCMappingService : IPoCMappingService private PoCMapping? _mapping; private DateTime _nextRefresh = DateTime.MinValue; + /// + /// Initializes a new instance of the class, storing the supplied repository and capturing point-of-care mapping configuration values from . + /// + /// The used by the service to access mapping data. + /// The providing access to the point-of-care mapping settings. + /// public PoCMappingService(IPoCMappingRepository pocMappingRepository, IOptions apiSettings) { _pocMappingRepository = pocMappingRepository; diff --git a/adas-core.Application/Services/PointOfCareService.cs b/adas-core.Application/Services/PointOfCareService.cs index 64ac0c7e..e617e8e3 100644 --- a/adas-core.Application/Services/PointOfCareService.cs +++ b/adas-core.Application/Services/PointOfCareService.cs @@ -17,6 +17,20 @@ using MongoDB.Driver; namespace adas_core.Application.Services; +/// +/// Implements to provide point-of-care business logic that +/// coordinates persistence, patient, unit, admission, messaging, audit, and caching concerns +/// through its injected collaborators. +/// +/// +/// The service uses for data access and +/// for logging. , , +/// , and are resolved lazily +/// via . Additional collaborators include , +/// , , , +/// and bound to CacheSettings. +/// +/// public class PointOfCareService( ILogger logger, IPointOfCareRepository pointOfCareRepository, diff --git a/adas-core.Application/Services/RecordingAlertService.cs b/adas-core.Application/Services/RecordingAlertService.cs index 8ef5ec37..54c8038d 100644 --- a/adas-core.Application/Services/RecordingAlertService.cs +++ b/adas-core.Application/Services/RecordingAlertService.cs @@ -10,6 +10,13 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements to manage recording alerts, coordinating patient lookup, observation configuration, alert persistence, client messaging, subscribers, auditing, and HTTP context access. +/// +/// +/// Uses and for alert persistence, and lazily resolves through . +/// +/// public class RecordingAlertService( Lazy patientService, IConfigObservationService configObservationService, diff --git a/adas-core.Application/Services/RecordingService.cs b/adas-core.Application/Services/RecordingService.cs index 75c70951..6e7de36d 100644 --- a/adas-core.Application/Services/RecordingService.cs +++ b/adas-core.Application/Services/RecordingService.cs @@ -38,6 +38,21 @@ public class RecordingService : IRecordingService private AccessGrant? _accessGrant; + /// + /// Initializes a new instance of the class, resolving configuration options and service dependencies required to coordinate recording operations over HTTP and RabbitMQ. + /// + /// The RabbitMQ configuration options used to derive the recording queue name from . + /// The recording configuration options providing the API URL and HTTP client timeout; must be supplied. + /// The logger used to record diagnostic information. + /// The factory used to create the underlying . + /// The service used to publish messages. + /// The authentication service used to obtain access grants. + /// The API configuration options; provides the flag. + /// The service used to handle client messages. + /// The service used to manage subscribers. + /// The lazily resolved patient service used to look up patient information. + /// Thrown when does not provide a value. + /// public RecordingService(IOptions rabbitMqSettings, IOptions recordingSettings, ILogger logger, diff --git a/adas-core.Application/Services/ServiceConfigService.cs b/adas-core.Application/Services/ServiceConfigService.cs index ab8eabb0..eef53a76 100644 --- a/adas-core.Application/Services/ServiceConfigService.cs +++ b/adas-core.Application/Services/ServiceConfigService.cs @@ -8,6 +8,13 @@ using MongoDB.Bson; namespace adas_core.Application.Services; +/// +/// Implements , coordinating service configuration operations by persisting data through and emitting diagnostics via . +/// +/// +/// The class receives its collaborator and via the primary constructor parameters and . +/// +/// public class ServiceConfigService( IServiceConfigRepository serviceConfigRepository, ILogger logger) diff --git a/adas-core.Application/Services/UnitService.cs b/adas-core.Application/Services/UnitService.cs index a63b4657..124a1d99 100644 --- a/adas-core.Application/Services/UnitService.cs +++ b/adas-core.Application/Services/UnitService.cs @@ -16,6 +16,13 @@ using Serilog; namespace adas_core.Application.Services; +/// +/// Implements , coordinating unit-related operations by persisting data through and integrating with patient, master list, subscriber, client messaging, point-of-care, and auditing services. +/// +/// +/// Collaborators exposed as ( and ) are instantiated on demand. The service uses for structured logging, to access the current HTTP context, and to record audit entries. +/// +/// public class UnitService( IUnitRepository unitRepository, Lazy patientService, diff --git a/adas-core.Application/Subscriptions/WsSubscriberGrouped.cs b/adas-core.Application/Subscriptions/WsSubscriberGrouped.cs index 15f9aa7f..48e4ca67 100644 --- a/adas-core.Application/Subscriptions/WsSubscriberGrouped.cs +++ b/adas-core.Application/Subscriptions/WsSubscriberGrouped.cs @@ -20,6 +20,16 @@ public class WsSubscriberGrouped { private readonly EventHandler _sendEvent; + /// + /// Initializes a new instance of that registers in the shared WsSubscriber collection and copies the grouping configuration from . The constructor also seeds the last-observation state through , computes the identity hash via , and starts the internal that drives periodic emission through . + /// + /// The of the patient whose grouped observations this subscriber tracks. + /// The web socket subscriber identifier added to the shared WsSubscriber list and used as the key in the per-instance group dictionary. + /// The Windows or IANA time zone identifier applied to the observations; when null, falls back to Romance Standard Time. + /// The providing the grouping configuration consumed for names, max, since, start time shift, regularity, result, and group key. + /// The most recent passed to to initialize the last-observation state. + /// The invoked by the timer to forward outgoing messages to the subscriber. + /// public WsSubscriberGrouped(ObjectId patientId, string wsId, string? timeZoneId, GroupedField gf, GroupedObservation lastGroupedObservationObs, EventHandler sendEvent) { @@ -82,6 +92,12 @@ public class WsSubscriberGrouped } } + /// + /// Handles the timer elapsed event by stopping the timer, checking whether any cached grouped observation matches the current time at the configured granularity (second, minute, day, or hour by default), invoking the send event when no match is found, and restarting the timer. + /// + /// The source of the timer elapsed event. + /// The instance containing the elapsed event data. + /// private void Timer_Elapsed(object? sender, ElapsedEventArgs e) { var currentDateTime = DateTime.Now; diff --git a/adas-core.Authentication/Attributes/AuthorizeRolesAttribute.cs b/adas-core.Authentication/Attributes/AuthorizeRolesAttribute.cs index 552b5390..d913fbd7 100644 --- a/adas-core.Authentication/Attributes/AuthorizeRolesAttribute.cs +++ b/adas-core.Authentication/Attributes/AuthorizeRolesAttribute.cs @@ -5,6 +5,14 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace adas_core.Authentication.Attributes; +/// +/// Specifies an authorization filter attribute that restricts access to decorated methods based on a required role of type . +/// Inherits from and implements to participate in the authorization pipeline. +/// +/// +/// Constrained by to , the attribute is configured at construction with the required . +/// +/// [AttributeUsage(AttributeTargets.Method)] public class AuthorizeRolesAttribute(PermissionEnum.RolesType type) : Attribute, IAuthorizationFilter { diff --git a/adas-core.Authentication/Attributes/AuthorizeUserByService.cs b/adas-core.Authentication/Attributes/AuthorizeUserByService.cs index ee1d239b..04664b46 100644 --- a/adas-core.Authentication/Attributes/AuthorizeUserByService.cs +++ b/adas-core.Authentication/Attributes/AuthorizeUserByService.cs @@ -4,6 +4,13 @@ using Microsoft.AspNetCore.Mvc.Filters; namespace adas_core.Authentication.Attributes; +/// +/// Represents an authorization attribute that enforces permission-based access control using the injected . +/// +/// +/// Inherits from and implements , allowing it to be applied to controllers or actions and integrated into the request filtering pipeline. +/// +/// public class AuthorizePermissionsAttribute( IUserService userService) : Attribute, IAuthorizationFilter diff --git a/adas-core.Authentication/Attributes/PermissionAuthorizeAttribute.cs b/adas-core.Authentication/Attributes/PermissionAuthorizeAttribute.cs index 0f2306a3..5e29aea2 100644 --- a/adas-core.Authentication/Attributes/PermissionAuthorizeAttribute.cs +++ b/adas-core.Authentication/Attributes/PermissionAuthorizeAttribute.cs @@ -9,6 +9,14 @@ using Microsoft.Extensions.DependencyInjection; namespace adas_core.Authentication.Attributes; +/// +/// Represents an authorization attribute that evaluates permissions using a configured source and an optional resource identifier header. +/// +/// +/// Extends and implements to support asynchronous authorization filtering. +/// The primary constructor parameter specifies the permission source, while the optional identifies the header that carries the resource identifier. +/// +/// public class PermissionAuthorizeAttribute(string source, string? resourceIdHeader = null) : AuthorizeAttribute, IAsyncAuthorizationFilter { diff --git a/adas-core.Authentication/AuthorityService.cs b/adas-core.Authentication/AuthorityService.cs index a52009d3..0c48c208 100644 --- a/adas-core.Authentication/AuthorityService.cs +++ b/adas-core.Authentication/AuthorityService.cs @@ -8,6 +8,12 @@ using Serilog; namespace adas_core.Authentication; +/// +/// Implements , coordinating authority-related operations through +/// for data access, for +/// HTTP context access, and for local auditing. +/// +/// public class AuthorityService( IAuthorityRepository authorityRepository, IHttpContextAccessor httpContextAccessor, diff --git a/adas-core.Authentication/Models/UciResponse.cs b/adas-core.Authentication/Models/UciResponse.cs index 3adca8d8..ad41595b 100644 --- a/adas-core.Authentication/Models/UciResponse.cs +++ b/adas-core.Authentication/Models/UciResponse.cs @@ -6,10 +6,20 @@ /// The type of the response payload. public class UciResponse { + /// + /// Initializes a new instance of the class with default values. + /// This protected parameterless constructor enables the type to be instantiated by derived classes. + /// + /// protected UciResponse() { } + /// + /// Initializes a successful instance of the class, which wraps an entity as a response payload. The constructor assigns to , sets to true, and clears and . + /// + /// The payload to encapsulate in the response, stored in the property. + /// protected UciResponse(T entity) { Success = true; diff --git a/adas-core.Authentication/UserService.cs b/adas-core.Authentication/UserService.cs index a341aa85..64ae17ae 100644 --- a/adas-core.Authentication/UserService.cs +++ b/adas-core.Authentication/UserService.cs @@ -47,6 +47,25 @@ public class UserService : IUserService private readonly ISubscribersService _subscribersService; private readonly IClientMessageService _clientMessageService; private readonly Lazy _permissionService; + /// + /// Initializes a new instance of the class, capturing the supplied authentication, authorization, user data and logging collaborators for use by subsequent operations. + /// + /// The collection of implementations used to enumerate available login methods. + /// The wrapper whose define the supported login methods. + /// The wrapper providing the configured valid user groups. + /// The wrapper whose supplies the users white list. + /// The wrapper whose supplies the JWT configuration. + /// The used to access the current HTTP context. + /// The used to read and persist user data. + /// The used to perform authority and authorization operations. + /// The used to record local audit entries. + /// A wrapper providing deferred access to display services. + /// The used to log diagnostics for the . + /// The used to manage subscribers. + /// The used to send messages to clients. + /// A wrapper providing deferred access to permission checks. + /// Thrown when the JWT configuration provided by is not configured. + /// public UserService( IEnumerable loginServices, IOptions configuration, @@ -150,6 +169,13 @@ public class UserService : IUserService } } + /// + /// Retrieves a based on the username extracted from the provided . + /// Returns when the token is null or the user cannot be found, clears the retrieved user's password before returning, and lazily loads authorization data from the authority service when it is not already populated. + /// + /// The containing the user identity claims, or to indicate no token was supplied. + /// A that resolves to the matching with its password cleared and authorization loaded if required, or when the token is missing or no user matches the extracted username. + /// public async Task GetUserByToken(JwtSecurityToken? jwtToken) { User? user = null; diff --git a/adas-core.Domain/Exceptions/BusinessException.cs b/adas-core.Domain/Exceptions/BusinessException.cs index cd48d9a6..ad53c291 100644 --- a/adas-core.Domain/Exceptions/BusinessException.cs +++ b/adas-core.Domain/Exceptions/BusinessException.cs @@ -7,10 +7,22 @@ namespace adas_core.Domain.Exceptions; /// public class BusinessException : AggregateException { + /// + /// Initializes a new instance of the class with the supplied and message, forwarding their combined textual representation to the base exception constructor. represents errors raised by business logic that are associated with an HTTP status. + /// + /// The that identifies the nature of the business error. + /// The descriptive message that provides additional context for the error. + /// public BusinessException(HttpStatusCode status, string message) : base($"{status}: {message}") { } + /// + /// Initializes a new instance of the class, which represents errors in business logic, by passing the specified error message and inner to the base class constructor. + /// + /// The error message that describes the reason for the exception. + /// The inner that is the cause of the current exception, or if no inner exception is specified. + /// public BusinessException(string message, Exception exception) : base(message, exception) { } diff --git a/adas-core.Domain/Exceptions/LoginServicesException.cs b/adas-core.Domain/Exceptions/LoginServicesException.cs index f305684c..2ddb0a6a 100644 --- a/adas-core.Domain/Exceptions/LoginServicesException.cs +++ b/adas-core.Domain/Exceptions/LoginServicesException.cs @@ -11,11 +11,22 @@ namespace adas_core.Domain.Exceptions; /// public class LoginServicesException : BusinessException { + /// + /// Initializes a new instance of the class with a descriptive error message, forwarding it to the base exception together with an HTTP status code. + /// + /// The error message that describes the login service failure. + /// public LoginServicesException(string message) : base(HttpStatusCode.BadRequest, $"Login service error: {message}") { } + /// + /// Initializes a new instance of the class, which represents errors that occur in the login service. The supplied is prefixed with a service-context note and the underlying is preserved as the inner exception. + /// + /// The error message describing the login service failure. + /// The inner that caused the current exception. + /// public LoginServicesException(string message, Exception exception) : base($"Login service error: {message}", exception) { diff --git a/adas-core.Domain/Exceptions/LoginServicesNotFoundException.cs b/adas-core.Domain/Exceptions/LoginServicesNotFoundException.cs index 175d5428..f8120290 100644 --- a/adas-core.Domain/Exceptions/LoginServicesNotFoundException.cs +++ b/adas-core.Domain/Exceptions/LoginServicesNotFoundException.cs @@ -2,5 +2,12 @@ namespace adas_core.Domain.Exceptions; +/// +/// Represents the exception that is thrown when no login services are available to handle authentication requests. +/// +/// +/// This exception derives from and is raised with the status code and the message "No login services available". +/// +/// public class LoginServicesNotFoundException() : BusinessException(HttpStatusCode.Forbidden, "No login services available"); \ No newline at end of file diff --git a/adas-core.Domain/Exceptions/UserNotFoundException.cs b/adas-core.Domain/Exceptions/UserNotFoundException.cs index 00d0b4a2..efe49475 100644 --- a/adas-core.Domain/Exceptions/UserNotFoundException.cs +++ b/adas-core.Domain/Exceptions/UserNotFoundException.cs @@ -10,11 +10,22 @@ namespace adas_core.Domain.Exceptions; /// public class UserNotFoundException : BusinessException { + /// + /// Initializes a new instance of the class with a status code and a message identifying the missing . + /// + /// The username of the user that could not be found. + /// public UserNotFoundException(string username) : base(HttpStatusCode.NotFound, $"USER with username {username} not found") { } + /// + /// Initializes a new instance of the class with the username that could not be found and a wrapped inner . + /// + /// The username that was not found. + /// The inner that caused this exception to be raised. + /// public UserNotFoundException(string username, Exception exception) : base( $"USER with username {username} not found", exception) { diff --git a/adas-core.Domain/Models/AppSettings/AuthSettings.cs b/adas-core.Domain/Models/AppSettings/AuthSettings.cs index 3dea30bd..ae6e8a19 100644 --- a/adas-core.Domain/Models/AppSettings/AuthSettings.cs +++ b/adas-core.Domain/Models/AppSettings/AuthSettings.cs @@ -70,6 +70,10 @@ public class UsersWhiteListConfig : List /// /// This type serves as a container or marker for grouping validation logic within a broader validation framework. /// +/// +/// Represents a group that has been validated as meeting the required criteria. +/// +/// public class ValidGroupsConfig : List { /// diff --git a/adas-core.Domain/Models/AppSettings/PermissionSettings.cs b/adas-core.Domain/Models/AppSettings/PermissionSettings.cs index b25b2f09..225d81fa 100644 --- a/adas-core.Domain/Models/AppSettings/PermissionSettings.cs +++ b/adas-core.Domain/Models/AppSettings/PermissionSettings.cs @@ -272,6 +272,13 @@ public class PermissionSettings ); } +/// +/// Represents a set of permissions for a source, grouping the unit-level and display-level together with the corresponding . +/// +/// +/// The primary constructor captures and permissions as , and permissions as . +/// +/// public class SourcePermissions( DisplayPermissionTypes unit, DisplayPermissionTypes display, @@ -282,6 +289,13 @@ public class SourcePermissions( public PanelPermissionTypes Panel { get; set; } = panel; } +/// +/// Encapsulates a collection of that govern the display permissions for clinical and administrative areas such as admissions, discharges, observations, demographic data, box blocking, notices, and cell management. +/// +/// +/// The flag indicates whether the permission configuration should be evaluated in demonstration mode. +/// +/// public class DisplayPermissionTypes( UserActions admissions, UserActions discharges, @@ -302,6 +316,13 @@ public class DisplayPermissionTypes( public bool UseDemoMode { get; set; } = useDemoMode; } +/// +/// Encapsulates the permissions available for each application panel, such as , , and , along with the flag. +/// +/// +/// A dedicated value is supplied for every panel — units, displays, display configurations, master lists, treatments, patients, medicines, pumps, users, configuration observations, observations, and audits — so that the access rights for each section can be evaluated independently. The parameter indicates whether the system is operating in demo mode. +/// +/// public class PanelPermissionTypes( UserActions units, UserActions displays, diff --git a/adas-core.Domain/Models/DTO/UnitInfoDto.cs b/adas-core.Domain/Models/DTO/UnitInfoDto.cs index a08c45cf..97b13b2c 100644 --- a/adas-core.Domain/Models/DTO/UnitInfoDto.cs +++ b/adas-core.Domain/Models/DTO/UnitInfoDto.cs @@ -9,11 +9,21 @@ namespace adas_core.Domain.Models.DTO; /// public class UnitInfoDto { + /// + /// Initializes a new instance of the data transfer object, enabling JSON deserialization via the . + /// + /// [JsonConstructor] public UnitInfoDto() { } + /// + /// Initializes a new instance of from the supplied , + /// projecting its identifier and name into the DTO with safe empty-string defaults for the display fields. + /// + /// The optional whose values populate the DTO; when null, the string properties default to . + /// public UnitInfoDto(Unit? unit) { Id = unit?.Id; diff --git a/adas-core.Domain/Models/Filter/PaginationFilter.cs b/adas-core.Domain/Models/Filter/PaginationFilter.cs index d839e6ad..e9a95492 100644 --- a/adas-core.Domain/Models/Filter/PaginationFilter.cs +++ b/adas-core.Domain/Models/Filter/PaginationFilter.cs @@ -2,10 +2,21 @@ public record PaginationFilter { + /// + /// Initializes a new instance of the class, which encapsulates the parameters used to paginate query results. + /// + /// public PaginationFilter() { } + /// + /// Initializes a new instance of the class with sanitized pagination values and an optional . + /// + /// The requested page number; values less than 1 are clamped to 1. + /// The requested page size; values less than or equal to 0 default to 100. + /// The optional providing additional filtering criteria. + /// public PaginationFilter(int pageNumber, int pageSize, FilteredRequest? filtered) { PageNumber = pageNumber < 1 ? 1 : pageNumber; diff --git a/adas-core.Domain/Models/GroupedObservations/GroupedField.cs b/adas-core.Domain/Models/GroupedObservations/GroupedField.cs index 934c5dbc..fc39d8b1 100644 --- a/adas-core.Domain/Models/GroupedObservations/GroupedField.cs +++ b/adas-core.Domain/Models/GroupedObservations/GroupedField.cs @@ -10,10 +10,28 @@ namespace adas_core.Domain.Models.GroupedObservations; /// public class GroupedField { + /// + /// Initializes a new default instance of the class, representing a field that aggregates related items into a single addressable group. + /// + /// public GroupedField() { } + /// + /// Initializes a new instance of , which represents a configurable field for grouped observations with identifiers, scheduling offsets, and result selection. + /// Null collection parameters are normalized to empty lists, and defaults to a list containing when omitted. + /// + /// The primary identifier of the field, or null when only the collection is used. + /// The alternative identifiers for the field; when null, an empty is stored. + /// The grouping key that associates the field with a logical group, or null if unspecified. + /// The list of schedule offsets applied to the field; when null, an empty is stored. + /// The maximum number of observations retained for the field. + /// The optional that governs how observations are spaced. + /// The value that defines the schedule's starting reference. + /// The list of values the field should produce; when null, a list containing is stored. + /// The labels associated with the field, or null when no labels are provided. + /// public GroupedField( string? name, List? names, diff --git a/adas-core.Domain/Models/HistoricalLocations.cs b/adas-core.Domain/Models/HistoricalLocations.cs index 792fc220..81d0abdb 100644 --- a/adas-core.Domain/Models/HistoricalLocations.cs +++ b/adas-core.Domain/Models/HistoricalLocations.cs @@ -19,6 +19,13 @@ public class HistoricalLocation : IEquatable public HistoricalLocation() { } // Tu constructor actual + /// + /// Initializes a new instance of with the specified admission time and , representing a historical record of a patient's location. + /// + /// The admission time assigned to . + /// The assigned to ; cannot be . + /// Thrown when is . + /// public HistoricalLocation(DateTime admTime, PatientLocation patientLocation) { AdmTime = admTime; diff --git a/adas-core.Domain/Models/Masters/MasterList.cs b/adas-core.Domain/Models/Masters/MasterList.cs index dea8b892..96fca9b8 100644 --- a/adas-core.Domain/Models/Masters/MasterList.cs +++ b/adas-core.Domain/Models/Masters/MasterList.cs @@ -22,6 +22,12 @@ public class MasterList public LocaleEnum? DefaultLocale { get; set; } public List Options { get; set; } = []; + /// + /// Returns a copy of this with each option name in localized to the requested , falling back to the original name when no translation is found. + /// + /// Target used to look up a translated name via reflection on . When null, the current instance is returned unchanged. + /// A new with localized option names when is provided; otherwise the current instance. + /// public MasterList ReturnMasterListOptionsInLocaleIfExist(LocaleEnum? localeToReturn) { if (localeToReturn == null) return this; diff --git a/adas-core.Domain/Models/MongoModels/DisplayConfig.cs b/adas-core.Domain/Models/MongoModels/DisplayConfig.cs index cb87cf79..45394c90 100644 --- a/adas-core.Domain/Models/MongoModels/DisplayConfig.cs +++ b/adas-core.Domain/Models/MongoModels/DisplayConfig.cs @@ -184,6 +184,12 @@ public class SmartDisplay : DisplayConfig } // TO TEST + /// + /// Compares the values of the public properties of between the current instance and , and returns the names of the properties that differ. The property is also included when it is not null and not equal to the one in . + /// + /// The instance to compare against; may be null. + /// A containing the names of the properties that have different values between the two instances. + /// public List GetDifferentProperties(SmartDisplay? other) { // Obtiene las propiedades públicas de la clase SmartDisplay @@ -858,6 +864,10 @@ public class AxisLabel /// /// Represents a line associated with an axis, typically used in charting or graphing scenarios to render or define axis-related visual elements. /// +/// +/// Represents a line associated with an axis, typically used to render or define the visual structure of an axis in a chart or graph. +/// +/// public class AxisLineStyle { public string? Color { get; set; } @@ -1030,6 +1040,10 @@ public class Piece // /// // /// Represents a candle entity within the system. // /// +// /// +// /// Represents a single candlestick data point, typically used in financial charting to encapsulate price information for a discrete time interval. +// /// +// /// // public class CandlestickSeriesConfig : SeriesConfigBase // { // public List? CandleKeyList { get; set; } diff --git a/adas-core.Domain/Models/ObservaitonRetentionResult.cs b/adas-core.Domain/Models/ObservaitonRetentionResult.cs index 147f7103..173424eb 100644 --- a/adas-core.Domain/Models/ObservaitonRetentionResult.cs +++ b/adas-core.Domain/Models/ObservaitonRetentionResult.cs @@ -7,10 +7,20 @@ namespace adas_core.Domain.Models; /// public class ObservatitonRetentionResult { + /// + /// Initializes a new instance of the class, which represents the outcome of an observation retention operation. + /// + /// public ObservatitonRetentionResult() { } + /// + /// Initializes a new instance of the class, which represents the outcome of a retention evaluation, by storing the supplied and its associated . + /// + /// The that was evaluated to produce the result. + /// The optional numeric value paired with the , or when no value is required. + /// public ObservatitonRetentionResult(RetentionPolicy retentionPolicy, int? retentionPolicyValue) { RetentionPolicy = retentionPolicy; diff --git a/adas-core.Domain/Models/Observations/Medication.cs b/adas-core.Domain/Models/Observations/Medication.cs index bc0716f4..cfd087e1 100644 --- a/adas-core.Domain/Models/Observations/Medication.cs +++ b/adas-core.Domain/Models/Observations/Medication.cs @@ -11,10 +11,20 @@ namespace adas_core.Domain.Models.Observations; /// public class Medication : Observation { + /// + /// Initializes a new instance of the class with default values. + /// + /// public Medication() { } + /// + /// Initializes a new instance of the class, which represents medication delivery state, by reading pump-related properties from when their MDC codes are present and assigning to . + /// + /// The identifier stored in . + /// A of entries keyed by MDC code, consulted via . + /// public Medication(string id, Dictionary obj) { if (obj.TryGetValue("MDC_184504", out var mode)) PumpMode = new PumpMode(mode); @@ -57,10 +67,20 @@ public class Medication : Observation /// public class DrugValue { + /// + /// Initializes a new instance of the class using default values. The type represents the value associated with a drug. + /// + /// public DrugValue() { } + /// + /// Initializes a new instance of the class by copying the medication-related values from the specified . + /// This constructor populates the properties , , , , , and from the source element. + /// + /// The from which to copy the medication data. + /// public DrugValue(PumpElement pumpElement) { Id = pumpElement.Id; @@ -101,6 +121,11 @@ public class DrugValue /// public abstract class DrugDoubleValue : DrugValue { + /// + /// Initializes a new instance of the class by forwarding to the base constructor and parsing its textual value as a to set the Value property when the conversion succeeds. + /// + /// The whose string representation is parsed as a to initialize the Value property. + /// protected DrugDoubleValue(PumpElement pumpElement) : base(pumpElement) { if (double.TryParse(pumpElement.Value?.ToString(), out var valueParsed)) @@ -175,6 +200,11 @@ public class Drug(PumpElement pumpElement) : DrugStringValue(pumpElement); /// public class PumpMode : DrugStringValue { + /// + /// Initializes a new instance of the class by forwarding the supplied to the base constructor and computing the normalized mode identifier from its raw value. The type represents a pump mode value extracted from a pump element. + /// + /// The source element providing the raw mode text that is normalized to produce the mode identifier. + /// public PumpMode(PumpElement pumpElement) : base(pumpElement) { Value = pumpElement.Value?.ToString()?.SubstringAfter("pump-mode-").Replace("-", "_"); @@ -186,6 +216,11 @@ public class PumpMode : DrugStringValue /// public class PumpStatus : DrugStringValue { + /// + /// Initializes a new instance of the class from the specified , deriving the by stripping the "pump-status-" prefix and normalizing dashes to underscores. + /// + /// The whose value is parsed to populate the status. + /// public PumpStatus(PumpElement pumpElement) : base(pumpElement) { Value = pumpElement.Value?.ToString()?.SubstringAfter("pump-status-").Replace("-", "_"); diff --git a/adas-core.Domain/Models/PatientLocation.cs b/adas-core.Domain/Models/PatientLocation.cs index 57764d4a..3821fd27 100644 --- a/adas-core.Domain/Models/PatientLocation.cs +++ b/adas-core.Domain/Models/PatientLocation.cs @@ -6,6 +6,13 @@ /// public class PatientLocation : IEquatable { + /// + /// Initializes a new instance of the class, which represents a patient's location within a care unit, using the specified unit name, bed, and room values. + /// + /// The name of the care unit assigned to , or . + /// The bed identifier assigned to , or . + /// The room identifier assigned to , or . + /// public PatientLocation(string? unitName, string? bed, string? room) { UnitName = unitName; @@ -13,6 +20,12 @@ public class PatientLocation : IEquatable Room = room; } + /// + /// Initializes a new instance of the class, storing the supplied unit name and bed, and using the bed value as the room identifier. + /// + /// The unit name to assign to , or if unspecified. + /// The bed identifier to assign to and , or if unspecified. + /// public PatientLocation(string? unitName, string? bed) { UnitName = unitName; @@ -20,6 +33,11 @@ public class PatientLocation : IEquatable Room = bed; } + /// + /// Initializes a new instance of the class without performing explicit initialization of its members. + /// The type represents the location of a patient. + /// + /// public PatientLocation() { // Constructor vacío diff --git a/adas-core.Domain/Models/PatientObservation.cs b/adas-core.Domain/Models/PatientObservation.cs index a1301952..5378ca60 100644 --- a/adas-core.Domain/Models/PatientObservation.cs +++ b/adas-core.Domain/Models/PatientObservation.cs @@ -15,10 +15,21 @@ public class PatientObservation : BasePatientObservationValue { private string? _result; + /// + /// Initializes a new default instance of the class, which represents a clinical observation recorded for a patient. + /// + /// public PatientObservation() { } + /// + /// Initializes a new instance of the class, which represents an observation linked to a patient, with the specified identifier, value, and name. + /// + /// The identifying the patient associated with the observation. + /// The value recorded for the observation. + /// The name of the observation, or . + /// public PatientObservation(ObjectId patientId, object value, string? name) { PatientId = patientId; diff --git a/adas-core.Domain/Models/Responses/DisplayConfigMinimalResponse.cs b/adas-core.Domain/Models/Responses/DisplayConfigMinimalResponse.cs index 4d129015..2d4cb31e 100644 --- a/adas-core.Domain/Models/Responses/DisplayConfigMinimalResponse.cs +++ b/adas-core.Domain/Models/Responses/DisplayConfigMinimalResponse.cs @@ -12,10 +12,20 @@ namespace adas_core.Domain.Models.Responses; /// public class DisplayConfigMinimalResponse { + /// + /// Initializes a new instance of the class, which represents a minimal response payload carrying display configuration data. + /// + /// public DisplayConfigMinimalResponse() { } + /// + /// Initializes a new , a minimal response view of a display configuration, from the supplied and optional flag. + /// + /// The source whose , , and populate the response. + /// The nullable boolean indicating whether the display configuration is in use, stored in . + /// public DisplayConfigMinimalResponse(DisplayConfigSummary displayConfig, bool? isInUse = false) { Id = displayConfig.Id; diff --git a/adas-core.Domain/Models/Responses/PaginationResponse.cs b/adas-core.Domain/Models/Responses/PaginationResponse.cs index e77b3744..537145c1 100644 --- a/adas-core.Domain/Models/Responses/PaginationResponse.cs +++ b/adas-core.Domain/Models/Responses/PaginationResponse.cs @@ -6,6 +6,14 @@ /// The type of the items contained in the paginated response. public class PaginationResponse { + /// + /// Initializes a new instance of with the supplied page items and pagination metadata, deriving the total page count from and . + /// + /// The of items included in the current page. + /// The number of the current page. + /// The maximum number of items per page. + /// The total number of records available across all pages. + /// public PaginationResponse(List data, int pageNumber, int pageSize, long totalRecords) { PageNumber = pageNumber; diff --git a/adas-core.Domain/Models/Responses/PatientSearch.cs b/adas-core.Domain/Models/Responses/PatientSearch.cs index 4f5c121e..a55d86bb 100644 --- a/adas-core.Domain/Models/Responses/PatientSearch.cs +++ b/adas-core.Domain/Models/Responses/PatientSearch.cs @@ -2,6 +2,10 @@ using adas_core.Domain.Models.MongoModels; namespace adas_core.Domain.Models.Responses; +/// +/// Encapsulates the outcome of a lookup, bundling the matched , the corresponding archived , the related , and flags that indicate archive status and result availability. +/// +/// public class PatientSearch( Patient? patient, Patient? archivePatient, diff --git a/adas-core.Domain/Models/Responses/Response.cs b/adas-core.Domain/Models/Responses/Response.cs index 35368ec4..81989a9d 100644 --- a/adas-core.Domain/Models/Responses/Response.cs +++ b/adas-core.Domain/Models/Responses/Response.cs @@ -6,10 +6,19 @@ /// The type of the payload contained within the response. public class Response { + /// + /// Initializes a new instance of the class using default values. + /// + /// public Response() { } + /// + /// Initializes a new instance of the class representing a successful result, setting to true, to an empty string, to null, and storing the supplied payload in . + /// + /// The payload to expose through . + /// public Response(T data) { Succeeded = true; diff --git a/adas-core.Domain/Utils/AuthUtils.cs b/adas-core.Domain/Utils/AuthUtils.cs index 2111a7af..89ac6bea 100644 --- a/adas-core.Domain/Utils/AuthUtils.cs +++ b/adas-core.Domain/Utils/AuthUtils.cs @@ -12,11 +12,19 @@ public sealed class AuthUtils { private LoginResponse _loginResponse = new(); + /// + /// Static constructor that initializes the static field of the class by assigning a new instance if it has not already been set. + /// + /// static AuthUtils() { InternalInstance ??= new AuthUtils(); } + /// + /// Initializes a new instance of the authentication utility class and stores a self-reference in , allowing callers to retrieve the active instance through that property. + /// + /// public AuthUtils() { InternalInstance = this; diff --git a/adas-core.Domain/Utils/CacheUtils.cs b/adas-core.Domain/Utils/CacheUtils.cs index be69b254..a15a1019 100644 --- a/adas-core.Domain/Utils/CacheUtils.cs +++ b/adas-core.Domain/Utils/CacheUtils.cs @@ -140,6 +140,13 @@ namespace adas_core.Domain.Utils public static string ConfigObservationsAll() => "configObservations:all"; + /// + /// Returns the cache key and its associated time-to-live (TTL) for caching the complete collection of configuration observations. + /// The TTL is resolved by using and . + /// + /// Optional cache configuration used to resolve the TTL; may be . + /// A tuple containing the cache key and the resolved TTL as a . + /// public static (string Key, TimeSpan? Ttl) ConfigObservationsAllKeyWithTtl( CacheSettings? settings) { diff --git a/adas-core.Domain/Utils/CardConfigExtensions.cs b/adas-core.Domain/Utils/CardConfigExtensions.cs index 1559b0f4..c8e1478a 100644 --- a/adas-core.Domain/Utils/CardConfigExtensions.cs +++ b/adas-core.Domain/Utils/CardConfigExtensions.cs @@ -11,6 +11,14 @@ namespace adas_core.Domain.Utils; public static class CardConfigExtensions { // Método principal para extraer todos los nombres + /// + /// Retrieves all unique observation names defined within the rows and cells of the specified . + /// Returns an empty list when has no , and skips any row whose Cells collection is . + /// Observation names are extracted recursively from each cell, with duplicates removed. + /// + /// The whose cell observation names should be collected. + /// A of distinct observation names found across all cells of , or an empty list if no rows are defined. + /// public static List GetAllObservationNames(this CardConfig config) { if (config.Rows == null) return []; @@ -28,6 +36,12 @@ public static class CardConfigExtensions } // Método auxiliar RECURSIVO para extraer nombres de una Cell y sus SubObs + /// + /// Extracts observation names from the specified , yielding the values in when present and recursively collecting names from each . + /// + /// The whose observation names and nested sub-observations are traversed. + /// An of observation names from the and its sub-observations. + /// private static IEnumerable ExtractObservationNames(Cell cell) { // 1. Si la Cell tiene ObservationName, devolver esos nombres. diff --git a/adas-core.Domain/Utils/ComplexObjectValueTypeSerializer.cs b/adas-core.Domain/Utils/ComplexObjectValueTypeSerializer.cs index 5689fbdb..1d24596e 100644 --- a/adas-core.Domain/Utils/ComplexObjectValueTypeSerializer.cs +++ b/adas-core.Domain/Utils/ComplexObjectValueTypeSerializer.cs @@ -26,6 +26,14 @@ public partial class ComplexObjectValueTypeSerializer : SerializerBase [GeneratedRegex("ObjectId\\((.[a-f0-9]{24}.)\\)")] private static partial Regex ObjectIdRegex(); + /// + /// Deserializes a BSON value into a .NET , handling primitive values directly, marker types (Null, EndOfDocument, Undefined, MinKey, MaxKey) as false, embedded instances by resolving the _t type discriminator with legacy namespace normalization (mapping adas-core.Models to adas-core.Domain.Models), and values as a of the inferred element type after cleaning $oid wrappers from the intermediate JSON. + /// + /// The whose supplies the BSON tokens to read. + /// The carrying additional deserialization configuration. + /// An representing the deserialized value: a primitive returned directly, false for marker types, an instance of the type indicated by the _t field for documents, or a typed for arrays. + /// Thrown when a lacks a _t discriminator or a _v array payload, the referenced cannot be resolved via , the element type of a non-empty cannot be determined, the current is unhandled, or any inner step via fails. + /// public override object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) { try diff --git a/adas-core.Domain/Utils/DetailConfigExtension.cs b/adas-core.Domain/Utils/DetailConfigExtension.cs index 1878808a..1476368e 100644 --- a/adas-core.Domain/Utils/DetailConfigExtension.cs +++ b/adas-core.Domain/Utils/DetailConfigExtension.cs @@ -11,6 +11,13 @@ namespace adas_core.Domain.Utils; public static class DetailConfigExtension { // Método principal para iniciar la extracción + /// + /// Retrieves all unique observation names defined in the nurse rows of the specified . + /// Returns an empty list when is null. + /// + /// The extension target whose nurse rows are inspected. + /// A containing the distinct observation names extracted from the nurse rows; an empty list when no nurse rows are defined. + /// public static List GetAllObservationNames(this CardDetailsConfig config) { if (config.NurseRows == null) return []; @@ -24,6 +31,12 @@ public static class DetailConfigExtension } // --- Auxiliar 1: Recorre la anidación de Filas (RowDetailsConfig) --- + /// + /// Recursively extracts names from a collection of entries, traversing both the and nested of each row. + /// + /// The list of instances to process. + /// An of containing all names collected from the cells and nested rows. + /// private static IEnumerable ExtractNamesFromRows(List rows) { foreach (var row in rows) @@ -43,6 +56,12 @@ public static class DetailConfigExtension } // --- Auxiliar 2: Recorre la anidación de Celdas (CellDetails) --- + /// + /// Recursively extracts every observation name from a , yielding names from the current cell as well as from all its nested . Null and null collections are safely skipped without yielding any elements. + /// + /// The whose observation names, including those of its descendant cells, should be collected. + /// A lazily evaluated of containing every observation name found in and its nested cells. + /// private static IEnumerable ExtractNamesFromCells(CellDetails cell) { // 1. EXTRAER nombres del nivel actual diff --git a/adas-core.Domain/Utils/EquatableDictionary.cs b/adas-core.Domain/Utils/EquatableDictionary.cs index 94dc4a7d..48da231a 100644 --- a/adas-core.Domain/Utils/EquatableDictionary.cs +++ b/adas-core.Domain/Utils/EquatableDictionary.cs @@ -1,5 +1,14 @@ namespace adas_core.Domain.Utils; +/// +/// Represents a sealed dictionary that inherits from and provides equality comparison with instances through . +/// +/// The type of the keys stored in the dictionary, constrained to be non-null. +/// The type of the values stored in the dictionary, constrained to be non-null. +/// +/// The implementation targets rather than the declaring type, enabling cross-type equality semantics between the two dictionary variants. +/// +/// public sealed class EquatableDictionary : Dictionary, IEquatable> where TKey : notnull where TValue : notnull diff --git a/adas-core.Domain/Utils/Mapper.cs b/adas-core.Domain/Utils/Mapper.cs index 92f6cdb6..3432f0d4 100644 --- a/adas-core.Domain/Utils/Mapper.cs +++ b/adas-core.Domain/Utils/Mapper.cs @@ -3,12 +3,24 @@ using System.Reflection; namespace adas_core.Domain.Utils; +/// +/// Provides a static mapping utility for instances of the reference type . +/// +/// The reference type that this mapper operates on, constrained to reference types via the class constraint. +/// +/// As indicated by the where T : class constraint, only reference types can be supplied as the generic argument for . +/// +/// public static class Mapper // We can only use reference types where T : class { private static readonly Dictionary PropertyMap; + /// + /// Initializes the static cache used by the mapper to look up entries for the type parameter T by their lowercased property name. + /// + /// static Mapper() { // At this point we can convert each diff --git a/adas-core.Domain/Utils/MappingUtils.cs b/adas-core.Domain/Utils/MappingUtils.cs index 146f5cb3..6093ad44 100644 --- a/adas-core.Domain/Utils/MappingUtils.cs +++ b/adas-core.Domain/Utils/MappingUtils.cs @@ -13,6 +13,11 @@ public sealed class MappingUtils : IMappingUtils private readonly List? _cccData; private bool _isTransformedValue; + /// + /// Initializes a new instance of the class by loading the CCC mapping interventions from the supplied and resetting the transformed-value flag. + /// + /// The wrapper whose provides the whose data is stored in this instance. + /// public MappingUtils(IOptions apiSettings) { var cccMappingData = apiSettings.Value.MappingInterventions; @@ -46,6 +51,13 @@ public sealed class MappingUtils : IMappingUtils return null; // No se encontro el code }*/ + /// + /// Searches for an entry matching the supplied within the given and returns its associated type, name, and group. The may be a (matched as an exact value or within a numeric range) or a (parsed as a when possible, otherwise compared as text). Returns when no matching entry is found. + /// + /// The code to look up. Accepts a for numeric matching and a for text matching or numeric parsing. + /// The category used to filter the entries; only entries whose category matches this value are considered. + /// A tuple containing the type, name, and group of the matching entry, or when no match is found. + /// public (string type, string name, string group)? SearchByCode(object code, string category) { // esta funcion conviete a double los string que permitan conversion si no se puede los deja como string diff --git a/adas-core.Domain/Utils/RelayHelper.cs b/adas-core.Domain/Utils/RelayHelper.cs index c8790489..c611b3fb 100644 --- a/adas-core.Domain/Utils/RelayHelper.cs +++ b/adas-core.Domain/Utils/RelayHelper.cs @@ -10,6 +10,12 @@ namespace adas_core.Domain.Utils; /// public class RelayHelper { + /// + /// Retrieves the current status of a by calling a local REST API endpoint built from its connection parameters, returning when the relay is reported as active and when the response is not , the payload cannot be converted to a boolean, or any exception is raised during the request. + /// + /// The whose status is queried; its is used in the URL path while , , and are passed as query parameters. + /// if the API responds with and the response body converts to a boolean value of ; otherwise, . + /// public static bool GetRelayStatusFromApiRest(Relay relay) { UriBuilder builder = new() @@ -94,6 +100,12 @@ public class RelayHelper PowerRelay(relay, builder); } + /// + /// Sends an HTTP POST request to power a through the endpoint described by , enriching the query string with the relay's driver, IP address, port, and a fixed channel count of 8. Logs an information message when the response status is not and logs any exception raised during the call at debug level instead of propagating it. + /// + /// The relay to power, whose , and values are written into the request query string. + /// The whose query string is populated and whose identifies the target endpoint of the POST request. + /// private static void PowerRelay(Relay relay, UriBuilder builder) { var query = HttpUtility.ParseQueryString(builder.Query); diff --git a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_0_UpdateDataPatien.cs b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_0_UpdateDataPatien.cs index 0b80d19e..f1f6c0f3 100644 --- a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_0_UpdateDataPatien.cs +++ b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_0_UpdateDataPatien.cs @@ -13,12 +13,20 @@ namespace adas_core.Infrastructure.Migrations.MongoMigrations; /// public class U_0_1_0_UpdateDataPatien : Migration { + /// + /// Initializes a new instance of the migration, passing the version 10 to the base constructor and assigning the Description that explains how person historical identifiers and locations are transformed into date-indexed arrays and merged into patients. + /// + /// public U_0_1_0_UpdateDataPatien() : base(10) { Description = "Transforma person.historicalIds y historicalLocations en arrays con fechas y realiza merge sobre patients."; } + /// + /// Migrates person.historicalIds and historicalLocations fields in the patients, admissions, and archive_patient MongoDB collections from a document representation to an array of objects, converting each key (a date string) into a Date value via $dateFromString. If a field is already an array it is preserved unchanged; otherwise it is reshaped using $objectToArray and $map, and the result is merged back into the same collection with $merge. + /// + /// public override void Update() { var collectionPatient = Database.GetCollection("patients"); @@ -231,6 +239,10 @@ public class U_0_1_0_UpdateDataPatien : Migration // NO usado por MongoMigrations.Core // Solo para ejecución manual si hiciera falta + /// + /// Reverts a schema migration on the patients, admissions, and archive_patient MongoDB collections by converting array representations of person.historicalIds and historicalLocations back into documents keyed by an ISO-8601 timestamp. When the target fields are already documents they are left unchanged via a $cond guard, and each aggregation result is persisted back to its source collection using $merge with whenMatched: replace. + /// + /// public void Down() { var collectionPatient = Database.GetCollection("patients"); diff --git a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_2_UpdatePointOfCareConfig.cs b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_2_UpdatePointOfCareConfig.cs index a27cbcbf..50db2063 100644 --- a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_2_UpdatePointOfCareConfig.cs +++ b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_2_UpdatePointOfCareConfig.cs @@ -12,6 +12,10 @@ namespace adas_core.Infrastructure.Migrations.MongoMigrations; /// public class U_0_1_2_UpdatePointOfCareConfig : Migration { + /// + /// Initializes a new instance of , assigning a Description stating that it removes the PointOfCare configuration elements for poc, relay, camera, and beacon while keeping the placeholder for the new model, and passing 12 to the base constructor. + /// + /// public U_0_1_2_UpdatePointOfCareConfig() : base(12) { Description = diff --git a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_3_UpdateLanguageBarrier.cs b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_3_UpdateLanguageBarrier.cs index 4cfda266..19fcbca1 100644 --- a/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_3_UpdateLanguageBarrier.cs +++ b/adas-core.Infrastructure/Migrations/MongoMigrations/U_0_1_3_UpdateLanguageBarrier.cs @@ -9,12 +9,20 @@ namespace adas_core.Infrastructure.Migrations.MongoMigrations; /// public class U_0_1_3_UpdateLanguageBarrier : Migration { + /// + /// Initializes a new instance of the class, passing identifier 13 to the base constructor and assigning the Description property to describe the removal of poc, relay, camera and beacon configuration elements for the new model. + /// + /// public U_0_1_3_UpdateLanguageBarrier() : base(13) { Description = "Borra los elementos de configuracion de poc, relay, camera y beacon y deja el place holder del nuevo modelo"; } + /// + /// Converts the languageBarrier field in the patients and admissions collections from a scalar value into a , preserving the original value as the first element when it is not null. Documents where the field is already an array are left untouched, and null values are replaced with an empty array. + /// + /// public override void Update() { string[] collectionsToUpdate = { "patients", "admissions" }; diff --git a/adas-core.Infrastructure/Repositories/AdmissionRepository.cs b/adas-core.Infrastructure/Repositories/AdmissionRepository.cs index faad311d..8ea41ad5 100644 --- a/adas-core.Infrastructure/Repositories/AdmissionRepository.cs +++ b/adas-core.Infrastructure/Repositories/AdmissionRepository.cs @@ -23,6 +23,13 @@ public class AdmissionRepository : MongoRepository, IAdmissionReposit private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, passing the MongoDB database to the base repository and storing the API configuration values used by the repository. + /// + /// The providing the values required by the repository. + /// The passed to the base repository constructor. + /// Thrown when is null. + /// public AdmissionRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/POCMappingRepository.cs b/adas-core.Infrastructure/Repositories/POCMappingRepository.cs index cab101d9..b884bfb4 100644 --- a/adas-core.Infrastructure/Repositories/POCMappingRepository.cs +++ b/adas-core.Infrastructure/Repositories/POCMappingRepository.cs @@ -13,6 +13,12 @@ public class PoCMappingRepository : MongoRepository, IPoCMappingRepo { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, storing the resolved and forwarding the supplied to the base repository to support persistence of PoC mappings. + /// + /// The wrapper that exposes the application's . + /// The instance passed to the base class to establish the MongoDB connection. + /// public PoCMappingRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { _apiSettings = apiSettings.Value; diff --git a/adas-core.Infrastructure/Repositories/PatientCarePlanRepository.cs b/adas-core.Infrastructure/Repositories/PatientCarePlanRepository.cs index 1cc66f2b..689e9943 100644 --- a/adas-core.Infrastructure/Repositories/PatientCarePlanRepository.cs +++ b/adas-core.Infrastructure/Repositories/PatientCarePlanRepository.cs @@ -39,6 +39,12 @@ public class PatientCarePlanRepository : MongoRepository, IPati + /// + /// Initializes a new instance of the class with the supplied API configuration and MongoDB database connection, forwarding the database to the base repository. + /// + /// The providing the assigned to the repository. + /// The connection passed to the base class for data access. + /// public PatientCarePlanRepository( IOptions apiSettings, IMongoDatabase database diff --git a/adas-core.Infrastructure/Repositories/PatientRepository.cs b/adas-core.Infrastructure/Repositories/PatientRepository.cs index d49dbf59..affe53dc 100644 --- a/adas-core.Infrastructure/Repositories/PatientRepository.cs +++ b/adas-core.Infrastructure/Repositories/PatientRepository.cs @@ -22,6 +22,13 @@ public class PatientRepository : MongoRepository, IPatientRepository { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of , a MongoDB-backed data repository, capturing API configuration from and forwarding the to the base repository constructor. + /// + /// The whose value supplies the repository's API configuration. + /// The connection passed to the base class constructor. + /// Thrown when is null. + /// public PatientRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); @@ -279,6 +286,12 @@ public class PatientRepository : MongoRepository, IPatientRepository } + /// + /// Finds a by , preferring the most recently admitted active patient (one whose is null) and falling back to the record with the most recent non-null when no active admission exists. Returns null when is null, empty, or whitespace, or when no matching record is found. + /// + /// The patient number used to locate the record. + /// A that resolves to the matching , or null when no record is found. + /// public async Task FindByPatientNumber(string patientNumber) { if (string.IsNullOrWhiteSpace(patientNumber)) return null; @@ -305,6 +318,13 @@ public class PatientRepository : MongoRepository, IPatientRepository return patient; } + /// + /// Searches for a by whose differs from , intended to locate a patient identified at a Point of Care but registered in another unit. Returns null when the patient number is blank, when multiple matches are found (since the patient number may be incomplete), or when no match exists; exceptions are logged and also surface as null. + /// + /// The patient number used to look up the . + /// The of the unit that must be excluded from the match. + /// A resolving to the matching , or null when there is no unique match. + /// public async Task SearchByPatientNumberAndDistinctUnit(string patientNumber, ObjectId unitId) { try @@ -328,6 +348,12 @@ public class PatientRepository : MongoRepository, IPatientRepository } } + /// + /// Retrieves all documents that contain at least one procedure considered finished and eligible for archival. A procedure qualifies when its EndDate is not null and the time elapsed since that EndDate exceeds the supplied grace period of minutes relative to the current UTC time. + /// + /// The grace period, in minutes, added to a procedure's EndDate; the procedure is treated as finished only when the resulting timestamp is earlier than . + /// A containing the patients matching the finished-procedure criteria, or an empty list when no patient has a procedure whose archival grace period has elapsed. + /// public async Task> FindAllPatientWithFinishedProcedures(int archiveProcedureEndDateAfterMinutes) { var currentDateTime = DateTime.UtcNow; @@ -359,6 +385,13 @@ public class PatientRepository : MongoRepository, IPatientRepository return patientsWithFinishedProcedures; } + /// + /// Retrieves all records whose tests have finished and whose end date, offset by the specified archive threshold, is earlier than the current UTC time. + /// The initial MongoDB filter keeps tests with a non-null EndDate, and the in-memory filter then retains only those whose EndDate plus minutes is before . + /// + /// The number of minutes added to each test's EndDate to determine whether the test is eligible for archival. + /// A containing the patients whose tests meet the finished and archive criteria. + /// public async Task> FindAllPatientWithFinishedTests(int archiveTestEndDateAfterMinutes) { var currentDateTime = DateTime.UtcNow; @@ -389,6 +422,12 @@ public class PatientRepository : MongoRepository, IPatientRepository return patientsWithFinishedTests; } + /// + /// Asynchronously retrieves all patients that have at least one finished whose is older than minutes relative to the current UTC time, using a MongoDB query combined with an in-memory time threshold filter. + /// + /// The grace period in minutes that must elapse after a treatment's before the patient qualifies for retrieval. + /// A that resolves to the list of records whose treatments satisfy the finished-treatment time threshold. + /// public async Task> FindAllPatientWithFinishedTreatment(int archiveTreatmentEndDateAfterMinutes) { var currentDateTime = DateTime.UtcNow; @@ -414,6 +453,19 @@ public class PatientRepository : MongoRepository, IPatientRepository return patientsWithFinishedTreatments; } + /// + /// Updates a master list option for all patients belonging to the specified , + /// handling , , + /// and cases by updating the relevant fields and auxiliary fields, + /// and returning the updated documents. If cannot be parsed + /// as a or the type is not implemented, an empty list is returned. + /// + /// The collection of unit identifiers used to scope the update to the affected patients. + /// The DTO containing the existing option and the replacement option values to apply. + /// The textual name of the that determines which update path is executed. + /// A containing the updated documents, + /// or an empty list when no update was performed. + /// public async Task> UpdateMasterListOption(List unitIds, UpdateOptionMasterListDto opt, string typeName) { @@ -593,6 +645,14 @@ public class PatientRepository : MongoRepository, IPatientRepository } + /// + /// Deletes a master list option from documents belonging to the specified units, applying the appropriate update logic based on the resolved . Returns the affected patients for the supported types (, , and ), or an empty collection when cannot be parsed or the type has no handling logic. + /// + /// The collection of values identifying the units whose patients will be affected by the deletion. + /// The option to remove, matched by its (for diagnosis and origin lists) or its (for the doctor list). + /// The textual name of the master list type, parsed via with = to select the update strategy. + /// A that yields the documents modified for the supported values, or an empty when no updates are performed. + /// public async Task> DeleteMasterListOption(List unitIds, OptionList opt, string typeName) { @@ -714,6 +774,12 @@ public class PatientRepository : MongoRepository, IPatientRepository return new List(); } + /// + /// Finds the associated with the specified , preferring an active admission (no ) sorted by most recent , and falling back to the most recently discharged record when no active admission exists. + /// + /// The identifier of the patient to locate. + /// A instance if found; otherwise, when is null, empty, or whitespace, or when no matching record exists. + /// public async Task FindByPatientId(string patientId) { if (string.IsNullOrWhiteSpace(patientId)) return null; @@ -729,6 +795,12 @@ public class PatientRepository : MongoRepository, IPatientRepository return patient; } + /// + /// Retrieves the most relevant record for the specified identifier, prioritizing an active admission (no discharge time) ordered by the latest , and falling back to the most recently discharged patient ordered by when no active admission exists. + /// + /// The of the to look up. + /// The matching if one is found; otherwise, . + /// public async Task FindByPatientId(ObjectId patientId) { //Último paciente admitido @@ -782,6 +854,11 @@ public class PatientRepository : MongoRepository, IPatientRepository return await result.ToListAsync(); } + /// + /// Asynchronously retrieves all records whose associated point of care is not a virtual , by performing a lookup against the pointOfCares collection and excluding any bed whose value matches a virtual point of care. + /// + /// A that resolves to a containing the patients located in active (non-virtual) points of care. + /// public async Task> FindInActivePoC() { var virtualPointOfCareValues = Enum.GetValues(typeof(VirtualPointOfCare)).Cast() @@ -812,6 +889,12 @@ public class PatientRepository : MongoRepository, IPatientRepository } + /// + /// Asynchronously retrieves the records whose associated point of care has a bed value matching one of the enum values. + /// The lookup is performed through a MongoDB aggregation pipeline that joins the patients collection with the point of care collection and filters by the pointOfCareInfo.bed field. + /// + /// A that yields a containing the patients linked to a point of care whose bed matches any value. + /// public async Task> FindInInactivePoC() { var virtualPointOfCareValues = Enum.GetValues(typeof(VirtualPointOfCare)).Cast() diff --git a/adas-core.Infrastructure/Repositories/PoCSettingsRepository.cs b/adas-core.Infrastructure/Repositories/PoCSettingsRepository.cs index ebf540bb..4abb8a51 100644 --- a/adas-core.Infrastructure/Repositories/PoCSettingsRepository.cs +++ b/adas-core.Infrastructure/Repositories/PoCSettingsRepository.cs @@ -18,6 +18,13 @@ public class PoCSettingsRepository : MongoRepository, IPoCSettingsR { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of , capturing the API configuration from and forwarding the MongoDB database to the base repository. + /// + /// The wrapping the configuration values. + /// The passed to the base repository for data access. + /// Thrown when is . + /// public PoCSettingsRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/PointOfCareRepository.cs b/adas-core.Infrastructure/Repositories/PointOfCareRepository.cs index 929c5402..238ad7ad 100644 --- a/adas-core.Infrastructure/Repositories/PointOfCareRepository.cs +++ b/adas-core.Infrastructure/Repositories/PointOfCareRepository.cs @@ -20,6 +20,13 @@ public class PointOfCareRepository : MongoRepository, IPointOfCareR { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the repository, capturing the configured and delegating the to the base class. + /// + /// The providing access to the configured . + /// The forwarded to the base constructor. + /// Thrown when is null. + /// public PointOfCareRepository(IOptions? apiSettings, IMongoDatabase database) : base(database) { if (apiSettings != null) @@ -242,6 +249,14 @@ public class PointOfCareRepository : MongoRepository, IPointOfCareR } } + /// + /// Asynchronously finds a matching the specified and . + /// Returns when the bed is null or empty, when no matching document is found, or when an error occurs. + /// + /// The bed identifier to search for. If null or empty, the method returns without querying. + /// The unit identifier used to filter the documents. + /// A task containing the first matching , or if no match is found. + /// public async Task FindByBedAndUnitId(string? bed, ObjectId unitId) { try @@ -386,6 +401,12 @@ public class PointOfCareRepository : MongoRepository, IPointOfCareR throw; } } + /// + /// Asynchronously counts the records associated with the supplied , applying a filter that targets documents whose Bed value corresponds to one of the inactive states such as Pushed, Unknown, Deleted, NoBed, Cancelled, Recovered, UnitData, or Moved. + /// + /// The identifier of the unit whose associated documents are filtered and counted. + /// A representing the asynchronous operation, with the result being the number of matching documents. + /// public async Task CountVirtualsByUnitId(ObjectId unitId) { try @@ -680,6 +701,12 @@ public class PointOfCareRepository : MongoRepository, IPointOfCareR } //Deprecated PatientLocation by UnitName + /// + /// Asynchronously searches for the first matching the supplied criteria, combining equality filters for , and when their values are provided; if no criteria are provided an empty filter is used. + /// + /// The whose non-empty fields (, , ) are used to build the search filters. + /// A that yields the first matching , or when no document matches or when an error is caught and logged. + /// public async Task FindByPatientLocation(PatientLocation patientLocation) { try diff --git a/adas-core.Infrastructure/Repositories/PumpAlarmEventRepository.cs b/adas-core.Infrastructure/Repositories/PumpAlarmEventRepository.cs index f8bf0a7f..93e273aa 100644 --- a/adas-core.Infrastructure/Repositories/PumpAlarmEventRepository.cs +++ b/adas-core.Infrastructure/Repositories/PumpAlarmEventRepository.cs @@ -17,6 +17,12 @@ public class PumpAlarmEventRepository : MongoRepository, IPumpAl { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the repository, capturing the configured from and forwarding to the base repository for persistence operations. + /// + /// The wrapper that exposes the application's . + /// The passed to the base constructor and used to perform MongoDB operations. + /// public PumpAlarmEventRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { @@ -25,11 +31,20 @@ public class PumpAlarmEventRepository : MongoRepository, IPumpAl + /// + /// Retrieves the collection name used for pump alarm events, returning the configured value from _apiSettings.PumpAlarmEvent when set, or falling back to the default "pump_alarm_event". + /// + /// The configured pump alarm event collection name, or the default "pump_alarm_event" when no configuration value is available. + /// public override string GetCollectionName() { return _apiSettings.PumpAlarmEvent ?? "pump_alarm_event"; } + /// + /// Creates the MongoDB indexes for the PumpAlarmEvent collection, optimizing the most common query patterns: device lookup with reverse-chronological time ordering, time-only range queries, patient lookup, and device queries filtered by alarm type. + /// + /// public override async Task CreateIndexes() { var indexModels = new List> @@ -63,6 +78,11 @@ public class PumpAlarmEventRepository : MongoRepository, IPumpAl } + /// + /// Asynchronously inserts a new document into the underlying MongoDB collection. + /// + /// The record to persist. + /// public async Task InsertAsync(PumpAlarmEvent alarmEvent) { await Collection.InsertOneAsync(alarmEvent); @@ -85,6 +105,12 @@ public class PumpAlarmEventRepository : MongoRepository, IPumpAl return await find.ToListAsync(); } + /// + /// Asynchronously retrieves the most recent for the device identified by , returning the entry with the latest time stamp, or null if no event exists. + /// + /// The identifier of the device whose latest alarm event is being retrieved. + /// A that yields the latest associated with , or null if no matching event is found. + /// public async Task FindLastByDeviceIdAsync(string deviceId) { return await Collection @@ -93,12 +119,25 @@ public class PumpAlarmEventRepository : MongoRepository, IPumpAl .FirstOrDefaultAsync(); } + /// + /// Asynchronously removes all documents linked to the specified patient by deleting every record whose PatientId matches the supplied . + /// + /// The of the patient whose associated documents should be deleted. + /// public async Task DeleteByPatientId(ObjectId patientId) { await Collection.DeleteManyAsync(x => x.PatientId == patientId); } + /// + /// Asynchronously updates the value of the specified field across multiple documents, replacing occurrences of with , and returns the number of documents that were modified. + /// + /// The name of the field on whose value should be replaced. + /// The new value to assign to the field in matching documents. + /// The existing value used to identify documents to be updated. + /// The number of documents modified by the bulk update. + /// public async Task UpdateManyObjectIdByFiledNameAsync(string fieldName, ObjectId newId, ObjectId oldId) { var filter = Builders.Filter.Eq(fieldName, oldId); diff --git a/adas-core.Infrastructure/Repositories/PumpAlarmStateRepository.cs b/adas-core.Infrastructure/Repositories/PumpAlarmStateRepository.cs index 59edcedb..7bfb32f5 100644 --- a/adas-core.Infrastructure/Repositories/PumpAlarmStateRepository.cs +++ b/adas-core.Infrastructure/Repositories/PumpAlarmStateRepository.cs @@ -15,6 +15,12 @@ public class PumpAlarmStateRepository : MongoRepository, IPumpAl { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, which persists pump alarm state data, by storing the resolved and delegating MongoDB initialization to the base repository. + /// + /// The instance whose supplies the used by the repository. + /// The passed to the base constructor to provide the underlying MongoDB connection. + /// public PumpAlarmStateRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { @@ -32,6 +38,10 @@ public class PumpAlarmStateRepository : MongoRepository, IPumpAl return _apiSettings.PumpAlarmState ?? "pump_alarm_state"; } + /// + /// Creates the MongoDB indexes required by the collection: a unique compound index on , , and (named ux_device_alarm), plus supporting indexes on and . + /// + /// public override async Task CreateIndexes() { var indexModels = new List> @@ -80,6 +90,15 @@ public class PumpAlarmStateRepository : MongoRepository, IPumpAl return await Collection.Find(filter).FirstOrDefaultAsync(); } + /// + /// Inserts or updates an active document, reusing the identifier of an + /// existing record that already matches the same , + /// and combination, or generating a new when + /// does not yet carry one. + /// + /// The to persist; its is + /// populated from the matching document when one is found, or newly generated when it is currently . + /// public async Task UpsertActiveAsync(PumpAlarmState state) { var filter = diff --git a/adas-core.Infrastructure/Repositories/PumpArchiveRepository.cs b/adas-core.Infrastructure/Repositories/PumpArchiveRepository.cs index f42e856a..4be44c12 100644 --- a/adas-core.Infrastructure/Repositories/PumpArchiveRepository.cs +++ b/adas-core.Infrastructure/Repositories/PumpArchiveRepository.cs @@ -19,6 +19,12 @@ namespace adas_core.Infrastructure.Repositories { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, forwarding to the base repository and storing the resolved configuration for subsequent operations. + /// + /// The wrapper whose supplies the current . + /// The connection passed to the base class constructor. + /// public PumpArchiveRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { @@ -26,12 +32,21 @@ namespace adas_core.Infrastructure.Repositories } + /// + /// Returns the agreed MongoDB collection name used to store archived pump observations for patients, falling back to the default value when the corresponding setting is not configured. + /// + /// The collection name to use, either the value configured in ArchivePatientsPumpobservations or the default archive_pumpobservations. + /// public override string GetCollectionName() { // Nombre de colección pactado: "archive_pumpobservations" return _apiSettings.ArchivePatientsPumpobservations ?? "archive_pumpobservations"; } + /// + /// Creates the MongoDB indexes required by the collection: an ascending index on for patient-based lookups and audits, a compound index on (ascending) and (descending) for per-device timelines, and a descending index on for chronological ordering. + /// + /// public override async Task CreateIndexes() { var indexModels = new List> diff --git a/adas-core.Infrastructure/Repositories/PumpObservationRepository.cs b/adas-core.Infrastructure/Repositories/PumpObservationRepository.cs index f044119c..94d016ff 100644 --- a/adas-core.Infrastructure/Repositories/PumpObservationRepository.cs +++ b/adas-core.Infrastructure/Repositories/PumpObservationRepository.cs @@ -23,6 +23,12 @@ namespace adas_core.Infrastructure.Repositories + /// + /// Initializes a new instance of the class, capturing the configuration and forwarding the to the base repository to back pump observation data. + /// + /// The providing API configuration values assigned to the repository. + /// The passed to the base class to supply the MongoDB connection. + /// public PumpObservationRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { _apiSettings = apiSettings.Value; @@ -37,6 +43,10 @@ namespace adas_core.Infrastructure.Repositories return _apiSettings.PumpObservations ?? "pump_observations"; } + /// + /// Creates the MongoDB indexes for the collection, defining a compound index on (ascending) and (descending) to optimize per-pump timeline queries and a single-field index on for patient-scoped lookups. A commented TTL index on is included as a reference for enabling direct MongoDB retention when needed. + /// + /// public override async Task CreateIndexes() { var indexModels = new List> @@ -149,6 +159,12 @@ namespace adas_core.Infrastructure.Repositories return await query.ToListAsync(); } + /// + /// Asynchronously retrieves the most recent observation time for every patient that has at least one observation with a non-null patient identifier, by running a MongoDB aggregation that groups observations by patient and selects the maximum time per group. + /// Documents whose grouped identifier is not an or whose maximum time is not a valid are skipped from the result, and the remaining timestamps are normalized to UTC. + /// + /// A that yields a dictionary keyed by the patient's with the latest observation as the value. + /// public async Task> FindAllLastPatientObservationTimeAsync() { // Pipeline: @@ -321,6 +337,14 @@ namespace adas_core.Infrastructure.Repositories } + /// + /// Deletes older entries for the specified , keeping only the most recent records ordered by . + /// Returns 0 when is null or whitespace, when the existing count does not exceed , or when there is nothing left to delete after skipping the most recent items. + /// + /// Name used to filter the documents to be considered for deletion. + /// Maximum number of most recent entries to retain; any additional older entries will be removed. + /// The number of documents deleted, or 0 when no deletion was required. + /// public async Task DeleteOlderNumberAsync(string name, int maxCount) { if (string.IsNullOrWhiteSpace(name)) diff --git a/adas-core.Infrastructure/Repositories/PumpStateRepository.cs b/adas-core.Infrastructure/Repositories/PumpStateRepository.cs index b2f743f6..b3967818 100644 --- a/adas-core.Infrastructure/Repositories/PumpStateRepository.cs +++ b/adas-core.Infrastructure/Repositories/PumpStateRepository.cs @@ -15,6 +15,12 @@ namespace adas_core.Infrastructure.Repositories { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of , storing the resolved from and passing the to the base class constructor. + /// + /// The providing the configuration values used by the repository. + /// The forwarded to the base class to establish the underlying data connection. + /// public PumpStateRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { @@ -31,6 +37,10 @@ namespace adas_core.Infrastructure.Repositories return _apiSettings.PumpStates ?? "pump_states"; } + /// + /// Creates the MongoDB indexes required by the collection, including a unique index on , a compound index on and for time-based queries, and an index on for patient-scoped lookups. + /// + /// public override async Task CreateIndexes() { var indexModels = new List> diff --git a/adas-core.Infrastructure/Repositories/RecordingAlertArchiveRepository.cs b/adas-core.Infrastructure/Repositories/RecordingAlertArchiveRepository.cs index 168c36df..8e6cd970 100644 --- a/adas-core.Infrastructure/Repositories/RecordingAlertArchiveRepository.cs +++ b/adas-core.Infrastructure/Repositories/RecordingAlertArchiveRepository.cs @@ -14,6 +14,13 @@ public class RecordingAlertArchiveRepository : MongoRepository + /// Initializes a new instance of the class, which provides repository access to recording alert archive data, by storing the resolved configuration and forwarding the supplied to the base repository. + /// + /// The containing the API configuration values assigned to the repository. + /// The passed to the base class for persistence operations. + /// Thrown when is null. + /// public RecordingAlertArchiveRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/RecordingAlertRepository.cs b/adas-core.Infrastructure/Repositories/RecordingAlertRepository.cs index d13f99ee..047ad6da 100644 --- a/adas-core.Infrastructure/Repositories/RecordingAlertRepository.cs +++ b/adas-core.Infrastructure/Repositories/RecordingAlertRepository.cs @@ -18,6 +18,13 @@ public class RecordingAlertRepository : MongoRepository, { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, capturing the API configuration and forwarding the MongoDB database to the base repository to support recording-alert persistence operations. + /// + /// The providing access to the values. + /// The passed to the base class constructor. + /// Thrown when is . + /// public RecordingAlertRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/RelayRepository.cs b/adas-core.Infrastructure/Repositories/RelayRepository.cs index 8a6f20d2..9d2f65b4 100644 --- a/adas-core.Infrastructure/Repositories/RelayRepository.cs +++ b/adas-core.Infrastructure/Repositories/RelayRepository.cs @@ -23,6 +23,12 @@ public class RelayRepository : MongoRepository, IRelayRepository + /// + /// Initializes a new instance of the class, a MongoDB-backed repository that depends on . It forwards the to the base constructor and stores the configuration obtained from . + /// + /// The instance passed to the base class. + /// The wrapper supplying the active configuration. + /// public RelayRepository(IMongoDatabase database, IOptions apiSettings) : base(database) { _apiSettings = apiSettings.Value; diff --git a/adas-core.Infrastructure/Repositories/SectionRepository.cs b/adas-core.Infrastructure/Repositories/SectionRepository.cs index 6805e81f..8176a710 100644 --- a/adas-core.Infrastructure/Repositories/SectionRepository.cs +++ b/adas-core.Infrastructure/Repositories/SectionRepository.cs @@ -18,6 +18,13 @@ public class SectionRepository : MongoRepository
, ISectionRepository { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, capturing the configured and forwarding the to the base repository. + /// + /// The providing the resolved used by the repository. + /// The passed to the base constructor to enable MongoDB data access. + /// Thrown when is null. + /// public SectionRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/ServiceConfigRepository.cs b/adas-core.Infrastructure/Repositories/ServiceConfigRepository.cs index 056bc164..fc99a4a1 100644 --- a/adas-core.Infrastructure/Repositories/ServiceConfigRepository.cs +++ b/adas-core.Infrastructure/Repositories/ServiceConfigRepository.cs @@ -14,6 +14,13 @@ public class ServiceConfigRepository : MongoRepository, IServiceC { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, capturing the from the supplied and forwarding the to the base repository for MongoDB-backed operations. + /// + /// The providing access to the API configuration. + /// The passed to the base class. + /// Thrown when is null. + /// public ServiceConfigRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/TreatmentArchiveRepository.cs b/adas-core.Infrastructure/Repositories/TreatmentArchiveRepository.cs index 4d3e7a67..65b93a3b 100644 --- a/adas-core.Infrastructure/Repositories/TreatmentArchiveRepository.cs +++ b/adas-core.Infrastructure/Repositories/TreatmentArchiveRepository.cs @@ -15,6 +15,13 @@ public class TreatmentArchiveRepository : MongoRepository, ITr { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, which manages treatment archive records persisted in MongoDB. The constructor stores the API settings and forwards the connection to the base repository. + /// + /// The wrapper exposing the application API settings required by the repository. + /// The instance passed to the base constructor to provide the storage context. + /// Thrown when is . + /// public TreatmentArchiveRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Repositories/TreatmentRepository.cs b/adas-core.Infrastructure/Repositories/TreatmentRepository.cs index cd68c798..3ff1e7f6 100644 --- a/adas-core.Infrastructure/Repositories/TreatmentRepository.cs +++ b/adas-core.Infrastructure/Repositories/TreatmentRepository.cs @@ -19,6 +19,13 @@ public class TreatmentRepository : MongoRepository, ITreatment private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class by forwarding the to the base constructor and caching the resolved from . + /// + /// The providing the instance stored by the repository. + /// The passed to the base class for MongoDB access. + /// Thrown when is null. + /// public TreatmentRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); @@ -203,6 +210,12 @@ public class TreatmentRepository : MongoRepository, ITreatment return result.ToEnumerable(); } + /// + /// Retrieves a paginated, filterable query of records sorted by in descending order. When carries a FilteredRequest, the query is narrowed by , an optional date range, and the active-treatments flag; otherwise default time-based filters are applied. + /// + /// The pagination and search criteria used to build the MongoDB filter pipeline. + /// An of that can be paged or iterated. + /// public IFindFluent GetPaginatedTreatments(PaginationFilter filter) { var filterBuilder = Builders.Filter; diff --git a/adas-core.Infrastructure/Repositories/UnitRepository.cs b/adas-core.Infrastructure/Repositories/UnitRepository.cs index ec04e174..d947351d 100644 --- a/adas-core.Infrastructure/Repositories/UnitRepository.cs +++ b/adas-core.Infrastructure/Repositories/UnitRepository.cs @@ -28,6 +28,12 @@ public class UnitRepository : MongoRepository, IUnitRepository + /// + /// Initializes a new instance of the class by forwarding the to the base constructor and storing the obtained from . + /// + /// The wrapper whose provides the configuration used by the repository. + /// The connection passed to the base class constructor. + /// public UnitRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { _apiSettings = apiSettings.Value; @@ -105,6 +111,13 @@ public class UnitRepository : MongoRepository, IUnitRepository throw new NotImplementedException(); } + /// + /// Finds all records linked to the supplied master list identifier, dynamically resolving the property to filter on based on . Any failure encountered while querying is logged and rethrown. + /// + /// The of the master list whose related units should be retrieved. + /// The that selects which property of is matched against . + /// A task yielding an with the units that satisfy the resolved filter. + /// public async Task> FindByMasterListId(ObjectId id, MasterListType masterListType) { try diff --git a/adas-core.Infrastructure/Repositories/UserRepository.cs b/adas-core.Infrastructure/Repositories/UserRepository.cs index 1745cb0d..f69f21fe 100644 --- a/adas-core.Infrastructure/Repositories/UserRepository.cs +++ b/adas-core.Infrastructure/Repositories/UserRepository.cs @@ -20,6 +20,13 @@ public class UserRepository : MongoRepository, IUserRepository { private readonly ApiSettings _apiSettings; + /// + /// Initializes a new instance of the class, passing the MongoDB database to the base constructor and storing the API settings required by the repository. + /// + /// The containing the API settings used by the repository. + /// The supplied to the base constructor for MongoDB data access. + /// Thrown when is . + /// public UserRepository(IOptions apiSettings, IMongoDatabase database) : base(database) { if (apiSettings == null) throw new ArgumentNullException(nameof(apiSettings)); diff --git a/adas-core.Infrastructure/Services/PublisherService.cs b/adas-core.Infrastructure/Services/PublisherService.cs index cf1e36c9..197aa765 100644 --- a/adas-core.Infrastructure/Services/PublisherService.cs +++ b/adas-core.Infrastructure/Services/PublisherService.cs @@ -18,6 +18,12 @@ public class PublisherService : IPublisherService private readonly HashSet _queues = new(); private readonly IBus? _bus; + /// + /// Initializes a new instance of the class, a RabbitMQ publisher service, by configuring the message bus from and storing for diagnostic logging. + /// + /// The RabbitMQ configuration whose is used to initialize the message bus. + /// The logger used to record initialization status and errors. + /// public PublisherService( IOptions rabbitMqSettings, ILogger logger) @@ -48,6 +54,17 @@ public class PublisherService : IPublisherService } } + /// + /// Registers a queue with the specified for tracking purposes, + /// while the actual queue creation is delegated to EasyNetQ. Returns false when the name is + /// null, empty, or whitespace, and returns true when the queue is newly added or already + /// registered (idempotent behavior). + /// + /// The name of the queue to register. + /// A that resolves to true when the queue is successfully + /// registered (either newly added or already present), or false when + /// is null, empty, or whitespace. + /// public Task CreateQueue(string queueName) { if (string.IsNullOrWhiteSpace(queueName)) diff --git a/adas-core.Infrastructure/Services/ReceiverService.cs b/adas-core.Infrastructure/Services/ReceiverService.cs index 5455323b..b6ee7d72 100644 --- a/adas-core.Infrastructure/Services/ReceiverService.cs +++ b/adas-core.Infrastructure/Services/ReceiverService.cs @@ -31,6 +31,20 @@ public class ReceiverService private IBus? _bus; + /// + /// Initializes a new instance of by assigning the injected domain services, RabbitMQ settings and logger to backing fields. When is non-empty, it invokes and ; otherwise it logs an error. + /// + /// The observation service exposed by the receiver. + /// The treatment service exposed by the receiver. + /// The patient service exposed by the receiver. + /// The pump service exposed by the receiver. + /// The recording alert service exposed by the receiver. + /// The recording service exposed by the receiver. + /// The appointment service exposed by the receiver. + /// The alarm service exposed by the receiver. + /// The wrapper providing the configuration. + /// The used for diagnostic logging. + /// public ReceiverService( IObservationService observationService, ITreatmentService treatmentService, @@ -139,6 +153,11 @@ public class ReceiverService } } + /// + /// Registers an asynchronous consumer for the specified that receives messages, resolves the mapped service, and dispatches the payload for parsing and processing. When no service is mapped for the queue, the message is skipped with a warning; otherwise processing errors are logged and rethrown to enable the retry mechanism. + /// + /// The name of the queue whose incoming messages will be consumed. + /// private void RegisterConsumer(string queue) { _bus!.SendReceive.ReceiveAsync(queue, async payload => diff --git a/adas-core.Infrastructure/Services/RelayService.cs b/adas-core.Infrastructure/Services/RelayService.cs index 8078bbe0..8ed59b23 100644 --- a/adas-core.Infrastructure/Services/RelayService.cs +++ b/adas-core.Infrastructure/Services/RelayService.cs @@ -41,6 +41,15 @@ public class RelayService : IRelayService private readonly string _url; private UriBuilder? _builder; + /// + /// Initializes a new instance of the , storing its logging, HTTP, configuration, point-of-care, and repository dependencies, resolving the relay endpoint from configuration, and asynchronously invoking . + /// + /// The used to record diagnostic and operational messages. + /// The used to create HTTP clients for outbound calls. + /// The providing the relay configuration, including the used to compute the relay endpoint. + /// The used to interact with point-of-care data. + /// The used to persist and retrieve relay state. + /// public RelayService( ILogger logger, IHttpClientFactory httpClientFactory, @@ -277,6 +286,12 @@ public class RelayService : IRelayService return _relayRepository.GetRelayByTypeInList(configurationRelayList, type); } + /// + /// Retrieves a paginated list of entities, optionally filtered by whether each relay is currently in use by the point of care service. + /// + /// The containing paging parameters and optional filter criteria, including the flag. + /// A containing a of with the requested page data, the current page number, page size, and total document count. + /// public async Task> GetPaginatedRelays(PaginationFilter filter) { var usedRelayIds = await _pointOfCareService.FindAllIdRelaysInUse(); @@ -343,6 +358,11 @@ public class RelayService : IRelayService public event EventHandler>? RelayStatusChanged; + /// + /// Asynchronously initializes the in-memory relay status cache by iterating the point-of-care configurations returned by the service and querying the status of each configured relay. + /// Configurations whose RelayList is null are skipped, and only relays flagged with the cache option have their status stored in the _relayWithStatus dictionary keyed by IP, port, and relay number; per-relay and overall failures are logged instead of being rethrown. + /// + /// private async Task InitRelayWithStatus() { try diff --git a/adas-core.Infrastructure/Services/SendAlertService.cs b/adas-core.Infrastructure/Services/SendAlertService.cs index fd06c81c..4ea5878c 100644 --- a/adas-core.Infrastructure/Services/SendAlertService.cs +++ b/adas-core.Infrastructure/Services/SendAlertService.cs @@ -9,6 +9,12 @@ using System.Diagnostics; namespace adas_core.Infrastructure.Services; +/// +/// Implements to publish alert messages to a RabbitMQ +/// broker, using the configuration provided by +/// and the logging facility provided by . +/// +/// public class SendAlertService( IOptions rabbitMqSettings, ILogger logger) diff --git a/adas-core.Infrastructure/Utils/CacheHostBuilderExtension.cs b/adas-core.Infrastructure/Utils/CacheHostBuilderExtension.cs index 960deee1..214b662f 100644 --- a/adas-core.Infrastructure/Utils/CacheHostBuilderExtension.cs +++ b/adas-core.Infrastructure/Utils/CacheHostBuilderExtension.cs @@ -13,6 +13,12 @@ namespace adas_core.Infrastructure.Utils /// public static class CacheHostBuilderExtension { + /// + /// Registers the cache infrastructure on the host, exposing through a that can route to either an in-memory or Redis-backed implementation based on . is wired lazily so that its is only resolved once the underlying connection has been established asynchronously, while is provided with an and is registered as a no-op fallback. + /// + /// The to extend with the cache service registrations. + /// The same instance, configured with the cache services for fluent chaining. + /// public static IHostBuilder UseCache(this IHostBuilder hostBuilder) { return hostBuilder.ConfigureServices((context, services) => diff --git a/adas-core.Infrastructure/Utils/CustomPointOfCareConverter.cs b/adas-core.Infrastructure/Utils/CustomPointOfCareConverter.cs index f28b3898..dff4e5d8 100644 --- a/adas-core.Infrastructure/Utils/CustomPointOfCareConverter.cs +++ b/adas-core.Infrastructure/Utils/CustomPointOfCareConverter.cs @@ -22,6 +22,13 @@ public class CustomPointOfCareConverter : JsonConverter return objectType == typeof(PointOfCare); } + /// + /// Serializes an object to JSON, converting all enum-typed properties to their string representation rather than their underlying integer value. If is null, a JSON null token is written and the method returns immediately. + /// + /// The that receives the serialized JSON output. + /// The object to serialize. Enum properties on this instance are written as their string names. + /// The used to convert the value to a . + /// public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value == null) @@ -45,6 +52,16 @@ public class CustomPointOfCareConverter : JsonConverter jo.WriteTo(writer); } + /// + /// Reads and deserializes a JSON value into an object of the target . This override is not implemented and serves as a placeholder. + /// + /// The used to read the incoming JSON tokens. + /// The of the object to deserialize into. + /// An existing value to reuse during deserialization, or if none is available. + /// The controlling the deserialization process. + /// An instance populated from the JSON data. + /// Thrown in all cases because the method body has not been implemented. + /// public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { diff --git a/adas-core.Infrastructure/Utils/MongoDbHostBuilderExtension.cs b/adas-core.Infrastructure/Utils/MongoDbHostBuilderExtension.cs index 56c95c22..054e7276 100644 --- a/adas-core.Infrastructure/Utils/MongoDbHostBuilderExtension.cs +++ b/adas-core.Infrastructure/Utils/MongoDbHostBuilderExtension.cs @@ -81,6 +81,10 @@ public static class MongoDbHostBuilderExtension return mongoDb; } + /// + /// Discovers all concrete types in the current that implement , instantiates each one, and invokes its method to register entity mappings. + /// + /// public static void ConfigureRegisterMapClass() { var assembly = Assembly.GetExecutingAssembly(); diff --git a/adas-core.Infrastructure/Utils/MongoMaps/BoxConfigMapContributor.cs b/adas-core.Infrastructure/Utils/MongoMaps/BoxConfigMapContributor.cs index eab5432b..1212f444 100644 --- a/adas-core.Infrastructure/Utils/MongoMaps/BoxConfigMapContributor.cs +++ b/adas-core.Infrastructure/Utils/MongoMaps/BoxConfigMapContributor.cs @@ -15,6 +15,10 @@ namespace adas_core.Infrastructure.Utils.MongoMaps; /// public class BoxConfigMapContributor : IEntityMapContributor { + /// + /// Registers the BSON class maps used to control how and instances are serialized to and from MongoDB. Each registration is only performed when no class map is already registered for the target type, and the mappings exclude properties that should not be persisted, rename persisted members where needed, apply to the Configuration member of , and configure null/default-value handling for members. + /// + /// public void RegisterMaps() { if (!BsonClassMap.IsClassMapRegistered(typeof(Box))) diff --git a/adas-core.Infrastructure/Utils/MongoMaps/PumpMapContributor.cs b/adas-core.Infrastructure/Utils/MongoMaps/PumpMapContributor.cs index e8762c95..9509962e 100644 --- a/adas-core.Infrastructure/Utils/MongoMaps/PumpMapContributor.cs +++ b/adas-core.Infrastructure/Utils/MongoMaps/PumpMapContributor.cs @@ -13,6 +13,10 @@ namespace adas_core.Infrastructure.Utils.MongoMaps /// public class PumpMapContributor : IEntityMapContributor { + /// + /// Registers BSON class maps for the pump-related domain models (, , , , , , , and ) used by the MongoDB driver. Each map is registered only when no prior registration exists for the type, optional members are configured to be ignored when null, enum properties are serialized as strings, and the Id member is mapped to the _id element where applicable. + /// + /// public void RegisterMaps() { // ============================================================ diff --git a/adas-core.Infrastructure/Utils/MongoUtils.cs b/adas-core.Infrastructure/Utils/MongoUtils.cs index 7d3686c8..87371cd7 100644 --- a/adas-core.Infrastructure/Utils/MongoUtils.cs +++ b/adas-core.Infrastructure/Utils/MongoUtils.cs @@ -9,6 +9,12 @@ namespace adas_core.Infrastructure.Utils; /// public class MongoUtils { + /// + /// Ensures that the indexes defined in are present on the supplied via . For each expected index, an existing index with the same key specification is left unchanged when its options match, or dropped and recreated when they differ (except for the built-in _id_ index, which is never dropped); if no matching index exists the index is created, and MongoDB conflicts reported with code 85 are logged and tolerated. + /// + /// The whose indexes are inspected and reconciled. + /// The set of definitions that the collection should contain. + /// public static async Task EnsureIndexes(IMongoCollection collection, List> expectedIndexes) { @@ -74,6 +80,16 @@ public class MongoUtils } } + /// + /// Determines whether the options of an existing index match the expected options by comparing the unique, background, and partialFilterExpression values. + /// Missing boolean fields in are treated as false. + /// + /// The type of the document the index is defined on. + /// The containing the expected Unique, Background, and PartialFilterExpression values. + /// The representing the existing index whose options should be checked. + /// The used to render the expected partial filter expression for comparison. + /// true if the unique flag, background flag, and rendered partial filter expression all match the expected values; otherwise false. + /// private static bool IndexOptionsMatch(CreateIndexModel expectedIndexModel, BsonDocument existingIndex, RenderArgs renderArgs) { diff --git a/adas-core.Infrastructure/Utils/RabbitConsumerErrorStrategy.cs b/adas-core.Infrastructure/Utils/RabbitConsumerErrorStrategy.cs index 34f598f0..faab08bc 100644 --- a/adas-core.Infrastructure/Utils/RabbitConsumerErrorStrategy.cs +++ b/adas-core.Infrastructure/Utils/RabbitConsumerErrorStrategy.cs @@ -48,6 +48,15 @@ public class RabbitConsumerErrorHandler(IPublisherService publisherService) } } + /// + /// Handles retry processing for a received message, either forwarding it to an error queue when the maximum retry count is exceeded or republishing it to the original queue with an incremented retry counter. + /// + /// Metadata about the message origin, used to determine the source queue and to build the error message. + /// The current of the message; its headers are copied so the retry count can be updated without mutating the original instance. + /// The raw message payload that will be resent to the queue or forwarded to the error queue. + /// The that triggered the retry, included when building the error message. + /// Thrown when the republish to the original queue fails (i.e. .SendMessage returns false). The exception is caught and logged internally. + /// private void HandleRetries( MessageReceivedInfo receivedInfo, MessageProperties properties, diff --git a/adas-core.Infrastructure/Utils/TypesUtils.cs b/adas-core.Infrastructure/Utils/TypesUtils.cs index 1c550629..af971249 100644 --- a/adas-core.Infrastructure/Utils/TypesUtils.cs +++ b/adas-core.Infrastructure/Utils/TypesUtils.cs @@ -25,6 +25,15 @@ public static class TypesUtils }; } + /// + /// Resolves the of a device driver class by locating a loaded assembly whose name contains and then loading the type at the path formed by replacing hyphens in with underscores and appending .Devices., , and . + /// + /// Substring used to match the loaded assembly and to build the namespace portion of the target type name. + /// Device identifier segment combined into the target class name. + /// Suffix appended to to form the final class name. + /// The resolved representing the device driver class. + /// Thrown when no loaded assembly matches or when the driver type cannot be resolved within the matched assembly. + /// private static Type GetType(string typeName, string device, string deviceType) { var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); diff --git a/adas-core.Test/Customizations/H12O/UCIN/CalculatedObservationsTest.cs b/adas-core.Test/Customizations/H12O/UCIN/CalculatedObservationsTest.cs index d5f47ce7..e2c48dba 100644 --- a/adas-core.Test/Customizations/H12O/UCIN/CalculatedObservationsTest.cs +++ b/adas-core.Test/Customizations/H12O/UCIN/CalculatedObservationsTest.cs @@ -12,10 +12,28 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Customizations.H12O.UCIN; +/// +/// Represents a test fixture that contains unit tests for calculated observations, executing with an order priority of 2 relative to other test fixtures. +/// +/// +/// This fixture is annotated with to mark it as a container of NUnit test methods, and with to control its execution sequence within the test suite. +/// +/// [TestFixture] [Order(2)] public class CalculatedObservationsTest { + /// + /// Initializes the test fixture for by creating mocked instances of + /// , , , + /// , and , configuring + /// settings for medication bolus, transcutaneous, regional brain saturation, + /// electroencephalogram, respiratory, high-frequency ventilation, invasive ventilation, non-invasive + /// ventilation, one-lung isolation, and ECMO codes, and registering all dependencies in a + /// so that a fully wired instance + /// is produced for each test. + /// + /// [SetUp] public void Setup() { @@ -79,6 +97,10 @@ public class CalculatedObservationsTest private IOptions _optionsApiSettings; + /// + /// Verifies that processing a new that contains a medicine—matched by code to a known with an assigned —for the first time for a patient (no prior observations and no active treatments) results in a named Medication with value 1 associated to the treatment's . + /// + /// [Test] public async Task Calculate_First_Medicine_Observation_With_Type_Should_Return_1() { @@ -128,6 +150,12 @@ public class CalculatedObservationsTest } + /// + /// Verifies that mapping a new containing a medicine, when no prior + /// observations or active treatments exist for the patient, results in the insertion of a + /// named "Medication" with value 0 for the patient. + /// + /// [Test] public async Task Calculate_First_Medicine_Observation_With_Out_Type_Should_Return_1() { @@ -176,6 +204,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that when a new with an OrderControl of is mapped for the first time and contains a medicine code, a with name Medication and value 1 is inserted for the patient. + /// + /// [Test] public async Task Calculate__Medicine_Observation_New_Type_Should_Sum_1() { @@ -226,6 +258,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that when a new is mapped and a prior of name "Medication" with value 0 already exists for the patient, the calculated observations service inserts a new observation with value 1 (the sum of the existing value 0 plus the new contribution). + /// + /// [Test] public async Task Calculate__Medicine_Observation_Type_Already_Exists_Should_Sum_0() { @@ -296,6 +332,12 @@ public class CalculatedObservationsTest } + /// + /// Verifies that when a medicine observation of type already exists for the patient, + /// subtracts the existing value and inserts a new observation with a resulting value of 0. + /// + /// A representing the asynchronous unit test execution. + /// [Test] public async Task Calculate__Medicine_Observation_DC_Type_Already_Exists_Should_Subtract_0() { @@ -357,6 +399,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that when a treatment is processed and the patient has two active medicines, a Medication observation is inserted with the last observation value decremented by one (2 - 1 = 1). + /// + /// [Test] public async Task Calculate__Medicine_Observation_DC_OF_TYPE_WITH_TWO_MEDICINES_Should_Subtract_0() { @@ -439,6 +485,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a new containing a medicine without a defined type results in the insertion of a named "Medication" with a value of 1 for the associated patient. + /// + /// [Test] public async Task Calculate_Medicine_Observation_New_Medicine_Without_Type_Should_Insert_Medication_1_point() { @@ -514,6 +564,12 @@ public class CalculatedObservationsTest } + /// + /// Verifies that . inserts a new + /// observation with a score of 5 when processing the first + /// intravenous arterial observation for a patient, given that no previous observations exist. + /// + /// [Test] public async Task Calculate_First_Intravenous_Arterial_Observation_Should_Return_5() { @@ -550,6 +606,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that when a previous for the same patient and location has already been removed, the intravenous calculation performed by produces a result of 0. + /// + /// [Test] public async Task Calculate_Intravenous_Obs_Already_Exist_Removed_Should_Return_0() { @@ -600,6 +660,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a with an whose type and location match the last stored observation for the same patient does not trigger an insertion of a calculated "IntravenousLines" observation. + /// + /// [Test] public async Task Calculate_Intravenous_two_observations_of_same_type_and_same_location_should_return_null() { @@ -647,6 +711,10 @@ public class CalculatedObservationsTest ), true, true), Times.Never); } + /// + /// Verifies that when a new PatientObservation of type "IntravenousLinesObs" is processed alongside a previous observation of the same type for the same patient, the calculator produces a derived PatientObservation named "IntravenousLines" with a value of 10. + /// + /// [Test] public async Task Calculate_Intravenous_two_observations_of_same_type_should_return_10() { @@ -696,6 +764,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that the method limits the calculated sum of observations to a maximum value of ten when the total exceeds that threshold. + /// + /// [Test] public async Task Calculate_Intravenous_sum_more_than_10_should_limit_to_ten() { @@ -761,6 +833,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that mapping a new with a "Catéter línea media" type, when two prior intravenous lines exist (one "Catéter EPICUTÁNEO PERIFÉRICO" and one "Catéter Venoso PERIFÉRICO"), inserts an named "IntravenousLines" with a summed value of 5 for the given . + /// + /// [Test] public async Task Calculate_Intravenous_sum_one_middle_line_and_two_Peripheral_should_return_5() { @@ -825,6 +901,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that . produces a monitor observation with value 3 for a treatment containing the EEG code 42803009, based on the most recent transcutaneous and regional brain saturation observations retrieved for the patient. + /// + /// [Test] public async Task Calculate_Monitor_Transcuatenous_Regional_Brain_Saturation_and_enter_EEG_should_return_3() { @@ -896,6 +976,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a ventilation with value OXIDO NITRICO 800 PPM MOL for a patient with no prior observations produces a derived named "Respiratory" with an integer value of 10. + /// + /// [Test] public async Task Calculate_Respiratory_INO_should_return_10() { @@ -924,6 +1008,13 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that calculates a respiratory value of 5 when the patient observation + /// represents a "V.A.F.O." (ventilación de alta frecuencia oscilatoria) entry coded as 361110005 in the SNM coding system, + /// using an empty list returned by . + /// + /// A that completes when the assertions have been executed. + /// [Test] public async Task Calculate_Respiratory_VAFO_should_return_5() { @@ -952,6 +1043,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a with value "V.M.C." (ventilation type, SNOMED code "361110005") produces a calculated respiratory observation with value 3 for the same , when no previous observations are returned by the observation service. + /// + /// [Test] public async Task Calculate_Respiratory_VMC_should_return_3() { @@ -980,6 +1075,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a with the ventilation type V.N.I. Ciclada (Non-Invasive Mechanical Ventilation) results in the insertion of a calculated respiratory observation with an integer value of 2 for the same patient. + /// + /// [Test] public async Task Calculate_Respiratory_VMNI_should_return_2() { @@ -1008,6 +1107,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that when a with name "Tipo de ventilación" and value "Bajo Flujo" is mapped, a calculated respiratory observation is inserted with value 1 for the associated patient. + /// + /// [Test] public async Task Calculate_Respiratory_Nassal_Canulas_Bajo_Flujo_should_return_2() { @@ -1036,6 +1139,10 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that returns a respiratory value of 1 when the patient observation indicates an "Alto Flujo" (high flow nasal cannula) ventilation type, identified by "361110005" in the SNM coding system. + /// + /// [Test] public async Task Calculate_Respiratory_Nassal_Canulas_Alto_Flujo_should_return_1() { @@ -1064,6 +1171,12 @@ public class CalculatedObservationsTest ), true, false)); } + /// + /// Verifies that mapping a with the name "Resp_Mode" and the value "PC-AC" + /// produces a calculated observation for "Resp_Type" using the "ADAS" coding system with the + /// value. + /// + /// [Test] public async Task Calculate_Ventilation_Mode_Returns_INVASIVE() { @@ -1085,6 +1198,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a with the name Resp_Mode and value DUOPAP triggers an insert of a new observation named Resp_Type using the value. + /// + /// [Test] public async Task Calculate_Ventilation_Mode_Returns_NON_INVASIVE() { @@ -1106,6 +1223,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a with the Resp_Mode name and the PC-HFO value produces a calculated observation named Resp_Type using the ADAS coding system whose value resolves to . + /// + /// [Test] public async Task Calculate_Ventilation_Mode_Returns_HIGH_FREQUENCY() { @@ -1127,6 +1248,11 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that when a with "Resp_Mode" and "VENTAPNEA" is mapped, the calculated observation for "Resp_Type" is produced with using the "ADAS" coding system. + /// + /// A representing the asynchronous test execution. + /// [Test] public async Task Calculate_Ventilation_Mode_Returns_NONE() { @@ -1148,6 +1274,12 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that CalculateOxygenationIndex retrieves the latest AirPressure_Mean, FiO2, and PaO2 + /// values for the patient via FindLastObservations and inserts a new + /// named "Oxygenation_Index" with the correctly computed value of 1250. + /// + /// [Test] public async Task CalculateOxygenationIndex_ShouldInsertCorrectObservation() { @@ -1178,6 +1310,13 @@ public class CalculatedObservationsTest It.IsAny(), It.IsAny())); } + /// + /// Verifies that inserts a new + /// with the name Respiratory for the patient when the most recent + /// retrieved observation matches the expected respiratory mode (Resp_Mode), and returns the + /// original . + /// + /// [Test] public async Task CalculateAsistResp_ShouldUpdateObservation_WhenConditionsMet() { @@ -1215,6 +1354,13 @@ public class CalculatedObservationsTest // [TestCase("valorInvasive", RespirationType.INVASIVE)] // [TestCase("valorNonInvasive", RespirationType.NON_INVASIVE)] // [TestCase("valorNone", RespirationType.NONE)] + /// + /// Verifies that maps the supplied input value to the expected and persists it as a Resp_Type observation via . + /// Handles the localized input cases valorHFV (mapped to PC-HFO), valorInvasive (mapped to PRVC), and valorNonInvasive (mapped to DUOPAP); any other value falls back to . + /// + /// The raw Resp_Mode input value from the observation; when it does not match a known ventilation label, it is replaced by . + /// The expected to be inserted as Resp_Type after the calculation runs. + /// public async Task CalculateVentilationMode_ShouldInsertCorrectRespType(string value, RespirationType expectedRespType) { @@ -1246,6 +1392,16 @@ public class CalculatedObservationsTest // [TestCase("Age_Gestational", 1, 2, ObservationStatus.Alert)] // [TestCase("Age_Gestational", 1, 12, ObservationStatus.Ok)] // [TestCase("Age_Gestational_Fixed", 5, 10, ObservationStatus.Ok)] + /// + /// Verifies that the CalculateTAmAlert method updates the status of a TAm observation + /// to the expected when the observation name is "TAm", and inserts a new + /// TAm observation when the name is "Age_Gestational" or "Age_Gestational_Fixed". + /// + /// The name of the observation under test, expected to be "TAm", "Age_Gestational", or "Age_Gestational_Fixed". + /// The numeric TAm value assigned to the observation and related grouped observations. + /// The numeric gestational age value used in the related grouped observations. + /// The expected used to assert the resulting observation status. + /// public async Task CalculateTAmAlert_ShouldUpdateStatusCorrectly(string observationName, int tamValue, int gestationalAge, StatusEnum.Type expectedType) { @@ -1306,6 +1462,10 @@ public class CalculatedObservationsTest It.Is(o => o.PatientId == patientId && o.Name == "TAm"), It.IsAny(), It.IsAny())); } + /// + /// Verifies that the ParseWeight method correctly converts the units to "gr" and scales the value (multiplying by 1000) when given a valid with a numeric . + /// + /// [Test] public async Task ParseWeight_WhenValidObservation_ShouldConvertUnitsAndValue() { @@ -1328,6 +1488,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that ParseWeight handles non-numeric gracefully by returning the original unchanged. + /// + /// [Test] public async Task ParseWeight_WhenValueIsNotNumeric_ShouldHandleGracefullyAndReturnOriginal() { @@ -1339,6 +1503,10 @@ public class CalculatedObservationsTest Assert.That(result, Is.EqualTo(obs)); } + /// + /// Verifies that the ParseWeight method returns the original unchanged when the observation cannot be converted to a PatientObservation, exercising the fallback behavior for invalid input types. + /// + /// [Test] public async Task ParseWeight_WhenInvalidObservation_ShouldReturnOriginal() { @@ -1350,6 +1518,10 @@ public class CalculatedObservationsTest Assert.That(result, Is.EqualTo(obs)); } + /// + /// Verifies that when the patient temperature and the latest incubator temperature observation are both recent, CalculateTempGradient triggers an InsertObservation call exactly once to persist the computed Temp_Gradient value (incubator minus patient temperature). + /// + /// [Test] public async Task CalculateTempGradient_WhenTempPatientAndTempIncubatorAreRecent_ShouldCalculateGradient() { @@ -1410,6 +1582,11 @@ public class CalculatedObservationsTest ), Times.Once()); } + /// + /// Verifies that the temperature gradient calculation does not persist a new + /// when the lookup for the complementary temperature reading returns no observations. + /// + /// [Test] public async Task CalculateTempGradient_WhenOneTemperatureIsMissing_ShouldNotCalculateGradient() { @@ -1437,6 +1614,10 @@ public class CalculatedObservationsTest ), Times.Never()); // Verificamos que InsertObservation no se llama } + /// + /// Verifies that the intravenous line observation calculation maps to "IntravenousLines", preserves , and ensures is not earlier than the current time when no prior intravenous lines observation exists. + /// + /// [Test] public async Task CalculateIntravenousLineObservation_ShouldCalculateObservationAndAdjustTimeIfNecessary() { @@ -1474,6 +1655,10 @@ public class CalculatedObservationsTest }; } + /// + /// Verifies that correctly calculates and inserts a "Monitor" when the patient has a valid existing observation matching the configured regional brain saturation code or an active treatment. + /// + /// [Test] public async Task CalculateMonitor_WithValidObservationOrTreatment_ShouldCalculateAndInsertObservation() { @@ -1520,6 +1705,10 @@ public class CalculatedObservationsTest Times.Once()); } + /// + /// Verifies that CalculateMonitor calculates and inserts a new Monitor observation for the patient when invoked with a , provided an active treatment exists and a matching non-expired is returned by FindLastObservations. + /// + /// [Test] public async Task CalculateMonitor_WithPatientTreatment_ShouldCalculateAndInsertObservation() { @@ -1565,6 +1754,13 @@ public class CalculatedObservationsTest Times.Once()); } + /// + /// Verifies that does not invoke + /// when the supplied + /// contains incomplete data (only + /// is populated), and the prior observations returned by are empty. + /// + /// [Test] public async Task CalculateMonitor_WithIncompleteData_ShouldNotInsertObservation() { @@ -1594,6 +1790,10 @@ public class CalculatedObservationsTest Times.Never()); } + /// + /// Verifies that the surgery expiration check does not insert the when its flag is set to false, ensuring that only expired observations trigger an insertion. + /// + /// [Test] public async Task CheckSurgeryExpired_WhenNotExpired_DoesNotInsertObservation() { @@ -1608,6 +1808,10 @@ public class CalculatedObservationsTest Times.Never); } + /// + /// Tests that when a has expired, inserts a new named "Surgery" with value 0, range 0 to 5, coding system "ADAS", timestamp offset by one second from the original observation, and matching patient identifier and expiry duration. + /// + /// [Test] public async Task CheckSurgeryExpired_WhenExpired_InsertsCorrectObservation() { @@ -1634,6 +1838,10 @@ public class CalculatedObservationsTest ), true, false), Times.Once); } + /// + /// Verifies that inserts a new complexity observation when processing a patient observation in a non-ECMO treatment context, ensuring the active treatments and recent observations are retrieved and the resulting complexity value is persisted. + /// + /// [Test] public async Task CalculateComplexity_NewObservation_NoECMO_AddsComplexity() { @@ -1693,6 +1901,12 @@ public class CalculatedObservationsTest ), true, false), Times.Once); } + /// + /// Verifies that when an expired is passed to the complexity calculation, + /// no new complexity record is inserted into the database, ensuring that expired observations are excluded + /// from contributing to the patient's calculated complexity value. + /// + /// [Test] public async Task CalculateComplexity_ExpiredObservation_DoesNotAddToComplexity() { @@ -1725,6 +1939,12 @@ public class CalculatedObservationsTest ), true, true), Times.Never); // No se debe llamar InsertObservation } + /// + /// Verifies that when an active treatment includes ECMO, + /// preserves the original value and records a derived Complexity observation labeled + /// "1 ECMO" for the patient. + /// + /// [Test] public async Task CalculateComplexity_ECMOActive_AdjustsComplexity() { @@ -1784,6 +2004,10 @@ public class CalculatedObservationsTest ), true, false), Times.Once); } + /// + /// Verifies that increments the by one second beyond the existing observation when the lookup returns a sharing the same timestamp, patient, and observation name as the supplied instance. + /// + /// [Test] public async Task CheckObsExistsAndIncrementTime_SameHourObservation_IncrementsTime() { @@ -1823,6 +2047,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that increments the of the supplied by one second and assigns a new when another observation with the same time and already exists for the same . + /// + /// [Test] public async Task CheckObsWithSameTimeExistsAndIncrementTime_WhenObservationWithSameTimeExists_IncrementsTime() { @@ -1869,6 +2097,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that correctly processes a treatment whose notes contain a parental nutrition formulation (comment "NPT" with comment type "formularybaseformulation"), looking up the associated by code, retrieving active treatments and the last medication observation for the patient, and inserting a new with "Medication", "ADAS" and 1. + /// + /// [Test] public async Task CheckTreatmentMedicines_ProcessesTreatmentCorrectly_WithParentalNutritionMedicine() { diff --git a/adas-core.Test/Customizations/HPAZ/CalculatedObservationsTest.cs b/adas-core.Test/Customizations/HPAZ/CalculatedObservationsTest.cs index 2d600c2d..26f00186 100644 --- a/adas-core.Test/Customizations/HPAZ/CalculatedObservationsTest.cs +++ b/adas-core.Test/Customizations/HPAZ/CalculatedObservationsTest.cs @@ -13,6 +13,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Customizations.HPAZ; +/// +/// Provides a NUnit test fixture that hosts unit tests verifying the behavior of calculated observations. +/// +/// +/// The class is marked with the attribute to group test methods that validate calculated observation logic. +/// +/// [TestFixture] public class CalculatedObservationsTest { @@ -832,6 +839,10 @@ public class CalculatedObservationsTest } + /// + /// Verifies that mapping a with a null drug name and results in an inserted position name formatted as "Rack 1 Bomba 2". + /// + /// [Test] public async Task Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_PositionName() { @@ -882,6 +893,10 @@ public class CalculatedObservationsTest arg.Value.ToString() == "Rack 1 Bomba 2"), true, true)); } + /// + /// Verifies that mapping a with a null drug name, alarm, and set to true produces an insertion of the main pump observation and an auxiliary observation with a position name formatted as "Rack Aux {GatewayNumber} Bomba {Number}". + /// + /// [Test] public async Task Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_Aux_PositionName() diff --git a/adas-core.Test/Customizations/HRYC/CalculatedObservationsTest.cs b/adas-core.Test/Customizations/HRYC/CalculatedObservationsTest.cs index 72e724f2..4814d07b 100644 --- a/adas-core.Test/Customizations/HRYC/CalculatedObservationsTest.cs +++ b/adas-core.Test/Customizations/HRYC/CalculatedObservationsTest.cs @@ -13,9 +13,20 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Customizations.HRYC; +/// +/// Provides an NUnit test fixture that verifies the behavior of calculated observations. +/// +/// +/// Decorated with to mark the class as a container for related NUnit test methods that exercise calculated observation logic. +/// +/// [TestFixture] public class CalculatedObservationsTest { + /// + /// Initializes the test environment for by mocking , , , and , configuring the latter to look up NEWS alert configurations by and return when no entry matches, registering all dependencies through a , and providing a sample resolved by its . + /// + /// [SetUp] public void Setup() { @@ -113,6 +124,10 @@ public class CalculatedObservationsTest private ObjectId _patientUnitId = ObjectId.GenerateNewId(); private Patient _patient; + /// + /// Verifies that mapping a with NEWS coding, when the resolved enables a beacon alarm with , triggers the light beacon service to send to the patient's . + /// + /// [Test] public async Task Calculate_CheckBeaconOnNEWS_Should_Send_PowerOff() { @@ -148,6 +163,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that when a with the "NEWS" name, "ADAS" coding system, and a value of 6 is processed, and the resolved enables a yellow beacon alarm, the is invoked exactly once to send to the patient's point of care. + /// + /// [Test] public async Task Calculate_CheckBeaconOnNEWS_Should_Send_Yellow() { @@ -183,6 +202,10 @@ public class CalculatedObservationsTest LightBeaconColor.Yellow), Times.Once); } + /// + /// Verifies that when a using the NEWS coding system is mapped and the resolved configuration defines an enabled red beacon alarm, the light beacon service is invoked exactly once to send the red color to the patient's point of care. + /// + /// [Test] public async Task Calculate_CheckBeaconOnNEWS_Should_Send_Red() { @@ -219,6 +242,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that .Map correctly produces a with name NEWS_EXTR_HI_Resp_Rate, coding system ADAS, and the same numeric value as the supplied respiratory rate (FR) when the latest ventilator rate, SpO2 and FiO2 observations are available. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FR_Returns_NEWS_EXTR_HI_Resp_Rate() @@ -270,6 +297,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a named FR with an invalid (non-numeric) value does not produce a NEWS_EXTR_HI respiratory rate result and instead raises a , even when valid Vent_Rat, SpO2, and FiO2 observations are available for the same patient. + /// + /// [Test] public async Task Calculate_FR_Does_Not_Returns_NEWS_EXTR_HI_Resp_Rate_When_Invalid_Value() { @@ -321,6 +352,15 @@ public class CalculatedObservationsTest } + /// + /// Verifies that mapping a respiratory rate (FR) observation through + /// produces a + /// NEWS_HI_Resp_Rate observation with the expected value (23) and coding system + /// (ADAS), resolving the ventilator rate (Vent_Rat), SpO2, and FiO2 + /// inputs via the mocked calls and inserting + /// the result through . + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FR_Returns_NEWS_HI_Resp_Rate() @@ -377,6 +417,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies (under the legacy NEWS calculation path, currently ignored via ) that mapping a respiratory rate (FR) produces an inserted NEWS_EXTR_LO_Resp_Rate observation tagged with the ADAS coding system and carrying the same numeric value, using mocked supporting observations for ventilation rate (Vent_Rate) and oxygenation (SpO2, FiO2). + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FR_Returns_NEWS_EXTR_LO_Resp_Rate() @@ -433,6 +477,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a with an SpO2 value of 90 produces an inserted named NEWS_EXTR_LO_SpO2 using the ADAS coding system, by mocking the lookup of the last FiO2 and FR observations for the same . The test is annotated with [Ignore] because it targets the legacy NEWS calculation logic. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_SpO2_Returns_NEWS_EXTR_LO_SpO2() @@ -471,6 +519,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a SpO2 produces a NEWS Low SpO2 score with name "NEWS_LO_SpO2", coding system "ADAS", and a value reflecting the source SpO2 reading (93), while relying on the last available respiratory rate (FR) observation for the calculation. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_SpO2_Returns_NEWS_LO_SpO2() @@ -509,6 +561,11 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a whose is Temperature results in a derived named NEWS_EXTR_LO_Temperature, coded under the ADAS system, and carrying the original numeric . + /// Marked with because it covers the legacy NEWS calculation logic. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_Temperature_Returns_NEWS_EXTR_LO_Temperature() @@ -534,6 +591,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a high with name "Temperature" and value 40 produces a calculated NEWS high-temperature observation (NEWS_HI_Temperature) under the ADAS coding system. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_Temperature_Returns_NEWS_HI_Temperature() @@ -559,6 +620,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a with the name "TAs" produces an associated low NEWS extra observation named "NEWS_EXTR_LO_TAs" in the ADAS coding system, carrying the same numeric value as the source observation. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_TAs_Returns_NEWS_EXTR_LO_TAs() @@ -584,6 +649,11 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that when a TAs (systolic blood pressure) is mapped, a derived NEWS_LO_TAs observation is inserted with the expected and . + /// This test is currently ignored because it targets the old NEWS calculation logic. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_TAs_Returns_NEWS_LO_TAs() @@ -609,6 +679,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a named "TAs" with a value of 240 produces an inserted observation named "NEWS_EXTR_HI_TAs" under the "ADAS" coding system through . The test is currently ignored as it covers the old NEWS calculation logic. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_TAs_Returns_NEWS_EXTR_HI_TAs() @@ -634,6 +708,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a with the name "FC" and a value of 20 produces an inserted calculated observation named "NEWS_EXTR_LO_FC" using the "ADAS" coding system, where the inserted value matches the original value of 20. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FC_Returns_NEWS_EXTR_LO_FC() @@ -659,6 +737,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a with a heart rate (FC) value of 140 through the calculation pipeline produces a derived NEWS extra-high heart rate (NEWS_EXTR_HI_FC) observation carrying the same value and tagged with the ADAS coding system. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FC_Returns_NEWS_EXTR_HI_FC() @@ -684,6 +766,11 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a named "FC" with value 120 produces a derived "NEWS_HI_FC" observation that is inserted through the observation service under the "ADAS" coding system with the original value preserved. + /// The test is marked as ignored because it targets the legacy NEWS calculation flow. + /// + /// [Ignore("old NEWS calc")] [Test] public async Task Calculate_FC_Returns_NEWS_HI_FC() @@ -709,6 +796,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that during the pre-mapping of a list of items, any observation named MDC_VENT_RESP_RATE (code 151586) is removed from the resulting list and inserted as a separate observation via . + /// + /// [Test] public async Task Check_MDC_VENT_RESP_RATE_IsInsertedBefore_And_RemoveFromList() { @@ -769,6 +860,10 @@ public class CalculatedObservationsTest obs.Code == "151586"), true, true), Times.Once); } + /// + /// Verifies that when mapping processes a respiratory-rate observation alongside a preceding vent-rate observation returned by , the calculated respiratory-rate observation is inserted with its offset by one second from the source observation and with its populated from the vent-rate observation. + /// + /// [Test] public async Task Check_Insert_Resp_Rate_Calculated_HasTimePlusOneSecond_And_Resp_Rate_Calculated_HasVentRateAsParent() @@ -816,6 +911,14 @@ public class CalculatedObservationsTest obs.Time == nowPlusOneSecond), true, true), Times.Once); } + /// + /// Verifies that mapping a patient observation with the name Resp_Mode and value PC-AC + /// through .Map produces a calculated observation named + /// Resp_Type using the ADAS coding system with the value + /// . + /// + /// A representing the asynchronous unit test execution. + /// [Test] public async Task Calculate_Ventilation_Mode_Should_Return_INVASIVE() { @@ -838,6 +941,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a for respiratory mode with a non-invasive ventilation value produces a calculated Resp_Type observation classified as . + /// + /// [Test] public async Task Calculate_Ventilation_Mode_Should_Return_NON_INVASIVE() { @@ -861,6 +968,10 @@ public class CalculatedObservationsTest } } + /// + /// Verifies that mapping a whose is "Resp_Mode" and is "HNF" causes the calculation service to insert an observation with the "Resp_Type", the "ADAS", and the set to . + /// + /// [Test] public async Task Calculate_Ventilation_Mode_Should_Return_HIGH_FREQUENCY() { @@ -985,6 +1096,10 @@ public class CalculatedObservationsTest //} + /// + /// Verifies that the mapping logic computes a diuresis-to-weight ratio of 43.6 from a diuresis observation of 3924 and a weight observation of 90 for the same patient, inserting the result as a new named "Diuresis_Weight". + /// + /// [Test] public async Task CalculateDiuresis_Weight_Received_D_3924_W_90_Return_43_6() { @@ -1018,6 +1133,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that . correctly computes the diuresis-to-weight ratio as 43.6 when the latest diuresis observation value is 3924 and the current weight observation value is 90, and persists a derived named "Diuresis_Weight" for the same . + /// + /// [Test] public async Task CalculateDiuresis_Weight_D_3924_Receive_W_90_Return_43_6() { @@ -1051,6 +1170,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that when a with the name Weight_Current is received but no prior diuresis observations exist for the patient, the mapping does not insert any calculated observation. + /// + /// [Test] public async Task CalculateDiuresis_Weight_Received_W_90_D_Null_Return_Nothing() { @@ -1073,6 +1196,10 @@ public class CalculatedObservationsTest Times.Never); } + /// + /// Verifies that when receives a Diuresis observation with value 3924 and the lookup for the last observation returns no results, the calculated "Diuresis_Weight" observation is not inserted. + /// + /// [Test] public async Task CalculateDiuresis_Weight_Received_D_3924_W_Null_Return_Nothing() { @@ -1097,6 +1224,10 @@ public class CalculatedObservationsTest ), true, true), Times.Never); } + /// + /// Verifies that mapping a named "AllergiesObs" containing an empty list of produces a calculated named "Allergies" with an empty string value for the given patient. + /// + /// [Test] public async Task CalculateAllergiesObservation_Received_AllergiesObs_Emty_Return_Allergies_Emty() { @@ -1121,6 +1252,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a named "AllergiesObs" that contains non-pharmacological allergies (such as "Latex" and "Alergia ambiental") results in the insertion of an "Allergies" observation whose value is the uppercase, comma-separated concatenation of the allergy types (e.g., "LATEX, AMBIENTAL"). + /// + /// [Test] public async Task CalculateAllergiesObservation_Received_AllergiesObs_Without_Farmacos_Return_Allergies() { @@ -1161,6 +1296,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that consolidates a received AllergiesObs containing one drug allergy (fármacos), a latex allergy, and an environmental allergy into a single named Allergies for the same , with the values merged into the formatted string LATEX, AMBIENTAL, FÁRMACOS (METILPREDNISOLONA). + /// + /// [Test] public async Task CalculateAllergiesObservation_Received_AllergiesObs_With_1_Farmacos_Return_Allergies() { @@ -1208,6 +1347,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that aggregates a received AllergiesObs observation containing multiple allergy types — including two drug allergies (METILPREDNISOLONA and Penicilina/cefalosporinas), a latex allergy and an environmental allergy — into a single named Allergies, whose value combines the allergy categories and the drug allergens into the expected grouped string. + /// + /// [Test] public async Task CalculateAllergiesObservation_Received_AllergiesObs_With_2_Farmacos_Return_Allergies() { @@ -1261,6 +1404,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that when a carrying a of type "Drenaje ventricular" with volume 60 and height 8 is processed by the calculator, two derived observations are inserted: one named "DVE" carrying the volume value and another named "Drainage_Height" carrying the height value, both under the "ADAS" coding system. + /// + /// [Test] public async Task Calculate_Drainages_Received_volume_60_height_8_Return_DVE_height() { @@ -1298,6 +1445,10 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Verifies that mapping a carrying a of type "Drenaje ventricular" with a volume of 60 and no height produces a "DVE" observation while suppressing the "Drainage_Height" observation. + /// + /// [Test] public async Task Calculate_Drainages_Received_volume_60_height_null_Return_DVE() { @@ -1332,6 +1483,12 @@ public class CalculatedObservationsTest ), true, true), Times.Never); } + /// + /// Verifies that when a containing a + /// has a null received volume but a defined height (8), the mapping inserts a new observation named "Drainage_Height" + /// with the height value while not creating a "DVE" observation. + /// + /// [Test] public async Task Calculate_Drainages_Received_volume_null_height_8_Return_height() { @@ -1366,6 +1523,11 @@ public class CalculatedObservationsTest ), true, true)); } + /// + /// Tests that mapping a of drainages type with null volume and null height values + /// does not generate any calculated DVE or Drainage_Height observations. + /// + /// [Test] public async Task Calculate_Drainages_Received_volume_null_height_null_Return_nothing() { diff --git a/adas-core.Test/Customizations/HUVH/UCIA/CalculatedObservationsTest.cs b/adas-core.Test/Customizations/HUVH/UCIA/CalculatedObservationsTest.cs index 69db473a..512e53f8 100644 --- a/adas-core.Test/Customizations/HUVH/UCIA/CalculatedObservationsTest.cs +++ b/adas-core.Test/Customizations/HUVH/UCIA/CalculatedObservationsTest.cs @@ -13,6 +13,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Customizations.HUVH.UCIA; +/// +/// Test fixture that validates the behavior of related functionality within the test suite. +/// +/// +/// Marked with TestFixture and assigned Order(2) to control its execution sequence relative to other fixtures. +/// +/// [TestFixture] [Order(2)] public class CalculatedObservationsTest @@ -298,6 +305,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that the mapping logic inserts a calculated ventilation mode observation when an Air_Flow is processed and the patient's coding system is CCC, ensuring the insert call is triggered exactly once. + /// + /// [Test] public async Task CalculateVentilationMode_Should_Insert_When_AirFlow_Arrives_And_CCC_Mode() { @@ -488,6 +499,10 @@ public class CalculatedObservationsTest ); } + /// + /// Verifies that the over-analgesia calculation does not create a new when the required conditions are not met: the source observation value falls below the expected threshold and the patient has no active s. + /// + /// [Test] public async Task CalculateOverAnalgesia_Should_Not_Create_Observation_When_Conditions_Are_Not_Met() { @@ -547,6 +562,10 @@ public class CalculatedObservationsTest ); } + /// + /// Verifies that driving pressure is not calculated nor persisted through when the complementary required for the calculation is missing for the patient. + /// + /// [Test] public async Task CalculateDrivingPressure_Should_Not_Calculate_If_Observation_Is_Missing() { @@ -603,6 +622,13 @@ public class CalculatedObservationsTest ); } + /// + /// Verifies that the ROX index mapping operation does not persist a calculated + /// when the required complementary observation + /// (needed to compute the ratio) cannot be retrieved, ensuring the calculation + /// is skipped instead of being stored with incomplete data. + /// + /// [Test] public async Task CalculateRoxIndex_Should_Not_Calculate_If_Observation_Is_Missing() { diff --git a/adas-core.Test/Customizations/HUVH/UCIN/CalculatedObservationsTest.cs b/adas-core.Test/Customizations/HUVH/UCIN/CalculatedObservationsTest.cs index 21bbbfa8..246b2864 100644 --- a/adas-core.Test/Customizations/HUVH/UCIN/CalculatedObservationsTest.cs +++ b/adas-core.Test/Customizations/HUVH/UCIN/CalculatedObservationsTest.cs @@ -13,9 +13,20 @@ using Newtonsoft.Json; namespace adas_core.Test.Customizations.HUVH.UCIN; +/// +/// Test fixture that contains unit tests for the type. +/// +/// +/// Marked with TestFixture so that the NUnit test runner discovers and executes the contained test methods. +/// +/// [TestFixture] public class CalculatedObservationsTest { + /// + /// Initializes the mocked dependencies and configuration required to instantiate for unit tests, including observation, medicine, and treatment services, the logger, and an populated with mapping interventions and complexity observation values deserialized from JSON. + /// + /// [SetUp] public void Setup() { @@ -1468,6 +1479,10 @@ public class CalculatedObservationsTest Times.Never); } + /// + /// Verifies that when a new "Intervention_In" observation is mapped via Map and the patient's prior "Respiratory_Device_Multivalue" observation is expired (so there is no existing active last observation), a new named "Respiratory_Device_Multivalue" is inserted containing the new intervention while the existing expired observation is left untouched. + /// + /// [Test] public async Task Map_WithNewInterventionNoExistingLastIntervention_NewMultiValueObservation() { @@ -1519,6 +1534,13 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that when a new Intervention_In observation is mapped for a patient that already has an + /// active Respiratory_Device_Multivalue observation, the new intervention is appended to the existing + /// multi-value observation via rather than inserted as a + /// new record through . + /// + /// [Test] public async Task Map_WithNewInterventionAddsToExistingMultiValueObservation() { @@ -1805,6 +1827,12 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that the Map method persists a "Complexity" with value 5 + /// when an "Intravenous_Routes_Multivalue" entry of "VV central" (contributing 2) and a "Respiratory_Device_Multivalue" + /// entry of "Ventilación mecánica Invasiva" (contributing 3) are provided, summing their mapped complexity contributions. + /// + /// [Test] public async Task Map_WithIntravenousRoutesAndRespiratoryDeviceMultiValueObservation_CalculatesComplexity_Return5() { @@ -1944,6 +1972,13 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that values mapped through the calculated observations pipeline + /// produce a Complexity observation with value 4 when a newborn weight observation of 600 + /// is provided and no previous observations exist for the respiratory, intravenous, medication, system, + /// or surgery multivalue categories. + /// + /// [Test] public async Task Map_WithNewbornWeightObservation_CalculatesComplexity_Return4() { @@ -2034,6 +2069,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Tests that inserts a diff observation with the calculated difference and a combined pre/post observation when a pre-observation is provided and the matching post-observation is found through . + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WhenPreObservationExistsAndPostIsFound_InsertsDiffAndPrePost() { @@ -2082,6 +2121,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that when a post observation is processed and a matching pre observation is found, both a diff observation (with the computed difference value) and a combined pre/post observation (with the pre and post values) are inserted. + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WhenPostObservationExistsAndPreIsFound_InsertsDiffAndPrePost() { @@ -2130,6 +2173,10 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that does not insert new records when only the pre-observation is available for the patient and no matching post-observation is returned by . + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WhenOnlyPreObservationExists_DoesNotInsertNewObservations() { @@ -2161,6 +2208,12 @@ public class CalculatedObservationsTest x => x.InsertObservation(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } + /// + /// Verifies that CalculateSaturation for a diff observation does not insert new + /// entries when only the post-observation is found and the + /// pre-observation is missing, ensuring no fallback insert occurs in this scenario. + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WhenOnlyPostObservationExists_DoesNotInsertNewObservations() { @@ -2192,6 +2245,10 @@ public class CalculatedObservationsTest x => x.InsertObservation(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } + /// + /// Verifies that the saturation difference calculation correctly handles pre and post values that differ, producing a "SpO2_Diff" observation with the numeric difference (7.4) and a "SpO2_Pre_Post" observation with both values formatted as "99,5/92,1". + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WithDifferentPrePostValues_CalculatesCorrectDifference() { @@ -2240,6 +2297,14 @@ public class CalculatedObservationsTest Times.Once); } + /// + /// Verifies that when mapping a pre-observation whose is non-numeric, the + /// CalculateSaturation logic treats the pre-value as 0 when computing the difference against the latest + /// matching post-observation returned by . + /// Confirms that a SpO2_Diff observation is inserted with the value 0 - post rounded to two decimals, + /// and a SpO2_Pre_Post observation is inserted concatenating the raw pre-value and post-value. + /// + /// [Test] public async Task CalculateSaturation_DiffObservation_WithNonNumericPreValue_TreatsAsZero() { @@ -2382,6 +2447,11 @@ public class CalculatedObservationsTest x => x.InsertObservation(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } + /// + /// Verifies that mapping a whose is set yields a result with , overriding the order control that would otherwise be derived from the patient's previously active treatments. + /// + /// A that completes when the assertions have been evaluated. + /// [Test] public async Task Map_TreatmentWithEndTimeSet_OverridesOrderControlFromOldTreatments() { @@ -2406,6 +2476,10 @@ public class CalculatedObservationsTest Assert.That(result.OrderControl, Is.EqualTo(OrderControlType.Dc)); } + /// + /// Verifies that the map operation inserts an observation when the supplied carries a medication code. The test arranges a treatment with a single requested give code, configures the treatment, medicine, and observation services to return an existing active treatment list, the matching , and no previous observations; then asserts that the resulting is and that the observation service is invoked once with a whose name equals "Medication_Multivalue" and whose value is a array of length one containing the medication text. + /// + /// [Test] public async Task Map_TreatmentWithMedication_InsertObservation() { diff --git a/adas-core.Test/Models/SignalR/SubscriberGroupedTest.cs b/adas-core.Test/Models/SignalR/SubscriberGroupedTest.cs index 2af900c5..d5503044 100644 --- a/adas-core.Test/Models/SignalR/SubscriberGroupedTest.cs +++ b/adas-core.Test/Models/SignalR/SubscriberGroupedTest.cs @@ -9,6 +9,10 @@ using static adas_core.Domain.Models.GroupedObservation; namespace adas_core.Test.Models.SignalR; +/// +/// Serves as a test fixture that validates the grouped subscription behavior. +/// +/// [TestFixture] public class SubscriberGroupedTest { diff --git a/adas-core.Test/Repositories/AdmissionRepositoryTest.cs b/adas-core.Test/Repositories/AdmissionRepositoryTest.cs index 32dfcc63..519b5b1c 100644 --- a/adas-core.Test/Repositories/AdmissionRepositoryTest.cs +++ b/adas-core.Test/Repositories/AdmissionRepositoryTest.cs @@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of . +/// +/// +/// Marked with and so the test runner identifies and groups these as integration-level tests. +/// +/// [TestFixture] [Category("Integration")] public class AdmissionRepositoryTest diff --git a/adas-core.Test/Repositories/AlarmRepositoryTest.cs b/adas-core.Test/Repositories/AlarmRepositoryTest.cs index 404223c2..296a005f 100644 --- a/adas-core.Test/Repositories/AlarmRepositoryTest.cs +++ b/adas-core.Test/Repositories/AlarmRepositoryTest.cs @@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of . +/// +/// +/// Annotated with , , and to control execution ordering and group the tests under the integration category. +/// +/// [TestFixture] [Order(1)] [Category("Integration")] diff --git a/adas-core.Test/Repositories/AppointmentArchiveRepositoryTest.cs b/adas-core.Test/Repositories/AppointmentArchiveRepositoryTest.cs index 3ae1cdf3..16ae7be4 100644 --- a/adas-core.Test/Repositories/AppointmentArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/AppointmentArchiveRepositoryTest.cs @@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an NUnit integration test fixture for the type. +/// +/// +/// The Integration category groups these tests so they can be executed separately from unit tests, indicating they depend on external infrastructure beyond isolated components. +/// +/// [TestFixture] [Category("Integration")] public class AppointmentArchiveRepositoryTest diff --git a/adas-core.Test/Repositories/AppointmentRepositoryTest.cs b/adas-core.Test/Repositories/AppointmentRepositoryTest.cs index 8191e381..c06b13b1 100644 --- a/adas-core.Test/Repositories/AppointmentRepositoryTest.cs +++ b/adas-core.Test/Repositories/AppointmentRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of against a real data store. +/// +/// +/// Marked with the Integration test category, so the contained cases are excluded from fast unit-test runs and executed in the dedicated integration pipeline. +/// +/// [TestFixture] [Category("Integration")] public class AppointmentRepositoryTest diff --git a/adas-core.Test/Repositories/ConfigObservationRepositoryTest.cs b/adas-core.Test/Repositories/ConfigObservationRepositoryTest.cs index 9706928b..495f1194 100644 --- a/adas-core.Test/Repositories/ConfigObservationRepositoryTest.cs +++ b/adas-core.Test/Repositories/ConfigObservationRepositoryTest.cs @@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Provides integration tests for the . +/// +/// +/// Marked as a and grouped under the "Integration" to allow filtering of test runs. +/// +/// [TestFixture] [Category("Integration")] public class ConfigObservationRepositoryTest diff --git a/adas-core.Test/Repositories/ConfigPumpsRepositoryTest.cs b/adas-core.Test/Repositories/ConfigPumpsRepositoryTest.cs index 92df829e..51a5e1b2 100644 --- a/adas-core.Test/Repositories/ConfigPumpsRepositoryTest.cs +++ b/adas-core.Test/Repositories/ConfigPumpsRepositoryTest.cs @@ -7,6 +7,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of the ConfigPumpsRepository against real or external dependencies. +/// +/// +/// Tagged with the Integration category so these tests can be selected or excluded independently of unit tests. +/// +/// [TestFixture] [Category("Integration")] public class ConfigPumpsRepositoryTest diff --git a/adas-core.Test/Repositories/ConfigUnitsRepositoryTest.cs b/adas-core.Test/Repositories/ConfigUnitsRepositoryTest.cs index 9814b115..3c020f31 100644 --- a/adas-core.Test/Repositories/ConfigUnitsRepositoryTest.cs +++ b/adas-core.Test/Repositories/ConfigUnitsRepositoryTest.cs @@ -6,6 +6,12 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of . +/// +/// +/// Categorized as an integration test suite to group and selectively execute tests that exercise against its backing store. +/// [TestFixture] [Category("Integration")] public class ConfigUnitsRepositoryTest diff --git a/adas-core.Test/Repositories/DiagnosisArchiveRepositoryTest.cs b/adas-core.Test/Repositories/DiagnosisArchiveRepositoryTest.cs index 2c6c0f33..3f01010a 100644 --- a/adas-core.Test/Repositories/DiagnosisArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/DiagnosisArchiveRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of . +/// +/// +/// Tests in this fixture belong to the Integration category and exercise the repository against its real or staged persistence dependencies rather than pure unit-level mocks. +/// +/// [TestFixture] [Category("Integration")] public class DiagnosisArchiveRepositoryTest diff --git a/adas-core.Test/Repositories/DiagnosisRepositoryTest.cs b/adas-core.Test/Repositories/DiagnosisRepositoryTest.cs index 17819d76..f08fc640 100644 --- a/adas-core.Test/Repositories/DiagnosisRepositoryTest.cs +++ b/adas-core.Test/Repositories/DiagnosisRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Provides integration tests for the diagnosis repository. +/// +/// +/// The class is decorated with and to mark it as an integration test fixture. +/// +/// [TestFixture] [Category("Integration")] public class DiagnosisRepositoryTest diff --git a/adas-core.Test/Repositories/DischargeRepositoryTest.cs b/adas-core.Test/Repositories/DischargeRepositoryTest.cs index 721625b2..bc1b5406 100644 --- a/adas-core.Test/Repositories/DischargeRepositoryTest.cs +++ b/adas-core.Test/Repositories/DischargeRepositoryTest.cs @@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as the NUnit test fixture that contains integration tests for the . +/// +/// +/// Tests declared in this fixture are tagged with the Integration category, indicating they exercise the repository against its real infrastructure dependencies rather than mocked ones. +/// +/// [TestFixture] [Category("Integration")] public class DischargeRepositoryTest diff --git a/adas-core.Test/Repositories/DisplayConfigTest.cs b/adas-core.Test/Repositories/DisplayConfigTest.cs index 6633657f..bf28c99e 100644 --- a/adas-core.Test/Repositories/DisplayConfigTest.cs +++ b/adas-core.Test/Repositories/DisplayConfigTest.cs @@ -10,6 +10,13 @@ using Moq; namespace adas_core.Test.Repositories; +/// +/// Test fixture that groups unit tests validating the behavior of . +/// +/// +/// Decorated with the so that its contained test methods are recognized and executed by the NUnit test runner. +/// +/// [TestFixture] public class DisplayConfigTest { diff --git a/adas-core.Test/Repositories/DisplayRepisitoryTest.cs b/adas-core.Test/Repositories/DisplayRepisitoryTest.cs index fc0baca1..f923d812 100644 --- a/adas-core.Test/Repositories/DisplayRepisitoryTest.cs +++ b/adas-core.Test/Repositories/DisplayRepisitoryTest.cs @@ -1,5 +1,10 @@ namespace adas_core.Test.Repositories; +/// +/// Provides a test fixture for the display repository, containing test methods to verify its behavior. +/// Marked with to be recognized as an NUnit test fixture. +/// +/// [TestFixture] public class DisplayRepisitoryTest { diff --git a/adas-core.Test/Repositories/HistoricalConfigChangesRepositoryTest.cs b/adas-core.Test/Repositories/HistoricalConfigChangesRepositoryTest.cs index 590e515e..12e2a883 100644 --- a/adas-core.Test/Repositories/HistoricalConfigChangesRepositoryTest.cs +++ b/adas-core.Test/Repositories/HistoricalConfigChangesRepositoryTest.cs @@ -11,6 +11,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Test fixture that exercises the through integration-level scenarios. +/// +/// +/// Tests in this fixture are categorized as integration tests. +/// +/// [TestFixture] [Category("Integration")] public class HistoricalConfigChangesRepositoryTest diff --git a/adas-core.Test/Repositories/IntegrationDb.cs b/adas-core.Test/Repositories/IntegrationDb.cs index e53f6e02..1b89ab8a 100644 --- a/adas-core.Test/Repositories/IntegrationDb.cs +++ b/adas-core.Test/Repositories/IntegrationDb.cs @@ -5,6 +5,13 @@ using MongoDB.Driver; namespace adas_core.Test.Repositories; +/// +/// Provides one-time setup and teardown for database-backed integration tests within the containing namespace or assembly. +/// +/// +/// Decorated with the attribute so its initialization and cleanup members run a single time per scope, and classified under the "Integration" . +/// +/// [SetUpFixture] [Category("Integration")] public class IntegrationDb diff --git a/adas-core.Test/Repositories/MasterListRepositoryTest.cs b/adas-core.Test/Repositories/MasterListRepositoryTest.cs index 4a6c1b49..9e3eeccd 100644 --- a/adas-core.Test/Repositories/MasterListRepositoryTest.cs +++ b/adas-core.Test/Repositories/MasterListRepositoryTest.cs @@ -7,6 +7,10 @@ using MongoDB.Bson; namespace adas_core.Test.Repositories; +/// +/// Contains unit tests that exercise the behavior of the class. +/// +/// [TestFixture] public class MasterListRepositoryTest { @@ -154,6 +158,10 @@ public class MasterListRepositoryTest Assert.That(result?.Name, Is.EqualTo("FindById MasterList")); } + /// + /// Verifies that the repository's FindById method returns the matching with locale-specific option names for each value, falling back to the DefaultLocale when the requested locale has no translations (e.g., falls back to ), and that is not populated on the returned options. + /// + /// [Test] public async Task FindById_WithDifferentLocale_ShouldReturnEntity_WhenFound() { @@ -209,6 +217,11 @@ public class MasterListRepositoryTest Assert.That(resultEs?.Options[0].LocaleItems, Is.Null); } + /// + /// Verifies that returns the persisted entity for every requested value, falling back to content when no locale-specific translations exist. + /// Confirms the lookup succeeds for , , , , and , returning the default-locale values in each case. + /// + /// [Test] public async Task FindById_WithDifferentLocale_ShouldReturnEntity_WhenFound_AndDefaultLocale() { @@ -284,6 +297,11 @@ public class MasterListRepositoryTest Assert.That(result.Count(), Is.GreaterThanOrEqualTo(2)); } + /// + /// Tests that GetMasterListByIdAndSearchOptions correctly retrieves a by its identifier and filters its associated entries by locale-specific criteria. + /// Validates the search behavior across multiple supported locales (, , and ), covering both Text-based and Description-based filters provided through , and asserts that the returned option matches the expected localized name for each scenario. + /// + /// [Test] public async Task GetMasterListByIdAndSearchOptiionsByLocale() { @@ -323,6 +341,10 @@ public class MasterListRepositoryTest Assert.That(resultEs[0].Name, Is.EqualTo("Opción 1")); } + /// + /// Verifies that updating a option through for a specific value replaces only the localized entry while preserving the default-locale option data. + /// + /// [Test] public async Task UpdateMasterListOptionByLocale() { @@ -365,6 +387,10 @@ public class MasterListRepositoryTest // _pointOfCareRepositoryMock.Verify(m => m.FindById(patientLocationId), Times.Once); } + /// + /// Tests that . returns the option item matching the supplied master list id, option id and locale, retrieving the localized name from the entries (e.g. Portuguese) rather than the . + /// + /// [Test] public async Task FindOptionItemByLocaleAndId() { diff --git a/adas-core.Test/Repositories/MedicineRepositoryTest.cs b/adas-core.Test/Repositories/MedicineRepositoryTest.cs index a2dc0b7c..72984756 100644 --- a/adas-core.Test/Repositories/MedicineRepositoryTest.cs +++ b/adas-core.Test/Repositories/MedicineRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of the medicine repository. +/// +/// +/// Categorized as Integration to enable selective execution of the contained tests apart from unit-level suites. +/// +/// [TestFixture] [Category("Integration")] public class MedicineRepositoryTest @@ -64,6 +71,10 @@ public class MedicineRepositoryTest Assert.That(result, Is.Empty); } + /// + /// Verifies that correctly retrieves a matching when both codes and notes are provided as search criteria, confirming that Paracetamol is returned when its code "605677" appears among the inputs. + /// + /// [Test] public async Task Get_Medicines_Of_Treatments_By_Code_When_Have_Code_And_Notes_Return_Paracetamol() { diff --git a/adas-core.Test/Repositories/MongodbMigrationTest.cs b/adas-core.Test/Repositories/MongodbMigrationTest.cs index f1c37087..e8a6de70 100644 --- a/adas-core.Test/Repositories/MongodbMigrationTest.cs +++ b/adas-core.Test/Repositories/MongodbMigrationTest.cs @@ -12,6 +12,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies MongoDB migration behavior. +/// +/// +/// Marked with and using the "Integration" category to group it with other integration-level tests. +/// +/// [TestFixture] [Category("Integration")] public class MongodbMigrationTest @@ -131,6 +138,10 @@ public class MongodbMigrationTest Assert.That(ids, Does.Contain(10)); // 0.1.0 } + /// + /// Verifies that running migrations twice via the runner is idempotent and does not fail, and that the migration identified by id 10 remains present in the applied set returned by GetAppliedMigrationIds after the second UpdateToLatest execution. + /// + /// [Test] public void RunningMigrationsTwice_ShouldNotFail() { diff --git a/adas-core.Test/Repositories/ObservationArchiveRepositoryTest.cs b/adas-core.Test/Repositories/ObservationArchiveRepositoryTest.cs index 6b397d21..ca311d76 100644 --- a/adas-core.Test/Repositories/ObservationArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/ObservationArchiveRepositoryTest.cs @@ -9,10 +9,21 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an integration test fixture that exercises the behavior of against a real backing store. +/// +/// +/// Marked with set to "Integration", indicating that the tests in this class require external dependencies and are grouped accordingly. +/// +/// [TestFixture] [Category("Integration")] public class ObservationArchiveRepositoryTest { + /// + /// One-time setup that resets the archive_patients_observations collection in the integration database and seeds it with two records (a current "Sin alergias conocidas" entry and a prior "¿Alergia al látex?" entry), both coded with the SNM system and marked as , so that integration tests start from a known baseline state. + /// + /// [OneTimeSetUp] public async Task Init() { diff --git a/adas-core.Test/Repositories/ObservationRepositoryTest.cs b/adas-core.Test/Repositories/ObservationRepositoryTest.cs index 7e728195..cc0732fe 100644 --- a/adas-core.Test/Repositories/ObservationRepositoryTest.cs +++ b/adas-core.Test/Repositories/ObservationRepositoryTest.cs @@ -15,6 +15,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of the class against a real backing store. +/// +/// +/// Marked with set to "Integration" and set to 1 so the suite runs first among the integration tests. +/// +/// [TestFixture] [Order(1)] [Category("Integration")] @@ -1940,6 +1947,10 @@ public class ObservationRepositoryTest Assert.That(resultClear.ToList(), Has.Count.EqualTo(0)); } + /// + /// Verifies that returns the expected aggregated list when grouping observations by and using with set to and a maximum of 8 entries, inserting 30 observations and asserting the returned count is either 7 or 8 to account for possible cross-test interference. + /// + /// [Test] public async Task AggregatedPatientGroupedObservations_Times_Firs_Return_List_8() { diff --git a/adas-core.Test/Repositories/PatientArchiveRepositoryTest.cs b/adas-core.Test/Repositories/PatientArchiveRepositoryTest.cs index b0844d30..80c0ba55 100644 --- a/adas-core.Test/Repositories/PatientArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/PatientArchiveRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that verifies the behavior of . +/// +/// +/// Decorated with the NUnit attribute and tagged with the Integration category, this class groups the test cases that exercise the repository end-to-end. +/// +/// [TestFixture] [Category("Integration")] public class PatientArchiveRepositoryTest diff --git a/adas-core.Test/Repositories/PatientRepositoryTest.cs b/adas-core.Test/Repositories/PatientRepositoryTest.cs index ce72efed..082d983b 100644 --- a/adas-core.Test/Repositories/PatientRepositoryTest.cs +++ b/adas-core.Test/Repositories/PatientRepositoryTest.cs @@ -11,6 +11,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an NUnit test fixture containing integration tests for the PatientRepository. +/// +/// +/// Marked with the TestFixture attribute and grouped under the Integration test category. +/// +/// [TestFixture] [Category("Integration")] public class PatientRepositoryTest diff --git a/adas-core.Test/Repositories/PoCMappingRepositoryTest.cs b/adas-core.Test/Repositories/PoCMappingRepositoryTest.cs index b25074d0..4d985045 100644 --- a/adas-core.Test/Repositories/PoCMappingRepositoryTest.cs +++ b/adas-core.Test/Repositories/PoCMappingRepositoryTest.cs @@ -6,6 +6,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that exercises the . +/// +/// +/// Categorized as "Integration", the tests in this fixture validate the repository against an actual or near-real data source rather than purely mocked dependencies. +/// +/// [TestFixture] [Category("Integration")] public class PoCMappingRepositoryTest diff --git a/adas-core.Test/Repositories/PoCSettingsRepositoryTest.cs b/adas-core.Test/Repositories/PoCSettingsRepositoryTest.cs index e172359f..78ab9277 100644 --- a/adas-core.Test/Repositories/PoCSettingsRepositoryTest.cs +++ b/adas-core.Test/Repositories/PoCSettingsRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Test fixture that verifies the behavior of . +/// +/// +/// Marked with so the NUnit test runner discovers and executes its contained test methods. +/// +/// [TestFixture] public class PoCSettingsRepositoryTest { diff --git a/adas-core.Test/Repositories/PointOfCareRepositoryTests.cs b/adas-core.Test/Repositories/PointOfCareRepositoryTests.cs index cb86d151..916842fb 100644 --- a/adas-core.Test/Repositories/PointOfCareRepositoryTests.cs +++ b/adas-core.Test/Repositories/PointOfCareRepositoryTests.cs @@ -10,6 +10,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as the NUnit for integration tests of the . +/// +/// +/// Tests in this class are tagged with the Integration category via the . +/// +/// [TestFixture] [Category("Integration")] public class PointOfCareRepositoryTests diff --git a/adas-core.Test/Repositories/PumpAlarmEventRepositoryTest.cs b/adas-core.Test/Repositories/PumpAlarmEventRepositoryTest.cs index f510c290..71512b3b 100644 --- a/adas-core.Test/Repositories/PumpAlarmEventRepositoryTest.cs +++ b/adas-core.Test/Repositories/PumpAlarmEventRepositoryTest.cs @@ -8,6 +8,13 @@ using MongoDB.Driver; namespace adas_core.Test.Repositories; +/// +/// Provides integration tests for the . +/// +/// +/// Marked with the Integration category to allow it to be included or excluded as a group during test execution. +/// +/// [TestFixture] [Category("Integration")] public class PumpAlarmEventRepositoryTest @@ -161,6 +168,10 @@ public class PumpAlarmEventRepositoryTest // ------------------------------------------------------------------- // FIND LAST BY DEVICE // ------------------------------------------------------------------- + /// + /// Verifies that the repository's FindLastByDeviceIdAsync method returns the most recent event for the specified device by comparing it against the event with the latest Time retrieved via FindByDeviceIdAsync. + /// + /// [Test] public async Task FindLastByDeviceIdAsync_Works() { diff --git a/adas-core.Test/Repositories/PumpAlarmStateRepositoryTest.cs b/adas-core.Test/Repositories/PumpAlarmStateRepositoryTest.cs index 23e1aee3..31d2d700 100644 --- a/adas-core.Test/Repositories/PumpAlarmStateRepositoryTest.cs +++ b/adas-core.Test/Repositories/PumpAlarmStateRepositoryTest.cs @@ -8,6 +8,13 @@ using MongoDB.Driver; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of . +/// +/// +/// All tests in this fixture belong to the Integration category and are expected to depend on external infrastructure. +/// +/// [TestFixture] [Category("Integration")] public class PumpAlarmStateRepositoryTest @@ -141,6 +148,10 @@ public class PumpAlarmStateRepositoryTest Assert.That(found, Is.Not.Null); } + /// + /// Verifies that the upsert operation updates an existing active record instead of inserting a duplicate, replacing the previous timestamp while ignoring the supplied . + /// + /// [Test] public async Task UpsertActiveAsync_UpdatesExisting() { @@ -273,6 +284,10 @@ public class PumpAlarmStateRepositoryTest } } + /// + /// Verifies that invoking the upsert operation twice with the same keeps the active alarm set unique per device, confirming the operation is idempotent and does not insert duplicate records. + /// + /// [Test] public async Task UpsertActiveAsync_NoDuplicateOnRepeatedCalls() { diff --git a/adas-core.Test/Repositories/PumpArchiveRepositoryTest.cs b/adas-core.Test/Repositories/PumpArchiveRepositoryTest.cs index f51d2047..13b3c0b1 100644 --- a/adas-core.Test/Repositories/PumpArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/PumpArchiveRepositoryTest.cs @@ -9,10 +9,24 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of the PumpArchiveRepository against its real dependencies rather than mocked collaborators. +/// +/// +/// Categorized as Integration so it can be filtered separately from unit tests during test execution. +/// +/// [TestFixture] [Category("Integration")] public class PumpArchiveRepositoryTest { + /// + /// Performs one-time initialization for the test fixture by seeding two + /// records into the archive collection: one with the current timestamp and another with a timestamp + /// ten days in the past, enabling tests of the archive behavior + /// across different observation times. + /// + /// [OneTimeSetUp] public async Task Init() { diff --git a/adas-core.Test/Repositories/PumpObservationRepositoryTest.cs b/adas-core.Test/Repositories/PumpObservationRepositoryTest.cs index 6a897796..b7541b7f 100644 --- a/adas-core.Test/Repositories/PumpObservationRepositoryTest.cs +++ b/adas-core.Test/Repositories/PumpObservationRepositoryTest.cs @@ -8,6 +8,13 @@ using MongoDB.Driver; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture for the . +/// +/// +/// Marked with the Integration category, so these tests target interactions with external dependencies rather than isolated unit logic. +/// +/// [TestFixture] [Category("Integration")] public class PumpObservationRepositoryTest @@ -21,6 +28,13 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // INIT – SETUP DE LA COLECCIÓN CON DATOS DE PRUEBA // ------------------------------------------------------------------- + /// + /// One-time setup that prepares the integration test environment for the by clearing the + /// pump_observations collection, recreating it, building the indexes, and seeding it with three sample + /// records belonging to . The setup then asserts that exactly three documents were + /// inserted into the collection. + /// + /// [OneTimeSetUp] public async Task Init() { @@ -79,6 +93,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // FIND LAST OBSERVATIONS (LÍMITE = 2) // ------------------------------------------------------------------- + /// + /// Verifies that the repository returns exactly two observations for the specified patient and "PumpX", and that the returned list is ordered with the first observation's time greater than or equal to the second observation's time. + /// + /// [Test] public async Task FindLastObservations_ReturnsTwo() { @@ -92,6 +110,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // INSERT // ------------------------------------------------------------------- + /// + /// Verifies that persists a new so that a subsequent lookup by returns the stored entity. + /// + /// [Test] public async Task InsertAsync_Works() { @@ -109,6 +131,10 @@ public class PumpObservationRepositoryTest Assert.That(found.FirstOrDefault(), Is.Not.Null); } + /// + /// Verifies that the repository successfully inserts a batch of documents and that all items can be retrieved by their identifiers from the underlying collection. + /// + /// [Test] public async Task InsertManyAsync_Works() { @@ -127,6 +153,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // FIND METHODS // ------------------------------------------------------------------- + /// + /// Verifies that the FindByDeviceIdAsync repository method returns a non-empty collection of pump observations for the specified device, ordered by time in descending order with the most recent observation first. + /// + /// [Test] public async Task FindByDeviceIdAsync_ReturnsOrdered() { @@ -140,6 +170,10 @@ public class PumpObservationRepositoryTest } } + /// + /// Verifies that the repository's FindByPatientAsync call returns a non-empty collection of observations for the configured PatientId, ordered by time in descending order so that the most recent observation appears first. + /// + /// [Test] public async Task FindByPatientAsync_ReturnsOrdered() { @@ -153,6 +187,10 @@ public class PumpObservationRepositoryTest } } + /// + /// Verifies that returns a non-null observation whose matches the device identifier passed in. + /// + /// [Test] public async Task FindLastByDeviceIdAsync_Works() { @@ -162,6 +200,10 @@ public class PumpObservationRepositoryTest Assert.That(obs.DeviceId, Is.EqualTo("Device-A")); } + /// + /// Verifies that the repository lookup by patient identifier returns a non-empty collection of results. + /// + /// [Test] public async Task FindByPatientId_Works() { @@ -173,6 +215,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // AGGREGATED LAST OBSERVATIONS // ------------------------------------------------------------------- + /// + /// Verifies that the aggregated last observations retrieved for the test PatientId are distinct by name, ensuring the resulting collection is non-empty and contains at most two entries. + /// + /// [Test] public async Task AggregatedPatientLastObservations_DistinctByName() { @@ -188,6 +234,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // DELETE METHODS // ------------------------------------------------------------------- + /// + /// Verifies that records associated with a given patient can be removed via DeleteByPatientId, ensuring no matching observations remain in the repository after deletion. + /// + /// [Test] public async Task DeleteByPatientId_Works() { @@ -207,6 +257,10 @@ public class PumpObservationRepositoryTest Assert.That(list.Any(), Is.False); } + /// + /// Tests that DeleteOlderThanDaysAsync successfully deletes pump observations older than the given number of days, asserting that the returned count is at least one when matching data exists. + /// + /// [Test] public async Task DeleteOlderThanDaysAsync_Works() { @@ -225,6 +279,11 @@ public class PumpObservationRepositoryTest Assert.That(deleted, Is.GreaterThanOrEqualTo(1)); } + /// + /// Verifies that the older-observation pruning operation retains only the requested number of newest entries for the given name and returns the count of deleted items. + /// Inserts five timed observations and asserts that exactly three older entries are removed when two are kept. + /// + /// [Test] public async Task DeleteOlderNumberAsync_Works() { @@ -246,6 +305,10 @@ public class PumpObservationRepositoryTest Assert.That(deleted, Is.EqualTo(3)); } + /// + /// Verifies that correctly deletes the older records while preserving the most recent entries, returning the expected count of deleted items. + /// + /// [Test] public async Task DeleteKeepLastNAsync_Works() { @@ -267,6 +330,10 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // UPDATE METHOD // ------------------------------------------------------------------- + /// + /// Verifies that correctly updates the field of all matching records, replacing the old value with a new one, and reports the number of documents modified. + /// + /// [Test] public async Task UpdateManyObjectIdByFieldAsync_Works() { @@ -292,6 +359,12 @@ public class PumpObservationRepositoryTest // ------------------------------------------------------------------- // AGGREGATION: LAST OBSERVATION TIME PER PATIENT // ------------------------------------------------------------------- + /// + /// Verifies that the repository returns a non-null dictionary containing the last patient observation + /// time for the specified patient, and that the recorded timestamp is not in the future relative to + /// . + /// + /// [Test] public async Task FindAllLastPatientObservationTimeAsync_Works() { @@ -305,6 +378,10 @@ public class PumpObservationRepositoryTest } } + /// + /// Verifies that looking up records by device ID with a date range entirely outside the stored data window returns an empty collection. + /// + /// [Test] public async Task FindByDeviceIdAsync_EmptyWhenOutOfDateRange() { @@ -316,6 +393,10 @@ public class PumpObservationRepositoryTest Assert.That(result, Is.Empty); } + /// + /// Verifies that the repository's FindByPatientAsync method respects the limit parameter when retrieving records for a patient, asserting that the returned collection contains exactly one item when the limit is set to one. + /// + /// [Test] public async Task FindByPatientAsync_RespectsLimit() { @@ -324,6 +405,10 @@ public class PumpObservationRepositoryTest Assert.That(list, Has.Count.EqualTo(1)); } + /// + /// Verifies that FindLastByDeviceIdAsync returns null when no observation exists for the supplied device identifier. + /// + /// [Test] public async Task FindLastByDeviceIdAsync_ReturnsNullWhenNotExists() { @@ -332,6 +417,10 @@ public class PumpObservationRepositoryTest Assert.That(obs, Is.Null); } + /// + /// Verifies that InsertManyAsync completes without throwing when invoked with an empty collection of . + /// + /// [Test] public async Task InsertManyAsync_IgnoresEmptyList() { @@ -343,6 +432,10 @@ public class PumpObservationRepositoryTest } + /// + /// Verifies that DeleteOlderNumberAsync leaves the stored data unchanged and returns zero when the total number of entries for the given device name is below the specified maxCount threshold. + /// + /// [Test] public async Task DeleteOlderNumberAsync_DoesNothingWhenCountBelowLimit() { @@ -363,6 +456,10 @@ public class PumpObservationRepositoryTest Assert.That(deleted, Is.Zero); } + /// + /// Verifies that the repository cleanup operation preserves recent observations by inserting a whose timestamp is one minute in the past and asserting that the deletion count returned by DeleteOlderThanDaysAsync is zero. + /// + /// [Test] public async Task DeleteOlderThanDaysAsync_DoesNotDeleteRecentObservations() { @@ -382,6 +479,10 @@ public class PumpObservationRepositoryTest Assert.That(deleted, Is.Zero); } + /// + /// Verifies that deduplicates entries that share the same and for a given patient, returning only a single entry per code/name combination. + /// + /// [Test] public async Task AggregatedPatientLastObservations_RemovesDuplicatesByCodeAndName() { diff --git a/adas-core.Test/Repositories/PumpStateRepositoryTest.cs b/adas-core.Test/Repositories/PumpStateRepositoryTest.cs index 81d8729a..6de21fb2 100644 --- a/adas-core.Test/Repositories/PumpStateRepositoryTest.cs +++ b/adas-core.Test/Repositories/PumpStateRepositoryTest.cs @@ -8,6 +8,13 @@ using adas_core.Domain.Enums; namespace adas_core.Test.Repositories; +/// +/// Serves as an integration test fixture that verifies the behavior of . +/// +/// +/// Marked with set to "Integration", the tests in this class exercise against its real dependencies rather than mocked collaborators. +/// +/// [TestFixture] [Category("Integration")] public class PumpStateRepositoryTest diff --git a/adas-core.Test/Repositories/RecordingAlertArchiveRepositoryTest.cs b/adas-core.Test/Repositories/RecordingAlertArchiveRepositoryTest.cs index abf829cc..27647c33 100644 --- a/adas-core.Test/Repositories/RecordingAlertArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/RecordingAlertArchiveRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Provides an integration test fixture that exercises the RecordingAlertArchiveRepository to verify its expected behavior. +/// +/// +/// Categorized as "Integration" so it can be grouped with other integration tests during test execution. +/// +/// [TestFixture] [Category("Integration")] public class RecordingAlertArchiveRepositoryTest diff --git a/adas-core.Test/Repositories/RecordingAlertRepositoryTest.cs b/adas-core.Test/Repositories/RecordingAlertRepositoryTest.cs index 6f0abb18..993d3775 100644 --- a/adas-core.Test/Repositories/RecordingAlertRepositoryTest.cs +++ b/adas-core.Test/Repositories/RecordingAlertRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of the RecordingAlertRepository class. +/// +/// +/// Categorized as "Integration" to group it with other integration-level test fixtures. +/// +/// [TestFixture] [Category("Integration")] public class RecordingAlertRepositoryTest diff --git a/adas-core.Test/Repositories/SectionRepositoryTest.cs b/adas-core.Test/Repositories/SectionRepositoryTest.cs index 6c180a7b..722a3c2c 100644 --- a/adas-core.Test/Repositories/SectionRepositoryTest.cs +++ b/adas-core.Test/Repositories/SectionRepositoryTest.cs @@ -11,10 +11,23 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an integration test fixture for the SectionRepository type. +/// +/// +/// Categorized as "Integration" via to group related test execution. +/// +/// [TestFixture] [Category("Integration")] public class SectionRepositoryTest { + /// + /// Initializes the integration test fixture by seeding two entities + /// (UCIP1 and UCIP2) with their associated data into the + /// config_sections MongoDB collection through . + /// + /// [OneTimeSetUp] public async Task Init() { @@ -83,6 +96,10 @@ public class SectionRepositoryTest private static readonly ObjectId SectionId1 = ObjectId.GenerateNewId(); private static readonly ObjectId SectionId2 = ObjectId.GenerateNewId(); + /// + /// Verifies that . returns a non-null collection containing the expected number of Sections. + /// + /// [Test] public async Task GetAll_Return_List_Sections() { @@ -92,6 +109,10 @@ public class SectionRepositoryTest Assert.That(result, Has.Count.EqualTo(2)); } + /// + /// Verifies that the repository's FindBySection method returns when invoked with an empty section name, covering the not-found case for empty input. + /// + /// [Test] public async Task FindBySection_Not_Find_Return_null() { @@ -100,6 +121,10 @@ public class SectionRepositoryTest Assert.That(result, Is.Null); } + /// + /// Verifies that FindBySection returns a matching section record when queried by the title "UCI PEDIÁTRICA 2", ensuring the result is not and the returned SectionTitle equals the queried value. + /// + /// [Test] public async Task FindBySection_Find_Return_Section() { @@ -109,6 +134,10 @@ public class SectionRepositoryTest Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 2")); } + /// + /// Verifies that the repository's FindByPointOfCare method returns null when invoked with an empty point of care value that does not match any existing record. + /// + /// [Test] public async Task FindByPointOfCare_Not_Find_Return_null() { @@ -117,6 +146,10 @@ public class SectionRepositoryTest Assert.That(result, Is.Null); } + /// + /// Verifies that the repository's FindByPointOfCare method successfully retrieves a non-null section for the point of care identifier "UCIP1" and confirms that the returned section's SectionTitle equals "UCI PEDIÁTRICA 1". + /// + /// [Test] public async Task FindByPointOfCare_Find_Return_Section() { @@ -126,6 +159,10 @@ public class SectionRepositoryTest Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 1")); } + /// + /// Verifies that returns when the requested entity cannot be located, using an empty identifier to simulate the not-found scenario. + /// + /// [Test] public async Task FindById_Not_Find_Return_null() { @@ -134,6 +171,11 @@ public class SectionRepositoryTest Assert.That(result, Is.Null); } + /// + /// Verifies that the repository's FindById method successfully retrieves a Section by its identifier, ensuring the returned object is not null and its SectionTitle matches the expected value. + /// Tests the lookup of the section with identifier "UCIP1" and asserts the returned title is "UCI PEDIÁTRICA 1". + /// + /// [Test] public async Task FindById_Find_Return_Section() { @@ -143,6 +185,10 @@ public class SectionRepositoryTest Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 1")); } + /// + /// Verifies that invoking the repository's FindById with a freshly generated that does not correspond to any stored entity returns . + /// + /// [Test] public async Task FindById_Not_Find_Id_Return_null() { @@ -151,6 +197,10 @@ public class SectionRepositoryTest Assert.That(result, Is.Null); } + /// + /// Verifies that the repository's FindById method successfully retrieves the section identified by SectionId2, confirming the returned section is not null and its SectionTitle equals "UCI PEDIÁTRICA 2". + /// + /// [Test] public async Task FindById_Find_Id_Return_Section() { @@ -160,6 +210,10 @@ public class SectionRepositoryTest Assert.That(result!.SectionTitle, Is.EqualTo("UCI PEDIÁTRICA 2")); } + /// + /// Verifies that the FindByLocation method returns a non-null empty list when no patient records match the specified PatientLocation. + /// + /// [Test] public async Task FindByLocation_Not_Find_Return_Emty_List() { @@ -170,6 +224,10 @@ public class SectionRepositoryTest Assert.That(result, Is.Empty); } + /// + /// Tests that the repository's FindByLocation method returns a list with exactly one result for the specified , and that the returned record contains the expected section title. + /// + /// [Test] public async Task FindByLocation_Find_Return_List() { @@ -182,6 +240,10 @@ public class SectionRepositoryTest } + /// + /// Tests the insert, update, and delete lifecycle of a entity through the repository, verifying that a section can be inserted, retrieved by its identifier, updated with new content, and subsequently deleted. + /// + /// [Test] public async Task InsertUpdateAndDeleteSection() { diff --git a/adas-core.Test/Repositories/ServiceConfigRepositoryTest.cs b/adas-core.Test/Repositories/ServiceConfigRepositoryTest.cs index 3e9316f3..a7d3815d 100644 --- a/adas-core.Test/Repositories/ServiceConfigRepositoryTest.cs +++ b/adas-core.Test/Repositories/ServiceConfigRepositoryTest.cs @@ -7,6 +7,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture for verifying the behavior of . +/// +/// +/// Categorized as an integration test to group it with other integration-level tests. +/// +/// [TestFixture] [Category("Integration")] public class ServiceConfigRepositoryTest diff --git a/adas-core.Test/Repositories/TreatmentArchiveRepositoryTest.cs b/adas-core.Test/Repositories/TreatmentArchiveRepositoryTest.cs index 3b3f73b2..6c175659 100644 --- a/adas-core.Test/Repositories/TreatmentArchiveRepositoryTest.cs +++ b/adas-core.Test/Repositories/TreatmentArchiveRepositoryTest.cs @@ -9,6 +9,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Acts as the integration test fixture for , containing tests that verify its behavior against real or test-managed external dependencies. +/// +/// +/// The class is annotated with the Integration Category attribute, which groups its tests for selective execution and reporting distinct from unit tests. +/// +/// [TestFixture] [Category("Integration")] public class TreatmentArchiveRepositoryTest diff --git a/adas-core.Test/Repositories/TreatmentRepositoryTest.cs b/adas-core.Test/Repositories/TreatmentRepositoryTest.cs index c2aa0aac..487fbd0a 100644 --- a/adas-core.Test/Repositories/TreatmentRepositoryTest.cs +++ b/adas-core.Test/Repositories/TreatmentRepositoryTest.cs @@ -9,6 +9,14 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an integration test fixture that validates the behavior of the . +/// +/// +/// Tests in this class are categorized as integration tests via the and require +/// the underlying data access infrastructure to be available at runtime. +/// +/// [TestFixture] [Category("Integration")] public class TreatmentRepositoryTest diff --git a/adas-core.Test/Repositories/UnitRepositoryTest.cs b/adas-core.Test/Repositories/UnitRepositoryTest.cs index 299f9693..3e6fae81 100644 --- a/adas-core.Test/Repositories/UnitRepositoryTest.cs +++ b/adas-core.Test/Repositories/UnitRepositoryTest.cs @@ -8,6 +8,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Integration test fixture that validates the behavior of the unit repository. +/// +/// +/// Tagged with the Integration category to group it with other integration-level tests in the test suite. +/// +/// [TestFixture] [Category("Integration")] public class UnitRepositoryTest diff --git a/adas-core.Test/Repositories/UserRepositoryTest.cs b/adas-core.Test/Repositories/UserRepositoryTest.cs index a6c27034..bc704f8c 100644 --- a/adas-core.Test/Repositories/UserRepositoryTest.cs +++ b/adas-core.Test/Repositories/UserRepositoryTest.cs @@ -7,6 +7,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Repositories; +/// +/// Serves as an integration test fixture for , exercising repository behavior against the real data store. +/// +/// [TestFixture] [Category("Integration")] public class UserRepositoryTest diff --git a/adas-core.Test/Services/AdmissionServiceTest.cs b/adas-core.Test/Services/AdmissionServiceTest.cs index 54d25247..667cd4aa 100644 --- a/adas-core.Test/Services/AdmissionServiceTest.cs +++ b/adas-core.Test/Services/AdmissionServiceTest.cs @@ -38,6 +38,10 @@ public class AdmissionServiceTest private Mock _subscribersServiceMock; private Mock _unitServiceMock; + /// + /// Initializes mocked dependencies and constructs an instance for use in unit tests, configuring a mock with an authenticated test user. + /// + /// [SetUp] public void Setup() { diff --git a/adas-core.Test/Services/AlarmServiceTest.cs b/adas-core.Test/Services/AlarmServiceTest.cs index b65a833c..1b8f9262 100644 --- a/adas-core.Test/Services/AlarmServiceTest.cs +++ b/adas-core.Test/Services/AlarmServiceTest.cs @@ -44,6 +44,10 @@ public class AlarmServiceTest private readonly RecordingSettings _recordingSettings = new(); private readonly Mock _unitServiceMock; + /// + /// Initializes a test fixture that exercises . The fixture configures mocked collaborators (such as , , , and ) and constructs an instance with the background timer disabled for testing. + /// + /// public AlarmServiceTest() { var optionsApiSettings = Options.Create(_apiSettings); diff --git a/adas-core.Test/Services/CacheDispatcherTest.cs b/adas-core.Test/Services/CacheDispatcherTest.cs index fc610ec2..1c99757c 100644 --- a/adas-core.Test/Services/CacheDispatcherTest.cs +++ b/adas-core.Test/Services/CacheDispatcherTest.cs @@ -42,6 +42,10 @@ public class FakeLockProvider : ILockProvider /// public class FakeLockManagerService : LockManagerService { + /// + /// Initializes a new instance of , a test fake of , by forwarding a mocked and a to the base constructor. + /// + /// public FakeLockManagerService() : base( Mock.Of>(), new FakeLockProvider()) @@ -61,6 +65,10 @@ public class FakeRedisService : RedisService, ICacheService public bool WasCalled { get; private set; } public string? LastKey { get; private set; } + /// + /// Initializes a new instance of , a test double for , supplying default , a mocked , and a to the base constructor. + /// + /// public FakeRedisService() : base( Options.Create(new CacheSettings()), Mock.Of>(), @@ -123,10 +131,23 @@ public class FakeCacheService : CacheService, ICacheService public bool WasCalled { get; private set; } public string? LastKey { get; private set; } + /// + /// Initializes a new instance of the test double, supplying a newly created to the base cache service as its lock-management dependency. + /// + /// public FakeCacheService() : base(new FakeLockManagerService()) { } + /// + /// Stub implementation of that records the invocation and the supplied key without performing any caching, and returns the value produced by . + /// + /// The cache key under which the value would be stored; recorded for later verification. + /// The invoked to produce the value returned by this method. + /// Optional time-to-live for the cache entry; ignored by this implementation. + /// Token to cancel the operation; ignored by this implementation. + /// The produced by invoking . + /// Task ICacheService.GetOrSetObjectAsync( string key, Func> factory, @@ -138,6 +159,17 @@ public class FakeCacheService : CacheService, ICacheService return factory(); } + /// + /// Retrieves an object from the cache for the given and , or produces it via when no cached entry exists. This implementation unconditionally invokes and records the call by setting to true, ignoring any cached value and the . + /// + /// The type of the object being retrieved or created. + /// The grouped field used as part of the cache lookup key. + /// The patient identifier used as part of the cache lookup key. + /// The asynchronous factory invoked to produce the value when no cached entry is available. + /// An optional time-to-live for the cached entry. Not used by this implementation. + /// A to cancel the operation. + /// A that resolves to the value returned by . + /// Task ICacheService.GetOrSetObjectAsync( GroupedField groupedField, ObjectId patientId, @@ -186,6 +218,10 @@ public class FakeNoCacheService : NoCacheService, ICacheService } +/// +/// Represents a test fixture that exercises the to validate its expected runtime behavior. +/// +/// [TestFixture] public class CacheDispatcherTest { @@ -216,6 +252,10 @@ public class CacheDispatcherTest #region TC-23 + /// + /// Verifies that GetOrSetObjectAsync uses the Redis service when the patients cache mode is configured as , and does not fall back to the memory or no-op cache services. + /// + /// [Test] public async Task GetOrSetObjectAsync_UsesRedisService_WhenPatientsModeIsRedis() { @@ -238,6 +278,10 @@ public class CacheDispatcherTest #endregion #region TC-24 + /// + /// Verifies that delegates to the in-memory cache service when is set to , forwarding the supplied key and ensuring that neither the Redis nor the no-op cache implementations are invoked in this scenario. + /// + /// [Test] public async Task GetOrSetObjectAsync_UsesCacheService_WhenAppointmentsModeIsCache() { @@ -260,6 +304,10 @@ public class CacheDispatcherTest #endregion #region TC-25 + /// + /// Verifies that delegates to the no-op cache service and skips both the Redis and in-memory cache services when is configured with . + /// + /// [Test] public async Task GetOrSetObjectAsync_UsesNoCacheService_WhenPumpObservationsModeIsNone() { @@ -282,6 +330,13 @@ public class CacheDispatcherTest #endregion #region TC-26 + /// + /// Verifies that falls back to the InMemory cache service + /// when the provided cache key has an unrecognized prefix, ensuring that unknown keys are still served by the default + /// cache implementation rather than the or . + /// + /// A that completes when the fallback behavior has been validated through the assertions. + /// [Test] public async Task GetOrSetObjectAsync_UsesCacheService_WhenKeyIsUnrecognized() { diff --git a/adas-core.Test/Services/CacheServiceTest.cs b/adas-core.Test/Services/CacheServiceTest.cs index 40d355c2..3bcf6e50 100644 --- a/adas-core.Test/Services/CacheServiceTest.cs +++ b/adas-core.Test/Services/CacheServiceTest.cs @@ -2,6 +2,13 @@ namespace adas_core.Test.Services; using adas_core.Application.Services.Caching; using Microsoft.Extensions.Logging; using Moq; +/// +/// Provides a test fixture containing unit tests for the CacheService class. +/// +/// +/// The indicates that this class groups related test methods executed by the NUnit testing framework. +/// +/// [TestFixture] public class CacheServiceTest { @@ -21,6 +28,10 @@ public class CacheServiceTest _svc = new CacheService(lockMgr); } #region TC-31 + /// + /// Verifies that GetOrSetObjectAsync returns the previously cached value for a key that already exists in the cache and does not invoke the factory delegate. + /// + /// [Test] public async Task GetOrSetObjectAsync_ReturnsCachedValue_AndDoesNotInvokeFactory_WhenKeyAlreadyExists() { diff --git a/adas-core.Test/Services/CameraServiceTest.cs b/adas-core.Test/Services/CameraServiceTest.cs index 1d0dcbc0..dc893eaf 100644 --- a/adas-core.Test/Services/CameraServiceTest.cs +++ b/adas-core.Test/Services/CameraServiceTest.cs @@ -1,5 +1,9 @@ namespace adas_core.Test.Services; +/// +/// Serves as a test fixture that contains unit tests for the class. +/// +/// [TestFixture] internal class CameraServiceTest { diff --git a/adas-core.Test/Services/ConfigObservationServiceTest.cs b/adas-core.Test/Services/ConfigObservationServiceTest.cs index b38404e8..ebf78454 100644 --- a/adas-core.Test/Services/ConfigObservationServiceTest.cs +++ b/adas-core.Test/Services/ConfigObservationServiceTest.cs @@ -16,6 +16,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides unit tests for the class. +/// +/// [TestFixture] public class ConfigObservationServiceTest { diff --git a/adas-core.Test/Services/ConfigPumpsServiceTest.cs b/adas-core.Test/Services/ConfigPumpsServiceTest.cs index 19ed2891..1c2e936b 100644 --- a/adas-core.Test/Services/ConfigPumpsServiceTest.cs +++ b/adas-core.Test/Services/ConfigPumpsServiceTest.cs @@ -14,6 +14,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Serves as a test fixture containing unit tests for the class. +/// +/// +/// Marked with the NUnit to group and execute the test methods that validate the behavior of . +/// +/// [TestFixture] public class ConfigPumpsServiceTest { diff --git a/adas-core.Test/Services/ConfigUnitsServiceTest.cs b/adas-core.Test/Services/ConfigUnitsServiceTest.cs index 3dfc8826..a33e03f3 100644 --- a/adas-core.Test/Services/ConfigUnitsServiceTest.cs +++ b/adas-core.Test/Services/ConfigUnitsServiceTest.cs @@ -10,6 +10,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides unit tests for the class. +/// +/// [TestFixture] public class ConfigUnitsServiceTest { diff --git a/adas-core.Test/Services/DiagnosisServiceTest.cs b/adas-core.Test/Services/DiagnosisServiceTest.cs index 5b162323..a8dbc5dc 100644 --- a/adas-core.Test/Services/DiagnosisServiceTest.cs +++ b/adas-core.Test/Services/DiagnosisServiceTest.cs @@ -14,6 +14,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Defines a test fixture containing unit tests that verify the behavior of the DiagnosisService. +/// +/// [TestFixture] public class DiagnosisServiceTest { @@ -213,6 +217,10 @@ public class DiagnosisServiceTest _diagnosisRepositoryMock.Verify(d => d.InsertOneAsync(It.IsAny()), Times.Never); } + /// + /// Verifies that does not insert a when the supplied does not represent diagnosis code settings. + /// + /// [Test] public async Task SaveRequest_Not_DiagnosisCodeSettings_Return_not_insert() { diff --git a/adas-core.Test/Services/DisplayServiceTest.cs b/adas-core.Test/Services/DisplayServiceTest.cs index e83f7b26..b8d58c4d 100644 --- a/adas-core.Test/Services/DisplayServiceTest.cs +++ b/adas-core.Test/Services/DisplayServiceTest.cs @@ -15,6 +15,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides a NUnit test fixture that exercises the behavior of the DisplayService class. +/// +/// +/// Marked with so the NUnit test runner can discover and execute the contained test methods. +/// +/// [TestFixture] public class DisplayServiceTest { @@ -144,6 +151,12 @@ public class DisplayServiceTest // GetAllByUser - Admin case // ----------------------------------------------------------- + /// + /// Verifies that returns all objects + /// associated with the units the user has authorization over when the user holds the + /// role. + /// + /// [Test] public async Task GetAllByUser_ShouldReturnDisplays_WhenAdmin() { diff --git a/adas-core.Test/Services/GroupedObservationServiceTest.cs b/adas-core.Test/Services/GroupedObservationServiceTest.cs index d73fe8cf..0f023fdf 100644 --- a/adas-core.Test/Services/GroupedObservationServiceTest.cs +++ b/adas-core.Test/Services/GroupedObservationServiceTest.cs @@ -12,6 +12,10 @@ using static adas_core.Domain.Enums.GroupedObservationEnum; namespace adas_core.Test.Services; +/// +/// Represents a NUnit test fixture that verifies the behavior of . +/// +/// [TestFixture] public class GroupedObservationServiceTest { diff --git a/adas-core.Test/Services/HistoricalConfigChangesServiceTest.cs b/adas-core.Test/Services/HistoricalConfigChangesServiceTest.cs index 8d52bb3b..0cbb4b83 100644 --- a/adas-core.Test/Services/HistoricalConfigChangesServiceTest.cs +++ b/adas-core.Test/Services/HistoricalConfigChangesServiceTest.cs @@ -9,6 +9,13 @@ using Moq; namespace adas_core.Test.Services; +/// +/// Test fixture that contains unit tests for HistoricalConfigChangesService. +/// +/// +/// Tests in this fixture are decorated with the NonParallelizable attribute and must not execute concurrently with other tests. +/// +/// [TestFixture] [NonParallelizable] internal class HistoricalConfigChangesServiceTest diff --git a/adas-core.Test/Services/InMemoryLockProviderTest.cs b/adas-core.Test/Services/InMemoryLockProviderTest.cs index e3cf0133..67da4572 100644 --- a/adas-core.Test/Services/InMemoryLockProviderTest.cs +++ b/adas-core.Test/Services/InMemoryLockProviderTest.cs @@ -4,6 +4,12 @@ using adas_core.Application.Services.Caching; namespace adas_core.Test.Services; +/// +/// NUnit test fixture that exercises the behavior of the in-memory lock provider. +/// +/// +/// The attribute marks this class as a container of related test cases. +/// [TestFixture] public class InMemoryLockProviderTest { diff --git a/adas-core.Test/Services/LightBeaconServiceTest.cs b/adas-core.Test/Services/LightBeaconServiceTest.cs index 3881762d..59551f22 100644 --- a/adas-core.Test/Services/LightBeaconServiceTest.cs +++ b/adas-core.Test/Services/LightBeaconServiceTest.cs @@ -12,6 +12,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides a NUnit test fixture for validating the behavior of LightBeaconService. +/// +/// +/// Marked with the attribute, this class groups together unit tests targeting LightBeaconService. +/// +/// [TestFixture] public class LightBeaconServiceTest { diff --git a/adas-core.Test/Services/MasterListServiceTest.cs b/adas-core.Test/Services/MasterListServiceTest.cs index 6bc0f02f..eb70cf2e 100644 --- a/adas-core.Test/Services/MasterListServiceTest.cs +++ b/adas-core.Test/Services/MasterListServiceTest.cs @@ -13,6 +13,10 @@ using Moq; namespace adas_core.Test.Services; +/// +/// Provides unit tests for the class, exercising its behavior under the NUnit framework. +/// +/// [TestFixture] public class MasterListServiceTest { diff --git a/adas-core.Test/Services/MedicineServiceTest.cs b/adas-core.Test/Services/MedicineServiceTest.cs index 6ee09145..b68a7918 100644 --- a/adas-core.Test/Services/MedicineServiceTest.cs +++ b/adas-core.Test/Services/MedicineServiceTest.cs @@ -14,9 +14,17 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Contains unit tests for the class, verifying its behavior and contracts. +/// +/// [TestFixture] public class MedicineServiceTest { + /// + /// Initializes the test dependencies for unit tests by creating mocks for , , and , then constructing the service under test with the required collaborators. + /// + /// [SetUp] public void Setup() { @@ -55,6 +63,11 @@ public class MedicineServiceTest //private static readonly DateTime now = DateTime.Now; private static readonly ObjectId PatientId = ObjectId.GenerateNewId(); + /// + /// Verifies that returns an empty result (count of 0) when yields no items for the supplied entries. + /// + /// Thrown when the local collection is null. + /// [Test] public async Task GetMedicinesOfTreatments_Null_Medicine_Return_0() { @@ -71,6 +84,11 @@ public class MedicineServiceTest Assert.That(result.Count(), EqualTo(0)); } + /// + /// Verifies that returns medicines when the supplied + /// contains codes matching medicines registered in the repository. + /// + /// [Test] public async Task GetMedicinesOfTreatments_Medicines_Return_Medicines() { @@ -117,6 +135,10 @@ public class MedicineServiceTest Assert.That(result.Count(), GreaterThan(0)); } + /// + /// Tests that returns medicines for a when the medicine repository returns no results for , verifying that the returned medicines contain the identifier and text extracted from . + /// + /// [Test] public async Task GetMedicinesOfTreatments_Not_Get_Medicines_Return_Note_Medicines() { @@ -152,6 +174,10 @@ public class MedicineServiceTest }; } + /// + /// Verifies that falls back to constructing medicines from the text when the medicine repository returns no medicines matching the requested codes. + /// + /// [Test] public async Task GetMedicinesOfTreatments_Not_Get_Medicines_Not_Code_identifier_Return_Note_Medicines() { @@ -188,6 +214,10 @@ public class MedicineServiceTest }; } + /// + /// Verifies that returns an NPT with type when the notes contain the "NPT" formularybaseformulation comment. + /// + /// [Test] public async Task CalculateParentalNutritionMedicine_Notes_NPT_Return_NPT_Medicine() { @@ -226,6 +256,10 @@ public class MedicineServiceTest }; } + /// + /// Verifies that when a includes notes indicating "NPT" parenteral nutrition and a lipid formulation comment, resolves the treatment into a named "NPT" of type with no associated code, even when returns an empty list. + /// + /// [Test] public async Task CalculateParentalNutritionMedicine_Notes_NPTL_Return_NPTL_Medicine() { diff --git a/adas-core.Test/Services/NoCacheServiceTest.cs b/adas-core.Test/Services/NoCacheServiceTest.cs index 4b0a82cb..e05c56c7 100644 --- a/adas-core.Test/Services/NoCacheServiceTest.cs +++ b/adas-core.Test/Services/NoCacheServiceTest.cs @@ -2,6 +2,10 @@ using adas_core.Application.Services.Caching; namespace adas_core.Test.Services; +/// +/// Test fixture that validates the behavior of the NoCacheService, ensuring its operations function correctly in a non-caching context. +/// +/// [TestFixture] public class NoCacheServiceTest { @@ -19,6 +23,11 @@ public class NoCacheServiceTest #region TC-27 + /// + /// Verifies that the no-cache implementation of always invokes the supplied factory delegate + /// and never returns a previously cached value, even when called repeatedly with the same key. + /// + /// [Test] public async Task GetOrSetObjectAsync_AlwaysCallsFactory_NeverUsesCache() { @@ -45,6 +54,10 @@ public class NoCacheServiceTest Assert.That(result2, Is.EqualTo(expectedResult)); } + /// + /// Verifies that GetOrSetValueAsync invokes the supplied factory delegate once for every unique key passed in, ensuring that the no-cache implementation does not deduplicate or short-circuit calls based on key uniqueness. + /// + /// [Test] public async Task GetOrSetObjectAsync_CallsFactory_ForEachUniqueKey() { diff --git a/adas-core.Test/Services/ObservationServiceTest.cs b/adas-core.Test/Services/ObservationServiceTest.cs index b0865ecb..cfdb6590 100644 --- a/adas-core.Test/Services/ObservationServiceTest.cs +++ b/adas-core.Test/Services/ObservationServiceTest.cs @@ -18,6 +18,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Serves as a NUnit test fixture that verifies the behavior of . +/// +/// [TestFixture] public class ObservationServiceTest { @@ -159,6 +163,10 @@ public class ObservationServiceTest private static readonly DateTime Now = DateTime.Now; private static readonly ObjectId PatientId = ObjectId.GenerateNewId(); + /// + /// Verifies that when an contains allergy observations stating that the patient has no known allergies, the observation service does not insert a new named "AllergiesObs" for the patient. + /// + /// [Test] public async Task ProcessAllergiesObservation__apiRequest_No_Allergies_Return_Nothing() { @@ -229,6 +237,12 @@ public class ObservationServiceTest )), Times.Never); } + /// + /// Verifies that the observation processing pipeline correctly handles an containing a latex allergy entry, + /// ensuring that the mapped with its list is persisted via the + /// repository's InsertOneAsync call after being resolved through the patient, configuration, and unit services. + /// + /// [Test] public async Task ProcessAllergiesObservation_apiRequest_Allergies_Latex_Return_AllergiesObs_Latex() { @@ -328,6 +342,10 @@ public class ObservationServiceTest _observationRepository.Verify(o => o.InsertOneAsync(expectedObs)); } + /// + /// Verifies that correctly handles an of type "ORU_R01" containing allergy-related entries, consolidating them into a single whose value groups the allergies by type with their allergen and notes, and that the resulting observation is persisted via . + /// + /// [Test] public async Task ProcessAllergiesObservation_apiRequest_Allergies_Return_AllergiesObs() { @@ -512,6 +530,10 @@ public class ObservationServiceTest } + /// + /// Verifies that SaveRequest processes an of type "ORU_R01" carrying drainages-related entries (volume, location, type and column height) and persists the resulting through the repository insert operation with the mapped collection as its value. + /// + /// [Test] public async Task ProcessDrainagesObservation_apiRequest_Drainages_Return_DrainagesObs() { @@ -816,6 +838,10 @@ public class ObservationServiceTest ))); } + /// + /// Verifies that processes an ORU_R01 message containing a SNOMED-coded intravenous line observation (peripheral epicatheter at the right temporal zone) and inserts a carrying a with the expected , , , , , and . + /// + /// [Test] public async Task ProcessIntravenousLinesObservation_Return_PositionObs() { diff --git a/adas-core.Test/Services/PatientServiceTest.cs b/adas-core.Test/Services/PatientServiceTest.cs index d876e252..b56d8616 100644 --- a/adas-core.Test/Services/PatientServiceTest.cs +++ b/adas-core.Test/Services/PatientServiceTest.cs @@ -18,6 +18,10 @@ using static NUnit.Framework.Assert; namespace adas_core.Test.Services; +/// +/// Serves as the NUnit test class that contains unit tests for . +/// +/// [TestFixture] internal class PatientServiceTest { @@ -1076,6 +1080,10 @@ internal class PatientServiceTest } + /// + /// Verifies that an ADT_A02 transfer request for an existing patient targeting a non-existent destination bed moves the patient to a virtual Point of Care flagged as Unknown when is disabled. + /// + /// [Test] public async Task ADT_A02_TRANSFER_PATIENT_FROM_EXISTS_BED_TO_NOT_EXISTS_BED_SHOULD_MOVE_TO_VIRTUAL_POC_UNKNOWN() { diff --git a/adas-core.Test/Services/PointOfCareServiceTest.cs b/adas-core.Test/Services/PointOfCareServiceTest.cs index dc7e6b8a..ff90d20e 100644 --- a/adas-core.Test/Services/PointOfCareServiceTest.cs +++ b/adas-core.Test/Services/PointOfCareServiceTest.cs @@ -14,6 +14,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Test fixture that exercises the behavior of . +/// +/// +/// Marked with so that the test runner discovers and executes the contained test methods. +/// +/// [TestFixture] public class PointOfCareServiceTests { @@ -210,6 +217,13 @@ public class PointOfCareServiceTests Assert.That(result, Is.EqualTo(expectedPointOfCareList)); } + /// + /// Verifies that resolves the through the cache factory, + /// looks up the next when is null, assigns it to the PoC, + /// transitions the status to Reserved, and invokes exactly once, + /// without taking the FindByIdAllConfig code path. + /// + /// [Test] public void CheckNextAdmission_ValidPatientLocation_UpdatesPoCStatus_AndCallsUpdate() { diff --git a/adas-core.Test/Services/PublisherServiceTest.cs b/adas-core.Test/Services/PublisherServiceTest.cs index 88f670c6..a6e46af2 100644 --- a/adas-core.Test/Services/PublisherServiceTest.cs +++ b/adas-core.Test/Services/PublisherServiceTest.cs @@ -8,6 +8,10 @@ using Moq; namespace adas_core.Test.Services; +/// +/// Provides a test fixture that validates the behavior of the . +/// +/// [TestFixture] public class PublisherServiceTest { diff --git a/adas-core.Test/Services/PumpServiceTest.cs b/adas-core.Test/Services/PumpServiceTest.cs index a3498598..90bd7fda 100644 --- a/adas-core.Test/Services/PumpServiceTest.cs +++ b/adas-core.Test/Services/PumpServiceTest.cs @@ -17,6 +17,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides a test fixture for verifying the behavior of the PumpService. +/// +/// +/// This class is decorated with the TestFixture attribute and hosts the unit tests for the PumpService. +/// +/// [TestFixture] public class PumpServiceTest { @@ -293,6 +300,10 @@ public class PumpServiceTest Times.Never); } + /// + /// Verifies that falls back to when the patient cannot be resolved from the API request, broadcasts the resulting to subscribers matching that location, and skips messages when no active alarms exist. + /// + /// [Test] public async Task SaveRequest_WithSubscribers_UsesReqLocation_AndSendsBroadcast() { diff --git a/adas-core.Test/Services/RecordingAlertServiceTest.cs b/adas-core.Test/Services/RecordingAlertServiceTest.cs index da9067a8..4fdfa25e 100644 --- a/adas-core.Test/Services/RecordingAlertServiceTest.cs +++ b/adas-core.Test/Services/RecordingAlertServiceTest.cs @@ -11,6 +11,10 @@ using Moq; namespace adas_core.Test.Services; +/// +/// Provides a test fixture containing unit tests for the class. +/// +/// [TestFixture] public class RecordingAlertServiceTest { diff --git a/adas-core.Test/Services/RecordingServiceTest.cs b/adas-core.Test/Services/RecordingServiceTest.cs index 950790e9..f7f2dd23 100644 --- a/adas-core.Test/Services/RecordingServiceTest.cs +++ b/adas-core.Test/Services/RecordingServiceTest.cs @@ -16,6 +16,13 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Acts as a NUnit test fixture that validates the behavior of the class. +/// +/// +/// Marked with , this class groups the unit tests that exercise . +/// +/// [TestFixture] public class RecordingServiceTest { diff --git a/adas-core.Test/Services/RedisLockProviderTest.cs b/adas-core.Test/Services/RedisLockProviderTest.cs index 680ab5af..61681d50 100644 --- a/adas-core.Test/Services/RedisLockProviderTest.cs +++ b/adas-core.Test/Services/RedisLockProviderTest.cs @@ -5,6 +5,13 @@ using StackExchange.Redis; namespace adas_core.Test.Services; +/// +/// Represents a test fixture that contains unit tests for the RedisLockProvider class. +/// +/// +/// Decorated with the TestFixture attribute so that NUnit-compatible test runners can discover and execute its test methods. +/// +/// [TestFixture] public class RedisLockProviderTest { diff --git a/adas-core.Test/Services/RedisServiceTest.cs b/adas-core.Test/Services/RedisServiceTest.cs index e5832ac4..d3cb5c22 100644 --- a/adas-core.Test/Services/RedisServiceTest.cs +++ b/adas-core.Test/Services/RedisServiceTest.cs @@ -9,6 +9,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Represents an NUnit containing unit tests that exercise the behavior of the Redis service. +/// +/// [TestFixture] public class RedisServiceTest { diff --git a/adas-core.Test/Services/RelayServiceTest.cs b/adas-core.Test/Services/RelayServiceTest.cs index a21423c7..546b6fda 100644 --- a/adas-core.Test/Services/RelayServiceTest.cs +++ b/adas-core.Test/Services/RelayServiceTest.cs @@ -13,6 +13,10 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Provides a NUnit test fixture that contains the unit tests for the RelayService class. +/// +/// [TestFixture] public class RelayServiceTest { @@ -176,6 +180,10 @@ public class RelayServiceTest Assert.That(result, Is.EqualTo(RelayEnum.Status.On)); } + /// + /// Verifies that the relay status check returns when the mocked HTTP response indicates the relay is off, after invoking the power-off operation on the supplied . + /// + /// [Test] public async Task CheckRelayStatus_Return_Off() { diff --git a/adas-core.Test/Services/SchedulerServiceTest.cs b/adas-core.Test/Services/SchedulerServiceTest.cs index 7433bdba..f431d106 100644 --- a/adas-core.Test/Services/SchedulerServiceTest.cs +++ b/adas-core.Test/Services/SchedulerServiceTest.cs @@ -16,9 +16,26 @@ using Options = Microsoft.Extensions.Options.Options; namespace adas_core.Test.Services; +/// +/// Contains unit tests that verify the behavior of the class. +/// +/// +/// Marked as a test fixture so that the contained test methods are discovered and executed by the test runner. +/// +/// [TestFixture] public class SchedulerServiceTest { + /// + /// One-time setup that initializes mocked services, lazy wrappers, and test data + /// required to exercise along with the Quartz-based + /// news and expiration jobs (, , + /// ). It configures and + /// behaviors to match observations by name and patient, and the + /// to return the predefined patient list from + /// , then starts the underlying scheduler. + /// + /// [OneTimeSetUp] public async Task SetUp() { @@ -267,6 +284,10 @@ public class SchedulerServiceTest //[TearDown] + /// + /// Stops the Quartz.NET scheduler engine after all tests in the fixture have run. Uses the null-conditional operator so the call is safely skipped when the scheduler was never initialized. + /// + /// [OneTimeTearDown] public void TearDown() { diff --git a/adas-core.Test/Services/SendAlertServiceTest.cs b/adas-core.Test/Services/SendAlertServiceTest.cs index 2f0fbe11..11be14cf 100644 --- a/adas-core.Test/Services/SendAlertServiceTest.cs +++ b/adas-core.Test/Services/SendAlertServiceTest.cs @@ -7,6 +7,10 @@ using Moq; namespace adas_core.Test.Services; +/// +/// Provides a test fixture for unit testing the SendAlertService class. +/// +/// [TestFixture] public class SendAlertServiceTest { diff --git a/adas-core.Test/Services/SeviceConfigServiceTest.cs b/adas-core.Test/Services/SeviceConfigServiceTest.cs index 0c8c5f65..2a4aaeb5 100644 --- a/adas-core.Test/Services/SeviceConfigServiceTest.cs +++ b/adas-core.Test/Services/SeviceConfigServiceTest.cs @@ -7,6 +7,10 @@ using ServiceConfigService = adas_core.Application.Services.ServiceConfigService namespace adas_core.Test.Services; +/// +/// Test fixture for the ServiceConfigService, containing its related unit tests. +/// +/// [TestFixture] public class ServiceConfigServiceTest { diff --git a/adas-core.Test/Services/TreatmentServiceTest.cs b/adas-core.Test/Services/TreatmentServiceTest.cs index 84a9b90c..8f5cb4f4 100644 --- a/adas-core.Test/Services/TreatmentServiceTest.cs +++ b/adas-core.Test/Services/TreatmentServiceTest.cs @@ -13,6 +13,10 @@ using static NUnit.Framework.Assert; namespace adas_core.Test.Services; +/// +/// Acts as the NUnit test fixture for the TreatmentService, housing the unit tests that verify its behavior. +/// +/// [TestFixture] public class TreatmentServiceTest { diff --git a/adas-core.Test/Utilities/CacheKeyClassifierTest.cs b/adas-core.Test/Utilities/CacheKeyClassifierTest.cs index 59a29571..3cafcaf1 100644 --- a/adas-core.Test/Utilities/CacheKeyClassifierTest.cs +++ b/adas-core.Test/Utilities/CacheKeyClassifierTest.cs @@ -9,6 +9,10 @@ using Microsoft.Extensions.Logging; namespace adas_core.Test.Utilities; +/// +/// Provides a that validates the behavior of . +/// +/// [TestFixture] public class CacheKeyClassifierTest { diff --git a/adas-core/Controllers/ConfigObservationController.cs b/adas-core/Controllers/ConfigObservationController.cs index ece9222b..93407bc4 100644 --- a/adas-core/Controllers/ConfigObservationController.cs +++ b/adas-core/Controllers/ConfigObservationController.cs @@ -10,6 +10,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Represents an API controller that handles HTTP requests for configuration observations at the config-observations route. +/// +/// +/// Annotated with and inherits from . +/// +/// [Route("config-observations")] [ApiController] public class ConfigObservationController : ControllerBase @@ -17,6 +24,12 @@ public class ConfigObservationController : ControllerBase private readonly IConfigObservationService _configObservationService; private readonly IHistoricalConfigChangesService _historicalConfigChangesService; + /// + /// Initializes a new instance of the class, establishing a trace identifier via and storing the injected dependencies used for observing configuration state and retrieving historical configuration changes. + /// + /// The dependency used by the controller to observe configuration state. + /// The dependency used by the controller to retrieve historical configuration changes. + /// public ConfigObservationController(IConfigObservationService configObservationService, IHistoricalConfigChangesService historicalConfigChangesService) { diff --git a/adas-core/Controllers/DeviceController.cs b/adas-core/Controllers/DeviceController.cs index 78b0c183..6a99bc86 100644 --- a/adas-core/Controllers/DeviceController.cs +++ b/adas-core/Controllers/DeviceController.cs @@ -7,12 +7,22 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as the HTTP entry point for device-related operations, exposing endpoints under the device route. +/// Inherits from and is configured with the to provide API-specific behavior. +/// +/// [Route("device")] [ApiController] public class DeviceController : ControllerBase { private readonly IDeviceService _deviceService; + /// + /// Initializes a new instance of the class, capturing the dependency required to coordinate device operations. + /// + /// The used by the controller to access device functionality. + /// public DeviceController(IDeviceService deviceService) { _deviceService = deviceService; diff --git a/adas-core/Controllers/DiagnosisController.cs b/adas-core/Controllers/DiagnosisController.cs index d9c473c2..f6ae09eb 100644 --- a/adas-core/Controllers/DiagnosisController.cs +++ b/adas-core/Controllers/DiagnosisController.cs @@ -8,12 +8,24 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// Serves as the API endpoint container for managing medical diagnosis resources, exposing operations under the diagnosis route. +/// +/// +/// The controller is bound to the diagnosis URI path through and enabled with Web API conventions by , while inheriting base MVC functionality from . +/// +/// [Route("diagnosis")] [ApiController] public class DiagnosisController : ControllerBase { private readonly IDiagnosisService _diagnosisService; + /// + /// Initializes a new instance of the class, establishing a logging trace identifier via and storing the injected dependency used to handle diagnosis-related operations. + /// + /// The instance used by the controller to perform diagnosis operations. + /// public DiagnosisController(IDiagnosisService diagnosisService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/DischargeController.cs b/adas-core/Controllers/DischargeController.cs index 013c8a8c..8a46162d 100644 --- a/adas-core/Controllers/DischargeController.cs +++ b/adas-core/Controllers/DischargeController.cs @@ -9,6 +9,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Exposes endpoints for discharge-related operations, handling HTTP requests routed to discharges and deriving from . +/// +/// +/// Marked with to enable API-specific behavior such as automatic model validation and standardized responses. +/// +/// [Route("discharges")] [ApiController] public class DischargeController : ControllerBase @@ -16,6 +23,12 @@ public class DischargeController : ControllerBase private readonly IDischargeService _dischargeService; private readonly IPatientService _patientService; + /// + /// Initializes a new instance of the class, storing the provided and dependencies and establishing a trace identifier via . + /// + /// The dependency assigned to the controller. + /// The dependency assigned to the controller. + /// public DischargeController(IDischargeService dischargeService, IPatientService patientService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/DisplayController.cs b/adas-core/Controllers/DisplayController.cs index 178bcc48..b3df5591 100644 --- a/adas-core/Controllers/DisplayController.cs +++ b/adas-core/Controllers/DisplayController.cs @@ -11,6 +11,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as an API controller that handles HTTP requests for display-related resources under the displays route. +/// +/// +/// Uses to manage displays and to manage display configurations. +/// +/// [Route("displays")] [ApiController] public class DisplayController( diff --git a/adas-core/Controllers/GroupedObservationsController.cs b/adas-core/Controllers/GroupedObservationsController.cs index 22d42de8..a3fba356 100644 --- a/adas-core/Controllers/GroupedObservationsController.cs +++ b/adas-core/Controllers/GroupedObservationsController.cs @@ -9,12 +9,24 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Exposes HTTP endpoints for the grouped-observations route, handling requests related to grouped observation resources as a Web API controller derived from . +/// +/// +/// The type is annotated with mapping requests to the grouped-observations URI template and to enable ASP.NET Core Web API conventions. +/// +/// [Route("grouped-observations")] [ApiController] public class GroupedObservationsController : ControllerBase { private readonly IGroupedObservationService _groupedObservationService; + /// + /// Initializes a new instance of the class, capturing the dependency required by the controller and establishing a correlation trace identifier through . + /// + /// The grouped observation service that the controller will use to perform its operations. + /// public GroupedObservationsController(IGroupedObservationService groupedObservationService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/LightBeaconController.cs b/adas-core/Controllers/LightBeaconController.cs index c2a5f6c2..1f9fcfcf 100644 --- a/adas-core/Controllers/LightBeaconController.cs +++ b/adas-core/Controllers/LightBeaconController.cs @@ -10,6 +10,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Exposes Web API endpoints for managing light beacon resources, mapped to the beacons route. +/// +/// +/// Derives from and therefore provides HTTP request handling without view support. +/// +/// [Route("beacons")] public class LightBeaconController : ControllerBase { @@ -17,6 +24,12 @@ public class LightBeaconController : ControllerBase private readonly IPatientService _patientService; + /// + /// Initializes a new instance of the class, which coordinates light beacon operations with patient data by setting an execution trace identifier via and storing the injected service dependencies. + /// + /// The dependency used by the controller to perform light beacon operations. + /// The dependency used by the controller to perform patient-related operations. + /// public LightBeaconController(ILightBeaconService lightBeaconService, IPatientService patientService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/MasterListController.cs b/adas-core/Controllers/MasterListController.cs index 4558b118..31e4c6aa 100644 --- a/adas-core/Controllers/MasterListController.cs +++ b/adas-core/Controllers/MasterListController.cs @@ -12,6 +12,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as an API controller that handles HTTP requests routed to "master-lists" for master list operations. +/// +/// +/// Inherits from and is annotated with . Its dependencies (, , and ) are supplied through constructor injection. +/// +/// [Route("master-lists")] [ApiController] public class MasterListController( diff --git a/adas-core/Controllers/MedicinesController.cs b/adas-core/Controllers/MedicinesController.cs index 7db5b886..9da14aa1 100644 --- a/adas-core/Controllers/MedicinesController.cs +++ b/adas-core/Controllers/MedicinesController.cs @@ -10,6 +10,11 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as the HTTP endpoint controller for medicine-related resources, exposing operations under the "medicines" route. +/// Inherits from to leverage ASP.NET Core controller infrastructure for handling requests and responses. +/// +/// [Route("medicines")] public class MedicinesController : ControllerBase { @@ -19,6 +24,12 @@ public class MedicinesController : ControllerBase //private readonly ILogger _loggerADMPanel; + /// + /// Initializes a new instance of the class, storing the supplied and dependencies and establishing a trace identifier through . + /// + /// The used by the controller to handle medicine-related operations. + /// The used by the controller to handle administrative operations. + /// public MedicinesController(IMedicineService medicineService, IAdminPanelService adminPanelService) //, ILogger loggerADMPanel) { diff --git a/adas-core/Controllers/NoticeController.cs b/adas-core/Controllers/NoticeController.cs index 56db601f..d7a9e667 100644 --- a/adas-core/Controllers/NoticeController.cs +++ b/adas-core/Controllers/NoticeController.cs @@ -9,12 +9,23 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as the API controller responsible for handling HTTP requests routed to the notices endpoint, deriving from . +/// +/// +/// The controller is mapped to the route template notices via the applied at the class level. +/// [Route("notices")] public class NoticeController : ControllerBase { private readonly INoticeService _noticeService; + /// + /// Initializes a new instance of the class, a controller that handles notice operations via the injected , and sets a trace identifier on for the current execution context. + /// + /// The dependency used by the controller to perform notice-related operations. + /// public NoticeController(INoticeService noticeService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/ObservationsController.cs b/adas-core/Controllers/ObservationsController.cs index 469adb87..1621fc5f 100644 --- a/adas-core/Controllers/ObservationsController.cs +++ b/adas-core/Controllers/ObservationsController.cs @@ -12,6 +12,10 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Represents an API controller that exposes observation-related endpoints, mapped to the "observations" route and inheriting from . +/// +/// [Route("observations")] [ApiController] public class ObservationController : ControllerBase @@ -21,6 +25,12 @@ public class ObservationController : ControllerBase private readonly IPatientService _patientService; + /// + /// Initializes a new instance of the class, a controller that coordinates observation-related operations, by assigning the supplied and dependencies to backing fields and establishing a trace identifier via . + /// + /// The dependency used to manage observations. + /// The dependency used to manage patient-related data. + /// public ObservationController(IObservationService observationService, IPatientService patientService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/PatientAppointmentController.cs b/adas-core/Controllers/PatientAppointmentController.cs index 2fd8b2c7..3c5491e7 100644 --- a/adas-core/Controllers/PatientAppointmentController.cs +++ b/adas-core/Controllers/PatientAppointmentController.cs @@ -8,6 +8,13 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// Represents an API controller that handles HTTP operations related to patient appointments. +/// +/// +/// Routes requests under the appointments path and exposes appointment-related endpoints via the ASP.NET Core Web API infrastructure, inheriting common controller functionality from . +/// +/// [Route("appointments")] [ApiController] public class PatientAppointmentController : ControllerBase @@ -15,6 +22,11 @@ public class PatientAppointmentController : ControllerBase private readonly IAppointmentService _appointmentService; + /// + /// Initializes a new instance of the class, which coordinates patient appointment operations, by storing in a private field and establishing a trace identifier via . + /// + /// The used to handle appointment-related operations. + /// public PatientAppointmentController(IAppointmentService appointmentService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/PatientController.cs b/adas-core/Controllers/PatientController.cs index c47be785..b8c842fc 100644 --- a/adas-core/Controllers/PatientController.cs +++ b/adas-core/Controllers/PatientController.cs @@ -14,6 +14,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Represents an API controller that handles HTTP requests routed to persons for managing patient resources. +/// +/// +/// Configured with using the template persons and with , and derives from . +/// +/// [Route("persons")] [ApiController] public class PatientController : ControllerBase diff --git a/adas-core/Controllers/PointOfCareController.cs b/adas-core/Controllers/PointOfCareController.cs index 1ccd6d66..82369198 100644 --- a/adas-core/Controllers/PointOfCareController.cs +++ b/adas-core/Controllers/PointOfCareController.cs @@ -9,6 +9,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// API controller that exposes endpoints related to point-of-care resources, delegating business operations to an injected . +/// +/// +/// Inherits from and is mapped to the point-of-cares route. +/// +/// [Route("point-of-cares")] [ApiController] public class PointOfCareController(IPointOfCareService pointOfCareService) diff --git a/adas-core/Controllers/ProxyDeviceController.cs b/adas-core/Controllers/ProxyDeviceController.cs index d8d2c409..8c752d1d 100644 --- a/adas-core/Controllers/ProxyDeviceController.cs +++ b/adas-core/Controllers/ProxyDeviceController.cs @@ -6,6 +6,14 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// Acts as the Web API controller that exposes proxy device operations under the proxy-devices route. +/// Delegates the underlying business logic to the injected instance. +/// +/// +/// Inherits from and is annotated with to enable API-specific conventions, while defines the controller's base route template. +/// +/// [Route("proxy-devices")] [ApiController] public class ProxyDeviceController(IProxyDeviceService proxyDeviceService) : ControllerBase diff --git a/adas-core/Controllers/PumpsController.cs b/adas-core/Controllers/PumpsController.cs index 23d267e2..25de599c 100644 --- a/adas-core/Controllers/PumpsController.cs +++ b/adas-core/Controllers/PumpsController.cs @@ -12,6 +12,11 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Serves as an MVC controller that handles HTTP requests related to pumps, mapped to the "pumps" route. +/// Inherits from to provide ASP.NET Core Web API capabilities. +/// +/// [Route("pumps")] public class PumpController : ControllerBase { @@ -19,6 +24,12 @@ public class PumpController : ControllerBase private readonly IPumpService _pumpService; + /// + /// Initializes a new instance of , establishing a trace identifier via and storing the injected service dependencies required by the controller. + /// + /// The used by the controller to interact with pump operations. + /// The used by the controller to record and query historical configuration changes. + /// public PumpController(IPumpService pumpService, IHistoricalConfigChangesService historicalConfigChangesService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/QXController.cs b/adas-core/Controllers/QXController.cs index 51397f85..5b9b3207 100644 --- a/adas-core/Controllers/QXController.cs +++ b/adas-core/Controllers/QXController.cs @@ -2,6 +2,12 @@ namespace adas_core.Controllers; +/// +/// Represents the MVC controller responsible for handling HTTP requests mapped to the "QX" route. +/// +/// +/// Derives standard web API behavior from and is bound to the QX route via the applied at the class level. +/// [Route("QX")] public class QxController : ControllerBase { diff --git a/adas-core/Controllers/RabbitController.cs b/adas-core/Controllers/RabbitController.cs index 114fe91c..62a319ce 100644 --- a/adas-core/Controllers/RabbitController.cs +++ b/adas-core/Controllers/RabbitController.cs @@ -6,6 +6,10 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// Provides HTTP endpoints under the rabbit route as an API controller derived from , delegating request processing to the injected . +/// +/// [Route("rabbit")] [ApiController] public class RabbitController(ReceiverService receiverService) : ControllerBase diff --git a/adas-core/Controllers/RecordingAlertController.cs b/adas-core/Controllers/RecordingAlertController.cs index 067ddf9d..47a6ca75 100644 --- a/adas-core/Controllers/RecordingAlertController.cs +++ b/adas-core/Controllers/RecordingAlertController.cs @@ -8,6 +8,12 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// HTTP API controller that exposes endpoints related to recording alerts under the alerts route. +/// +/// +/// Configured with and and inherits from . +/// [Route("alerts")] [ApiController] public class RecordingAlertController : ControllerBase diff --git a/adas-core/Controllers/RecordingController.cs b/adas-core/Controllers/RecordingController.cs index 91e06ad4..2bfc6164 100644 --- a/adas-core/Controllers/RecordingController.cs +++ b/adas-core/Controllers/RecordingController.cs @@ -2,6 +2,13 @@ namespace adas_core.Controllers; +/// +/// Represents an API controller that exposes endpoints for recording-related operations under the "Recording" route. +/// +/// +/// Inherits from and is decorated with to enable API-specific behaviors. +/// +/// [Route("Recording")] [ApiController] public class RecordingController : ControllerBase diff --git a/adas-core/Controllers/RelayController.cs b/adas-core/Controllers/RelayController.cs index 229b4c24..698d6e4d 100644 --- a/adas-core/Controllers/RelayController.cs +++ b/adas-core/Controllers/RelayController.cs @@ -14,6 +14,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Represents the API controller that exposes relay endpoints, routing incoming HTTP requests under the Relay path to the actions defined by its derived type. +/// +/// +/// Marked with to enable API-specific conventions and with set to Relay to define the controller's route template. Inherits from . +/// +/// [ApiController] [Route("Relay")] public class RelayController : ControllerBase @@ -25,6 +32,14 @@ public class RelayController : ControllerBase private readonly IRelayService _relayService; private readonly ILogger _logger; + /// + /// Initializes a new instance of the class, establishing a new correlation trace identifier via and capturing the injected relay, logging, and point-of-care dependencies required by the controller. + /// + /// The supplying recording configuration values. + /// The used to perform relay operations. + /// The used to log controller activity. + /// The used to access point-of-care data. + /// public RelayController( IOptions recordingSettings, IRelayService relayService, diff --git a/adas-core/Controllers/SendAlertController.cs b/adas-core/Controllers/SendAlertController.cs index 474a0e71..96baee83 100644 --- a/adas-core/Controllers/SendAlertController.cs +++ b/adas-core/Controllers/SendAlertController.cs @@ -8,12 +8,24 @@ using WebPush; namespace adas_core.Controllers; +/// +/// Represents an API controller that exposes endpoints for sending alerts, mapped to the send-alerts route. +/// +/// +/// Inherits from and is annotated with and to enable Web API conventions and route mapping. +/// +/// [Route("send-alerts")] [ApiController] public class SendAlertController : ControllerBase { private readonly ISendAlertService _sendAlertService; + /// + /// Initializes a new instance of the class, a controller responsible for dispatching alerts via its dependency. The constructor also establishes a trace identifier through for logging correlation. + /// + /// The implementation used by the controller to send alerts. + /// public SendAlertController(ISendAlertService sendAlertService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/SensorController.cs b/adas-core/Controllers/SensorController.cs index 742159a9..b089c216 100644 --- a/adas-core/Controllers/SensorController.cs +++ b/adas-core/Controllers/SensorController.cs @@ -2,6 +2,13 @@ namespace adas_core.Controllers; +/// +/// Exposes HTTP endpoints for sensor resources under the Sensor route. +/// +/// +/// Inherits from and applies to enable API-specific behavior. +/// +/// [Route("Sensor")] [ApiController] public class SensorController : ControllerBase diff --git a/adas-core/Controllers/ServiceConfigController.cs b/adas-core/Controllers/ServiceConfigController.cs index 5fe02068..85bc0028 100644 --- a/adas-core/Controllers/ServiceConfigController.cs +++ b/adas-core/Controllers/ServiceConfigController.cs @@ -6,12 +6,24 @@ using Microsoft.AspNetCore.Mvc; namespace adas_core.Controllers; +/// +/// Represents an API controller that exposes endpoints for managing service configurations at the "service-configs" route. +/// +/// +/// Inherits from and is annotated with to follow Web API conventions. +/// +/// [Route("service-configs")] [ApiController] public class ServiceConfigController : ControllerBase { private readonly IServiceConfigService _serviceConfigService; + /// + /// Initializes a new instance of the , a controller that exposes service configuration operations. Stores the supplied dependency and establishes a new trace identifier via . + /// + /// The instance used by the controller to access service configuration functionality. + /// public ServiceConfigController(IServiceConfigService serviceConfigService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/TreatmentsController.cs b/adas-core/Controllers/TreatmentsController.cs index c2bb29d1..14a1311a 100644 --- a/adas-core/Controllers/TreatmentsController.cs +++ b/adas-core/Controllers/TreatmentsController.cs @@ -11,6 +11,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Provides the HTTP endpoints for managing treatments, exposed under the treatments route. +/// +/// +/// Acts as an API controller by inheriting from and applying the ApiController attribute. +/// +/// [Route("treatments")] [ApiController] public class TreatmentsController : ControllerBase @@ -18,6 +25,13 @@ public class TreatmentsController : ControllerBase private readonly IPatientService _patientService; private readonly ITreatmentService _treatmentService; + /// + /// Initializes a new instance of the class, which handles treatment-related requests. + /// The constructor assigns the provided and to its internal fields and establishes a trace identifier using . + /// + /// The parameter provides treatment data and operations; stored in the controller's internal _treatmentService field. + /// The parameter provides patient data and operations; stored in the controller's internal _patientService field. + /// public TreatmentsController(ITreatmentService treatmentService, IPatientService patientService) { LogExecutionContext.TrySetTraceIdentifier(Guid.NewGuid().ToString(), true); diff --git a/adas-core/Controllers/UnitController.cs b/adas-core/Controllers/UnitController.cs index 085d0241..543e958f 100644 --- a/adas-core/Controllers/UnitController.cs +++ b/adas-core/Controllers/UnitController.cs @@ -11,6 +11,15 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Exposes HTTP endpoints for unit-related operations under the units route via the ASP.NET Core Web API pipeline. +/// Acts as a thin coordinator that delegates unit operations to an IUnitService and administrative concerns to an IAdminPanelService. +/// +/// +/// Constructed with an ILogger<UnitController> for diagnostic logging, an IUnitService for unit data access, and an IAdminPanelService for elevated operations. +/// Inherits from and is decorated with . +/// +/// [Route("units")] [ApiController] public class UnitController( diff --git a/adas-core/Controllers/UserController.cs b/adas-core/Controllers/UserController.cs index a0def3fd..4e806097 100644 --- a/adas-core/Controllers/UserController.cs +++ b/adas-core/Controllers/UserController.cs @@ -13,6 +13,13 @@ using MongoDB.Bson; namespace adas_core.Controllers; +/// +/// Represents the API controller that handles HTTP requests routed to the users endpoint, coordinating user operations through , , and the lazily resolved . +/// +/// +/// Inherits from and is annotated with . Cross-cutting responsibilities are delegated to , , and . +/// +/// [ApiController] [Route("users")] public class UserController( diff --git a/adas-core/WebSocket/Hubs/UciHub.cs b/adas-core/WebSocket/Hubs/UciHub.cs index 0829e1e8..287b35c5 100644 --- a/adas-core/WebSocket/Hubs/UciHub.cs +++ b/adas-core/WebSocket/Hubs/UciHub.cs @@ -9,6 +9,13 @@ using ILogger = Serilog.ILogger; namespace adas_core.WebSocket.Hubs; //[Authorize] +/// +/// Represents a SignalR that coordinates UCI client communication by routing messages and managing subscriber membership through the supplied services. +/// +/// +/// The hub delegates broadcasting and registration responsibilities to , , and , which are supplied through the primary constructor to handle per-connection messaging as well as individual and grouped subscriber state. +/// +/// public class UciHub( IClientMessageService clientMessageService, ISubscribersService subscribersService, diff --git a/adas-core/WebSocket/WebSocketMessageService.cs b/adas-core/WebSocket/WebSocketMessageService.cs index 88335e8d..8a5b75ca 100644 --- a/adas-core/WebSocket/WebSocketMessageService.cs +++ b/adas-core/WebSocket/WebSocketMessageService.cs @@ -22,6 +22,12 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient; namespace adas_core.WebSocket; +/// +/// Provides a WebSocket-based implementation of +/// that coordinates clinical and operational domain services and dispatches +/// client messages through the hub. +/// +/// public class WebSocketMessageService( Lazy patientService, Lazy observationService,