Documentation modifications

This commit is contained in:
julian
2026-06-27 15:23:26 -07:00
parent a633fe6c06
commit a19fb90902
218 changed files with 2882 additions and 0 deletions
@@ -13,6 +13,13 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient;
namespace adas_core.Application.Services;
/// <summary>
/// Provides the administrative panel operations defined by <see cref="IAdminPanelService"/>, integrating patient, admission, discharge, authentication, medicine, point-of-care, unit, display, and configurable observation services.
/// </summary>
/// <remarks>
/// The service receives its collaborators through primary constructor injection, including <see cref="IPatientService"/>, <see cref="IAdmissionService"/>, <see cref="IDischargeService"/>, <see cref="IAuthService"/>, <see cref="IMedicineService"/>, <see cref="IPointOfCareService"/>, <see cref="IUnitService"/>, <see cref="IDisplayService"/>, and <see cref="IConfigObservationService"/>, along with configuration via <see cref="IOptions{ApiSettings}"/> and logging through <see cref="ILogger{AdminPanelService}"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=29af4d8 -->
public class AdminPanelService(
IOptions<ApiSettings> apiSettings,
IPatientService patientService,
@@ -205,6 +212,12 @@ public class AdminPanelService(
return true;
}
/// <summary>
/// Updates the location of a patient identified by the source location in <paramref name="request"/>, relocating any occupant of the target location to the <see cref="VirtualPointOfCare.Pushed"/> point of care and creating a new <see cref="Patient"/> record when no matching patient is found.
/// </summary>
/// <param name="request">The <see cref="AdmPanelRequest"/> containing the original and the target <see cref="PatientLocation"/> values used to find and reassign the patient.</param>
/// <returns>A <see cref="Task{Boolean}"/> that resolves to <c>true</c> once the update or insertion has completed.</returns>
/// <!-- aidoc:v1 sig=d2e1ae3 body=d053266 -->
public async Task<bool> UpdatePatientLocation(AdmPanelRequest request)
{
var patient = await patientService.FindByLocation(request.OldLocation);
@@ -14,6 +14,13 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Provides admission-related operations and coordinates persistence, messaging, and clinical context services to manage the admission workflow.
/// </summary>
/// <remarks>
/// This service implements <see cref="IAdmissionService"/> 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.
/// </remarks>
/// <!-- aidoc:v1 sig=f8f49ce -->
public class AdmissionService(
ILogger<AdmissionService> logger,
ISubscribersService subscribersService,
@@ -51,6 +51,28 @@ public class AlarmService : IAlarmService
private TimeSpan _interval;
/// <summary>
/// Initializes a new instance of the <see cref="AlarmService"/> class, injecting required dependencies for alarm processing and optionally starting the internal alarm timer when <paramref name="startTimer"/> is <see langword="true"/>.
/// </summary>
/// <param name="alarmRepository">The <see cref="IAlarmRepository"/> used to persist and retrieve alarm data.</param>
/// <param name="logger">The <see cref="ILogger{AlarmService}"/> used for diagnostic logging.</param>
/// <param name="patientService">The <see cref="IPatientService"/> used to access patient information.</param>
/// <param name="configObservationService">The <see cref="IConfigObservationService"/> used to retrieve observation configuration.</param>
/// <param name="observationService">A <see cref="Lazy{IObservationService}"/> providing deferred access to observation data.</param>
/// <param name="clientMessageService">The <see cref="IClientMessageService"/> used to publish client notifications.</param>
/// <param name="subscribersService">The <see cref="ISubscribersService"/> used to manage alarm subscribers.</param>
/// <param name="calculatedObservationsService">A <see cref="Lazy{ICalculatedObservationsService}"/> providing deferred access to calculated observations.</param>
/// <param name="lightBeaconService">A <see cref="Lazy{ILightBeaconService}"/> providing deferred access to the light beacon service.</param>
/// <param name="recordingService">A <see cref="Lazy{IRecordingService}"/> providing deferred access to the recording service.</param>
/// <param name="relayService">A <see cref="Lazy{IRelayService}"/> providing deferred access to the relay service.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> providing access to API configuration.</param>
/// <param name="unitService">The <see cref="IUnitService"/> used to manage unit information.</param>
/// <param name="pocService">The <see cref="IPointOfCareService"/> used to access point-of-care information.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record audit entries.</param>
/// <param name="startTimer">A <see cref="bool"/> indicating whether the alarm timer should be started during construction.</param>
/// <exception cref="System.Exception">Thrown when <paramref name="apiSettings"/> is <see langword="null"/>.</exception>
/// <!-- aidoc:v1 sig=15ef9b7 body=6126462 -->
public AlarmService(IAlarmRepository alarmRepository,
ILogger<AlarmService> logger,
IPatientService patientService,
@@ -14,6 +14,13 @@ using Patient = adas_core.Domain.Models.MongoModels.Patient;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IAppointmentService"/> to coordinate appointment management operations, persisting data through <see cref="IAppointmentRepository"/> and <see cref="IAppointmentArchiveRepository"/> while integrating supporting services such as <see cref="IPatientService"/>, <see cref="IObservationService"/>, <see cref="IDiagnosisService"/>, and <see cref="IUnitService"/>.
/// </summary>
/// <remarks>
/// Defers initialization of <see cref="IPatientService"/> and <see cref="IObservationService"/> via <see cref="Lazy{T}"/>, reads configuration through <see cref="IOptions{TOptions}"/> bound to <c>ApiSettings</c> and <c>CacheSettings</c>, logs diagnostics with <see cref="ILogger{TCategoryName}"/>, and accesses the current request through <see cref="IHttpContextAccessor"/>. It also relies on <see cref="ILocalAuditService"/>, <see cref="IPointOfCareService"/>, <see cref="ISubscribersService"/>, <see cref="IClientMessageService"/>, and <see cref="ICacheService"/> to support auditing, point-of-care workflows, subscriber notifications, messaging, and caching.
/// </remarks>
/// <!-- aidoc:v1 sig=7de86ff -->
public class AppointmentService(
IAppointmentRepository appointmentRepository,
IAppointmentArchiveRepository appointmentArchiveRepository,
@@ -7,6 +7,14 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IArchivePatientCarePlanService"/> to provide the application service responsible for archiving patient care plans.
/// Collaborates with <see cref="IArchivePatientCarePlanRepository"/> for data access, <see cref="ILogger{ArchivePatientCarePlanService}"/> for diagnostics, <see cref="IHttpContextAccessor"/> for HTTP context retrieval, and <see cref="ILocalAuditService"/> for local auditing.
/// </summary>
/// <remarks>
/// The collaborators are supplied through the primary constructor, allowing the service to fulfill the contract defined by <see cref="IArchivePatientCarePlanService"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=6829647 -->
public class ArchivePatientCarePlanService(
IArchivePatientCarePlanRepository archivedPatientRepository,
ILogger<ArchivePatientCarePlanService> logger,
@@ -5,6 +5,13 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IArchivedPatientObservationService"/> to archive patient observations through the supplied <see cref="IObservationArchiveRepository"/>.
/// </summary>
/// <remarks>
/// The archive repository dependency is provided via the primary constructor and is used to perform the underlying archiving operations.
/// </remarks>
/// <!-- aidoc:v1 sig=a0ae303 -->
public class ArchivePatientObservationsService(IObservationArchiveRepository archivedPatientObservationService)
: IArchivedPatientObservationService
{
@@ -5,6 +5,10 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IArchivedPatientTreatmentService"/> and provides archived patient treatment operations using an injected <see cref="ITreatmentArchiveRepository"/>.
/// </summary>
/// <!-- aidoc:v1 sig=e336127 -->
public class ArchivedPatientTreatmentService(ITreatmentArchiveRepository archivedPatientTreatmentService)
: IArchivedPatientTreatmentService
{
@@ -24,6 +24,14 @@ public class AuthService : IAuthService
//private LoginResponse? _loginResponse;
/// <summary>
/// Initializes a new instance of the <see cref="AuthService"/> class, capturing the recording settings, logger, and authority repository required for authentication operations.
/// </summary>
/// <param name="recordingSettings">The <see cref="IOptions{RecordingSettings}"/> providing access to the configured <see cref="RecordingSettings"/>.</param>
/// <param name="logger">The <see cref="ILogger{AuthService}"/> used to log authentication activity.</param>
/// <param name="authorityRepository">The <see cref="IAuthorityRepository"/> used to access authority data.</param>
/// <exception cref="Exception">Thrown when <paramref name="recordingSettings"/>.Value is <see langword="null"/>.</exception>
/// <!-- aidoc:v1 sig=acf40f6 body=d2bb62a -->
public AuthService(IOptions<RecordingSettings> recordingSettings, ILogger<AuthService> logger,
IAuthorityRepository authorityRepository)
{
@@ -115,6 +115,16 @@ namespace adas_core.Application.Services.Caching
// GET OR SET - STRING KEY
// ============================================================
/// <summary>
/// Retrieves or creates an object asynchronously. When the cache mode is NONE, this method bypasses caching entirely and always invokes <paramref name="factory"/> to produce the result.
/// </summary>
/// <typeparam name="T">The type of the object to retrieve or create.</typeparam>
/// <param name="key">The cache key used to identify the cached object.</param>
/// <param name="factory">The asynchronous factory delegate that produces the value when no cached entry exists.</param>
/// <param name="ttl">An optional <see cref="TimeSpan"/> indicating the time-to-live for the cache entry.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param>
/// <returns>A <see cref="Task{T}"/> containing the value produced by <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=df20281 body=93d29eb -->
public async Task<T> GetOrSetObjectAsync<T>(
string key,
Func<Task<T>> factory,
@@ -145,6 +155,16 @@ namespace adas_core.Application.Services.Caching
// GET OR SET - GroupedField + patientId
// ============================================================
/// <summary>
/// Retrieves or creates an object asynchronously for the specified patient. This implementation does not perform caching and always invokes the supplied <paramref name="factory"/> to produce the result, corresponding to the disabled-cache (NONE) mode.
/// </summary>
/// <param name="groupedField">The grouped field that categorizes the object being retrieved.</param>
/// <param name="patientId">The identifier of the patient to whom the object belongs.</param>
/// <param name="factory">The asynchronous factory delegate invoked to produce the object.</param>
/// <param name="ttl">An optional time-to-live for the cached entry. Ignored because caching is disabled.</param>
/// <param name="cancellationToken">The token used to observe cancellation of the factory invocation.</param>
/// <returns>A task that yields the object produced by <paramref name="factory"/>.</returns>
/// <!-- aidoc:v1 sig=f122a12 body=93d29eb -->
public async Task<T> GetOrSetObjectAsync<T>(
GroupedField groupedField,
ObjectId patientId,
@@ -28,6 +28,13 @@ namespace adas_core.Application.Services.Caching
public IDatabase? Database => _database;
private bool _isRedisAvailable;
/// <summary>
/// Initializes a new instance of <see cref="RedisService"/>, capturing the bound <see cref="CacheSettings"/>, <see cref="ILogger{RedisService}"/>, and <see cref="LockManagerService"/> dependencies, and starting asynchronous Redis connection setup when a connection string is configured.
/// </summary>
/// <param name="options">The <see cref="IOptions{CacheSettings}"/> that exposes the bound <see cref="CacheSettings"/> whose Redis section drives connection initialization.</param>
/// <param name="logger">The <see cref="ILogger{RedisService}"/> used for diagnostic logging.</param>
/// <param name="lockManager">The <see cref="LockManagerService"/> used to coordinate distributed locks on the Redis instance.</param>
/// <!-- aidoc:v1 sig=2d613ee body=66db01c -->
public RedisService(
IOptions<CacheSettings> options,
ILogger<RedisService> logger,
@@ -17,6 +17,13 @@ public class CalculatedObservationsService : ICalculatedObservationsService
private readonly ILogger<CalculatedObservationsService>? _logger;
/// <summary>
/// Initializes a new instance of the <see cref="CalculatedObservationsService"/>, resolving the internal <see cref="ICalculatedObservations"/> implementation from the configured customization or falling back to <see cref="DefaultCalculatedObservations"/>.
/// </summary>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> providing the customization name used to locate the calculation implementation type.</param>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> supplied to the resolved customization type's constructor.</param>
/// <param name="logger">The <see cref="ILogger{CalculatedObservationsService}"/> used to log warnings when the customization cannot be resolved.</param>
/// <!-- aidoc:v1 sig=f22feaa body=18f989f -->
public CalculatedObservationsService(
IOptions<ApiSettings> apiSettings,
IServiceProvider serviceProvider,
@@ -50,6 +50,18 @@ public class ConfigObservationService : IConfigObservationService
private bool IgnoreUnknownObservation =>
_apiSettings.Value.ConfigObservation?.IgnoreUnknownObservation ?? false;
/// <summary>
/// Initializes a new instance of the <see cref="ConfigObservationService"/> class, storing its required dependencies and reading configuration values from the supplied <see cref="IOptions{TOptions}"/> instances to establish internal operational defaults such as the refresh timeout, unknown treatment handling, and retention policy.
/// </summary>
/// <param name="configObservationRepository">The <see cref="IConfigObservationRepository"/> used to access configuration observation data.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> providing API configuration values, including the refresh interval and retention policy defaults.</param>
/// <param name="cacheSettings">The <see cref="IOptions{CacheSettings}"/> providing cache configuration values.</param>
/// <param name="logger">The <see cref="ILogger{ConfigObservationService}"/> used for diagnostic logging.</param>
/// <param name="unitService">The <see cref="IUnitService"/> used to perform unit-related operations.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record local audit entries.</param>
/// <param name="cacheService">The <see cref="ICacheService"/> used for caching operations.</param>
/// <!-- aidoc:v1 sig=85a9f25 body=f5101e8 -->
public ConfigObservationService(
IConfigObservationRepository configObservationRepository,
IOptions<ApiSettings> apiSettings,
@@ -12,6 +12,14 @@ using Microsoft.Extensions.Options;
namespace adas_core.Application.Services;
/// <summary>
/// Implements the <see cref="IConfigPumpsService"/> contract to manage configuration operations for pumps.
/// </summary>
/// <remarks>
/// This service relies on an <see cref="IConfigPumpsRepository"/> for data access, an <see cref="IOptions{ApiSettings}"/> for API configuration,
/// an <see cref="ILogger{ConfigPumpsService}"/> for diagnostics, an <see cref="IHttpContextAccessor"/> for HTTP context retrieval, and an <see cref="ILocalAuditService"/> for auditing operations.
/// </remarks>
/// <!-- aidoc:v1 sig=abae5d0 -->
public class ConfigPumpsService(
IConfigPumpsRepository configPumpsRepository,
IOptions<ApiSettings> apiSettings,
@@ -10,6 +10,13 @@ using Microsoft.Extensions.Options;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IConfigUnitsService"/> to manage configuration units,
/// using <paramref name="configUnitsRepository"/> for data persistence,
/// <paramref name="apiSettings"/> for API configuration values,
/// and <paramref name="logger"/> for diagnostic logging.
/// </summary>
/// <!-- aidoc:v1 sig=cc78d0f -->
public class ConfigUnitsService(
IConfigUnitsRepository configUnitsRepository,
IOptions<ApiSettings> apiSettings,
@@ -22,6 +22,16 @@ public class DeviceService : IDeviceService
private readonly IPointOfCareService _pointOfCareService;
private readonly ILogger<DeviceService> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="DeviceService"/> class, injecting the required collaborators used to manage device-related domain operations.
/// </summary>
/// <param name="deviceRepository">The <see cref="IDeviceRepository"/> that provides persistence access for devices.</param>
/// <param name="pointOfCareService">The <see cref="IPointOfCareService"/> used to coordinate point-of-care operations.</param>
/// <param name="logger">The <see cref="ILogger{DeviceService}"/> used to emit diagnostic and operational logs.</param>
/// <param name="observationService">The <see cref="IObservationService"/> used to record and query observations.</param>
/// <param name="configObservationService">The <see cref="IConfigObservationService"/> used to manage configured observation rules.</param>
/// <param name="alarmService">The <see cref="IAlarmService"/> used to raise and resolve alarms.</param>
/// <!-- aidoc:v1 sig=ec3ca5b body=22d30a4 -->
public DeviceService(
IDeviceRepository deviceRepository,
IPointOfCareService pointOfCareService,
@@ -37,6 +37,21 @@ public class DiagnosisService : IDiagnosisService
private readonly IUnitService _unitService;
/// <summary>
/// Initializes a new instance of the <see cref="DiagnosisService"/>, 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 <paramref name="apiSettings"/>.
/// </summary>
/// <param name="patientService">A <see cref="Lazy{T}"/> that resolves an <see cref="IPatientService"/> for patient lookups.</param>
/// <param name="apiSettings">The <see cref="IOptions{TOptions}"/> of <see cref="ApiSettings"/> providing configuration such as the diagnosis system and diagnosis codes.</param>
/// <param name="diagnosisRepository">The <see cref="IDiagnosisRepository"/> used to read and persist diagnoses.</param>
/// <param name="diagnosisArchiveRepository">The <see cref="IDiagnosisArchiveRepository"/> used to read and persist archived diagnoses.</param>
/// <param name="logger">The <see cref="ILogger{TCategoryName}"/> used to record diagnostic information.</param>
/// <param name="clientMessageService">The <see cref="IClientMessageService"/> used to deliver messages to clients.</param>
/// <param name="subscribersService">The <see cref="ISubscribersService"/> used to notify subscribers of diagnosis events.</param>
/// <param name="calculatedObservations">A <see cref="Lazy{T}"/> that resolves an <see cref="ICalculatedObservationsService"/> for derived observations.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> providing access to the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record local audit entries.</param>
/// <param name="unitService">The <see cref="IUnitService"/> used to manage measurement units.</param>
/// <!-- aidoc:v1 sig=ff6d776 body=0fbbf26 -->
public DiagnosisService(
Lazy<IPatientService> patientService,
IOptions<ApiSettings> apiSettings,
@@ -35,6 +35,20 @@ public class DischargeService : IDischargeService
private readonly ISubscribersService _subscribersService;
private readonly IUnitService _unitService;
/// <summary>
/// Initializes a new instance of the <see cref="DischargeService"/> 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.
/// </summary>
/// <param name="logger">The <see cref="ILogger{TCategoryName}"/> used to record diagnostic information for the <see cref="DischargeService"/>.</param>
/// <param name="subscribersService">The <see cref="ISubscribersService"/> used to manage subscribers tied to discharge events.</param>
/// <param name="dischargeRepository">The <see cref="IDischargeRepository"/> used to persist and retrieve discharge records.</param>
/// <param name="patientServiceLazy">The <see cref="Lazy{T}"/> wrapping <see cref="IPatientService"/> to defer patient service resolution.</param>
/// <param name="clientMessageService">The <see cref="IClientMessageService"/> used to send client-facing messages.</param>
/// <param name="pointOfCareService">The <see cref="IPointOfCareService"/> used to interact with point-of-care operations.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record local audit entries.</param>
/// <param name="unitService">The <see cref="IUnitService"/> used to look up unit-related information.</param>
/// <param name="masterListServiceFactory">The <see cref="IMasterListServiceFactory"/> used to create master list services on demand.</param>
/// <!-- aidoc:v1 sig=5a98484 body=4f2b947 -->
public DischargeService(ILogger<DischargeService> logger,
ISubscribersService subscribersService,
IDischargeRepository dischargeRepository,
@@ -281,6 +295,11 @@ public class DischargeService : IDischargeService
}
/// <summary>
/// Processes an <see cref="ApiRequest"/> for patient discharge operations. Based on <paramref name="apiRequest"/>.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.
/// </summary>
/// <param name="apiRequest">The API request containing the discharge payload and the operation type to perform.</param>
/// <!-- aidoc:v1 sig=229d8cd body=acbd395 -->
public async Task SaveRequest(ApiRequest apiRequest)
{
try
@@ -18,6 +18,13 @@ using DisplayConfig = adas_core.Domain.Models.MongoModels.DisplayConfig;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IDisplayConfigService"/> to coordinate display configuration operations across multiple repositories and supporting services.
/// </summary>
/// <remarks>
/// 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 <see cref="IHttpContextAccessor"/> for accessing the current HTTP context and uses <see cref="Lazy{T}"/> of <see cref="IDisplayService"/> to defer initialization of the display service dependency.
/// </remarks>
/// <!-- aidoc:v1 sig=f2c684c -->
public class DisplayConfigService(
IDisplayConfigRepository displayConfigRepository,
Lazy<IDisplayService> displayService,
@@ -19,6 +19,13 @@ using MongoDB.Driver;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IDisplayService"/>, coordinating display management operations
/// across data access (<see cref="IDisplayRepository"/>), configuration (<see cref="IDisplayConfigService"/>),
/// authentication (<see cref="IAuthService"/>), audit (<see cref="ILocalAuditService"/>),
/// and caching (<see cref="ICacheService"/>) concerns.
/// </summary>
/// <!-- aidoc:v1 sig=010754e -->
public class DisplayService(
IDisplayRepository displayRepository,
IPointOfCareService pointOfCareService,
@@ -21,6 +21,12 @@ public class FileService : IFileService
private readonly ILogger<FileService> _logger;
private readonly string? _updateDirectory;
/// <summary>
/// Initializes a new instance of the <see cref="FileService"/> class, configuring the file system paths used to read update files and display assets and storing the logger used for diagnostic output. <see cref="FileService"/> provides file-related operations backed by the supplied configuration.
/// </summary>
/// <param name="apiSettings">The bound application settings exposed via <see cref="IOptions{ApiSettings}"/>; supplies the <see cref="ApiSettings.PathUpdateFiles"/> and <see cref="ApiSettings.PathToDisplayAssets"/> paths used to build the working directories.</param>
/// <param name="logger">The <see cref="ILogger{FileService}"/> retained for recording diagnostic and operational events.</param>
/// <!-- aidoc:v1 sig=715c341 body=f27c630 -->
public FileService(
IOptions<ApiSettings> apiSettings,
ILogger<FileService> logger
@@ -25,6 +25,16 @@ public class GroupedObservationService : IGroupedObservationService
private readonly ILogger<GroupedObservationService> _logger;
private readonly IObservationRepository _observationRepository;
/// <summary>
/// Initializes a new instance of the <see cref="GroupedObservationService"/>, which coordinates the retrieval, configuration, caching, and logging of grouped observation data, by capturing the supplied dependencies.
/// </summary>
/// <param name="observationRepository">The <see cref="IObservationRepository"/> used to access underlying observation records.</param>
/// <param name="configObservationService">The <see cref="IConfigObservationService"/> used to resolve observation configuration.</param>
/// <param name="logger">The <see cref="ILogger{GroupedObservationService}"/> used to record diagnostic and operational messages.</param>
/// <param name="cacheService">The <see cref="ICacheService"/> used to read from and write to the application cache.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> providing configurable API options.</param>
/// <param name="cacheSettings">The <see cref="IOptions{CacheSettings}"/> whose <see cref="IOptions{TOptions}.Value"/> is stored as the resolved cache configuration.</param>
/// <!-- aidoc:v1 sig=3ffcb4f body=0e26b9d -->
public GroupedObservationService(
IObservationRepository observationRepository,
IConfigObservationService configObservationService,
@@ -10,6 +10,13 @@ using MongoDB.Driver;
namespace adas_core.Application.Services;
/// <summary>
/// Provides operations for retrieving and managing historical configuration changes, delegating data access to an <see cref="IHistoricalConfigChangesRepository"/> and coordinating logging, HTTP context, and auditing concerns.
/// </summary>
/// <remarks>
/// Implements <see cref="IHistoricalConfigChangesService"/> and uses <paramref name="historicalConfigChangesRepository"/> for persistence, <paramref name="logger"/> for diagnostics, <paramref name="httpContextAccessor"/> for request context, and <paramref name="auditService"/> to record local audit entries.
/// </remarks>
/// <!-- aidoc:v1 sig=757183c -->
public class HistoricalConfigChangesService(
IHistoricalConfigChangesRepository historicalConfigChangesRepository,
ILogger<HistoricalConfigChangesService> logger,
@@ -5,6 +5,10 @@ using Microsoft.Extensions.Logging;
namespace adas_core.Application.Services;
/// <summary>
/// Implements the local auditing behavior defined by <see cref="ILocalAuditService"/>, forwarding audit operations to an inner <see cref="IAuditService"/> and recording diagnostic information via an <see cref="ILogger{LocalAuditService}"/>.
/// </summary>
/// <!-- aidoc:v1 sig=e6cdfbf -->
public class LocalAuditService(
IAuditService auditService,
ILogger<LocalAuditService> logger)
@@ -38,6 +38,22 @@ public class MasterListService<T> : IMasterListService<T> where T : MasterList,
private readonly ISubscribersService _subscribersService;
private readonly Lazy<IUnitService> _unitService;
/// <summary>
/// Initializes a new instance of <see cref="MasterListService{T}"/>, a service that coordinates display, patient, unit, admission, discharge, subscriber and client messaging operations. The constructor stores the injected collaborators and, when <paramref name="apiSettings"/> specifies a display assets path, computes the assets directory via <see cref="Path.Combine(System.String[])"/>.
/// </summary>
/// <param name="logger">The <see cref="ILogger{T}"/> used by the service to emit diagnostic messages.</param>
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> used to resolve additional services at runtime.</param>
/// <param name="clientMessageService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IClientMessageService"/> until it is first accessed.</param>
/// <param name="subscribersService">The <see cref="ISubscribersService"/> used to manage subscribers.</param>
/// <param name="unitService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IUnitService"/> until it is first accessed.</param>
/// <param name="displayService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IDisplayService"/> until it is first accessed.</param>
/// <param name="patientService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IPatientService"/> until it is first accessed.</param>
/// <param name="dischargeService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IDischargeService"/> until it is first accessed.</param>
/// <param name="admissionService">A <see cref="Lazy{T}"/> that defers creation of the <see cref="IAdmissionService"/> until it is first accessed.</param>
/// <param name="apiSettings">The <see cref="IOptions{T}"/> providing access to the configured <see cref="ApiSettings"/>; its <see cref="ApiSettings.PathToDisplayAssets"/> property initializes the assets directory when not null.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record audit entries.</param>
/// <!-- aidoc:v1 sig=2960814 body=4451a9b -->
public MasterListService(
ILogger<MasterListService<T>> logger,
IServiceProvider serviceProvider,
@@ -11,6 +11,13 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Factory class responsible for creating instances of master list services based on the supplied <see cref="ListSettings"/>.
/// </summary>
/// <remarks>
/// Implements <see cref="IMasterListServiceFactory"/> and uses <see cref="IServiceProvider"/> for dependency resolution along with <see cref="ILogger{MasterListServiceFactory}"/> for diagnostic logging.
/// </remarks>
/// <!-- aidoc:v1 sig=fefed1b -->
public class MasterListServiceFactory(
IServiceProvider serviceProvider,
ILogger<MasterListServiceFactory> logger,
@@ -14,6 +14,13 @@ using MongoDB.Driver;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IMedicineService"/> and provides the application service responsible for medicine-related operations, coordinating <see cref="IMedicineRepository"/> and <see cref="ITreatmentService"/>.
/// </summary>
/// <remarks>
/// Configured via <see cref="IOptions{ApiSettings}"/>, instrumented with <see cref="ILogger{MedicineService}"/>, supplied with the current HTTP context through <see cref="IHttpContextAccessor"/>, and audited by <see cref="ILocalAuditService"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=34a02a6 -->
public class MedicineService(
IMedicineRepository medicineRepository,
ITreatmentService treatmentService,
@@ -10,6 +10,17 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="INoticeService"/>, providing the coordination logic for managing
/// notices and delivering them through the configured subscriber, messaging, display, and audit subsystems.
/// </summary>
/// <remarks>
/// Instances are created through a primary constructor that receives <see cref="ILogger{NoticeService}"/>,
/// <see cref="ISubscribersService"/>, <see cref="INoticeRepository"/>, <see cref="IClientMessageService"/>,
/// <see cref="IDisplayService"/>, <see cref="IHttpContextAccessor"/>, and <see cref="ILocalAuditService"/>
/// as injected collaborators.
/// </remarks>
/// <!-- aidoc:v1 sig=3ccc883 -->
public class NoticeService(
ILogger<NoticeService> logger,
ISubscribersService subscribersService,
@@ -8,6 +8,13 @@ using adas_core.Domain.Utils;
namespace adas_core.Application.Services;
/// <summary>
/// Provides a demo implementation of <see cref="IObservationDemoService"/> that coordinates observation handling using <see cref="IConfigObservationService"/> for configuration and a <see cref="Lazy{T}"/> of <see cref="IAlarmService"/> for deferred alarm access.
/// </summary>
/// <remarks>
/// The service is constructed with an <see cref="IConfigObservationService"/> for observation configuration and a lazily-initialized <see cref="IAlarmService"/> so that alarm functionality is created only on first use.
/// </remarks>
/// <!-- aidoc:v1 sig=fc27ac9 -->
public class ObservationDemoService(
IConfigObservationService configObservationService,
Lazy<IAlarmService> alarmService)
@@ -74,6 +74,33 @@ public class ObservationService : IObservationService
private readonly ISubscribersService _subscribersService;
/// <summary>
/// Initializes a new instance of the <see cref="ObservationService"/> class, storing the supplied collaborators in private fields and loading observation-code and cache configuration from the provided options.
/// </summary>
/// <param name="patientService">Provides access to patient data.</param>
/// <param name="configObservationService">Provides observation configuration values.</param>
/// <param name="observationRepository">Persists and retrieves observations.</param>
/// <param name="observationArchiveRepository">Accesses archived observations.</param>
/// <param name="configUnitsService">Provides unit configuration.</param>
/// <param name="diagnosisService">Performs diagnosis-related operations.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> whose values seed the observation code settings.</param>
/// <param name="cacheSettings">The <see cref="IOptions{CacheSettings}"/> whose values configure caching behavior.</param>
/// <param name="lightBeaconService">Controls light beacon devices.</param>
/// <param name="relayService">Operates relay hardware.</param>
/// <param name="recordingService">Manages recordings.</param>
/// <param name="logger">Logs <see cref="ObservationService"/> activity.</param>
/// <param name="groupedObservationService">Handles grouped observation logic.</param>
/// <param name="alarmService">Raises and manages alarms.</param>
/// <param name="clientMessageService">Publishes messages to clients.</param>
/// <param name="subscribersService">Tracks observation subscribers.</param>
/// <param name="subscriberGroupedService">Manages grouped observation subscribers.</param>
/// <param name="calculatedObservationsService">Defers creation of the calculated observations dependency.</param>
/// <param name="httpContextAccessor">Exposes the current HTTP context.</param>
/// <param name="auditService">Writes local audit entries.</param>
/// <param name="pointOfCareService">Handles point-of-care operations.</param>
/// <param name="cacheService">Reads from and writes to the cache.</param>
/// <exception cref="Exception">Thrown when <paramref name="apiSettings"/> is null.</exception>
/// <!-- aidoc:v1 sig=50945c1 body=e153242 -->
public ObservationService(
IPatientService patientService,
IConfigObservationService configObservationService,
@@ -22,6 +22,16 @@ public class PatientCarePlanService : IPatientCarePlanService
private readonly IPatientCarePlanRepository _patientCarePlanRepository;
private readonly IUserRepository _userRepository;
/// <summary>
/// Initializes a new instance of the <see cref="PatientCarePlanService"/> class, wiring in the dependencies required to manage, archive, and audit patient care plans.
/// </summary>
/// <param name="logger">The <see cref="ILogger{PatientCarePlanService}"/> used to record operational and diagnostic information.</param>
/// <param name="patientCarePlanRepository">The <see cref="IPatientCarePlanRepository"/> used to access patient care plan data.</param>
/// <param name="userRepository">The <see cref="IUserRepository"/> used to access user information.</param>
/// <param name="archivePatientCarePlanService">The <see cref="IArchivePatientCarePlanService"/> used to archive patient care plans.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record local audit information.</param>
/// <!-- aidoc:v1 sig=8f3d58d body=0a1cfb1 -->
public PatientCarePlanService(
ILogger<PatientCarePlanService> logger,
IPatientCarePlanRepository patientCarePlanRepository,
@@ -70,6 +70,36 @@ public class PatientService : IPatientService
private readonly bool _updatePatientDataWithOru;
private readonly bool _updatePatientLocationWithOru;
/// <summary>
/// Initializes a new instance of the <see cref="PatientService"/> class, storing its required repositories, services and helpers, and reading configuration values from <see cref="ApiSettings"/> and <see cref="ListSettings"/>.
/// </summary>
/// <param name="patientRepository">The <see cref="IPatientRepository"/> used to access patient data.</param>
/// <param name="patientArchiveRepository">The <see cref="IPatientArchiveRepository"/> used to access archived patient data.</param>
/// <param name="observationService">The lazily resolved <see cref="Lazy{IObservationService}"/> providing observation operations.</param>
/// <param name="treatmentService">The lazily resolved <see cref="Lazy{ITreatmentService}"/> providing treatment operations.</param>
/// <param name="pocMappingService">The <see cref="IPoCMappingService"/> used for point-of-care mappings.</param>
/// <param name="diagnosisService">The <see cref="IDiagnosisService"/> used to manage diagnoses.</param>
/// <param name="appointmentService">The <see cref="IAppointmentService"/> used to manage appointments.</param>
/// <param name="pumpService">The lazily resolved <see cref="Lazy{IPumpService}"/> providing pump operations.</param>
/// <param name="recordingAlertService">The <see cref="IRecordingAlertService"/> used to handle recording alerts.</param>
/// <param name="dischargeService">The <see cref="IDischargeService"/> used to manage discharges.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> exposing archive and HL7 related configuration values.</param>
/// <param name="listSettings">The <see cref="IOptions{ListSettings}"/> exposing list related configuration values.</param>
/// <param name="logger">The <see cref="ILogger{PatientService}"/> used to log diagnostics.</param>
/// <param name="clientMessageService">The <see cref="IClientMessageService"/> used to send client messages.</param>
/// <param name="subscribersService">The <see cref="ISubscribersService"/> used to manage subscribers.</param>
/// <param name="subscriberGroupedService">The <see cref="ISubscriberGroupedService}"/> used to manage grouped subscribers.</param>
/// <param name="unitService">The <see cref="IUnitService"/> used to manage units.</param>
/// <param name="displayService">The <see cref="IDisplayService"/> used to manage displays.</param>
/// <param name="pointOfCareService">The <see cref="IPointOfCareService"/> used to manage point-of-care data.</param>
/// <param name="admissionService">The lazily resolved <see cref="Lazy{IAdmissionService}"/> providing admission operations.</param>
/// <param name="displayConfigService">The <see cref="IDisplayConfigService"/> used to manage display configuration.</param>
/// <param name="groupedObservationService">The <see cref="IGroupedObservationService"/> used to manage grouped observations.</param>
/// <param name="patientCarePlanService">The <see cref="IPatientCarePlanService"/> used to manage patient care plans.</param>
/// <param name="httpContextAccessor">The <see cref="IHttpContextAccessor"/> used to access the current HTTP context.</param>
/// <param name="auditService">The <see cref="ILocalAuditService"/> used to record local audit entries.</param>
/// <param name="masterListServiceFactory">The <see cref="IMasterListServiceFactory}"/> used to create master list services.</param>
/// <!-- aidoc:v1 sig=1949cfe body=98328ad -->
public PatientService(
IPatientRepository patientRepository,
IPatientArchiveRepository patientArchiveRepository,
@@ -10,6 +10,11 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IPermissionService"/> to evaluate user permissions from the configured <see cref="PermissionSettings"/> and the available authority data stores.
/// Resolves <see cref="IDisplayService"/>, <see cref="IUserRepository"/>, and <see cref="IAuthorityRepository"/> through <see cref="Lazy{T}"/> so their construction is deferred until needed.
/// </summary>
/// <!-- aidoc:v1 sig=62dd81d -->
public class PermissionService(
IOptions<PermissionSettings> permissionsConfig,
ILogger<PermissionService> logger,
@@ -21,6 +21,12 @@ public class PoCMappingService : IPoCMappingService
private PoCMapping? _mapping;
private DateTime _nextRefresh = DateTime.MinValue;
/// <summary>
/// Initializes a new instance of the <see cref="PoCMappingService"/> class, storing the supplied repository and capturing point-of-care mapping configuration values from <paramref name="apiSettings"/>.
/// </summary>
/// <param name="pocMappingRepository">The <see cref="IPoCMappingRepository"/> used by the service to access mapping data.</param>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> providing access to the point-of-care mapping settings.</param>
/// <!-- aidoc:v1 sig=3865e0c body=4a11e38 -->
public PoCMappingService(IPoCMappingRepository pocMappingRepository, IOptions<ApiSettings> apiSettings)
{
_pocMappingRepository = pocMappingRepository;
@@ -17,6 +17,20 @@ using MongoDB.Driver;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IPointOfCareService"/> to provide point-of-care business logic that
/// coordinates persistence, patient, unit, admission, messaging, audit, and caching concerns
/// through its injected collaborators.
/// </summary>
/// <remarks>
/// The service uses <see cref="IPointOfCareRepository"/> for data access and <see cref="ILogger{T}"/>
/// for logging. <see cref="IPatientService"/>, <see cref="IUnitService"/>,
/// <see cref="IClientMessageService"/>, and <see cref="IAdmissionService"/> are resolved lazily
/// via <see cref="Lazy{T}"/>. Additional collaborators include <see cref="ISubscribersService"/>,
/// <see cref="ILocalAuditService"/>, <see cref="ICacheService"/>, <see cref="IHttpContextAccessor"/>,
/// and <see cref="IOptions{TOptions}"/> bound to CacheSettings.
/// </remarks>
/// <!-- aidoc:v1 sig=0a9722c -->
public class PointOfCareService(
ILogger<PointOfCareService> logger,
IPointOfCareRepository pointOfCareRepository,
@@ -10,6 +10,13 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IRecordingAlertService"/> to manage recording alerts, coordinating patient lookup, observation configuration, alert persistence, client messaging, subscribers, auditing, and HTTP context access.
/// </summary>
/// <remarks>
/// Uses <see cref="IRecordingAlertRepository"/> and <see cref="IRecordingAlertArchiveRepository"/> for alert persistence, and lazily resolves <see cref="IPatientService"/> through <paramref name="patientService"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=6c23cec -->
public class RecordingAlertService(
Lazy<IPatientService> patientService,
IConfigObservationService configObservationService,
@@ -38,6 +38,21 @@ public class RecordingService : IRecordingService
private AccessGrant? _accessGrant;
/// <summary>
/// Initializes a new instance of the <see cref="RecordingService"/> class, resolving configuration options and service dependencies required to coordinate recording operations over HTTP and RabbitMQ.
/// </summary>
/// <param name="rabbitMqSettings">The RabbitMQ configuration options used to derive the recording queue name from <see cref="RabbitMqSettings.RecordingQueue"/>.</param>
/// <param name="recordingSettings">The recording configuration options providing the API URL and HTTP client timeout; must be supplied.</param>
/// <param name="logger">The logger used to record diagnostic information.</param>
/// <param name="httpClientFactory">The factory used to create the underlying <see cref="HttpClient"/>.</param>
/// <param name="publisherService">The service used to publish messages.</param>
/// <param name="authService">The authentication service used to obtain access grants.</param>
/// <param name="apiSettings">The API configuration options; provides the <see cref="ApiSettings.StartRecordingWithoutPatientNumber"/> flag.</param>
/// <param name="clientMessageService">The service used to handle client messages.</param>
/// <param name="subscribersService">The service used to manage subscribers.</param>
/// <param name="patientService">The lazily resolved patient service used to look up patient information.</param>
/// <exception cref="Exception">Thrown when <paramref name="recordingSettings"/> does not provide a value.</exception>
/// <!-- aidoc:v1 sig=7f5a5e7 body=7787634 -->
public RecordingService(IOptions<RabbitMqSettings> rabbitMqSettings,
IOptions<RecordingSettings> recordingSettings,
ILogger<RecordingService> logger,
@@ -8,6 +8,13 @@ using MongoDB.Bson;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IServiceConfigService"/>, coordinating service configuration operations by persisting data through <see cref="IServiceConfigRepository"/> and emitting diagnostics via <see cref="ILogger{ServiceConfigService}"/>.
/// </summary>
/// <remarks>
/// The class receives its <see cref="IServiceConfigRepository"/> collaborator and <see cref="ILogger{ServiceConfigService}"/> via the primary constructor parameters <paramref name="serviceConfigRepository"/> and <paramref name="logger"/>.
/// </remarks>
/// <!-- aidoc:v1 sig=8c82e54 -->
public class ServiceConfigService(
IServiceConfigRepository serviceConfigRepository,
ILogger<ServiceConfigService> logger)
@@ -16,6 +16,13 @@ using Serilog;
namespace adas_core.Application.Services;
/// <summary>
/// Implements <see cref="IUnitService"/>, coordinating unit-related operations by persisting data through <see cref="IUnitRepository"/> and integrating with patient, master list, subscriber, client messaging, point-of-care, and auditing services.
/// </summary>
/// <remarks>
/// Collaborators exposed as <see cref="Lazy{T}"/> (<see cref="IPatientService"/> and <see cref="IClientMessageService"/>) are instantiated on demand. The service uses <see cref="ILogger{T}"/> for structured logging, <see cref="IHttpContextAccessor"/> to access the current HTTP context, and <see cref="ILocalAuditService"/> to record audit entries.
/// </remarks>
/// <!-- aidoc:v1 sig=690f007 -->
public class UnitService(
IUnitRepository unitRepository,
Lazy<IPatientService> patientService,