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
@@ -17,6 +17,12 @@ public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IPumpAl
{
private readonly ApiSettings _apiSettings;
/// <summary>
/// Initializes a new instance of the <see cref="PumpAlarmEventRepository"/> repository, capturing the configured <see cref="ApiSettings"/> from <paramref name="apiSettings"/> and forwarding <paramref name="database"/> to the base repository for persistence operations.
/// </summary>
/// <param name="apiSettings">The <see cref="IOptions{ApiSettings}"/> wrapper that exposes the application's <see cref="ApiSettings"/>.</param>
/// <param name="database">The <see cref="IMongoDatabase"/> passed to the base constructor and used to perform MongoDB operations.</param>
/// <!-- aidoc:v1 sig=cfddddb body=12fddac -->
public PumpAlarmEventRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
: base(database)
{
@@ -25,11 +31,20 @@ public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IPumpAl
/// <summary>
/// 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".
/// </summary>
/// <returns>The configured pump alarm event collection name, or the default "pump_alarm_event" when no configuration value is available.</returns>
/// <!-- aidoc:v1 sig=94e22ff body=9e4a133 -->
public override string GetCollectionName()
{
return _apiSettings.PumpAlarmEvent ?? "pump_alarm_event";
}
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=4955da2 body=fae571b -->
public override async Task CreateIndexes()
{
var indexModels = new List<CreateIndexModel<PumpAlarmEvent>>
@@ -63,6 +78,11 @@ public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IPumpAl
}
/// <summary>
/// Asynchronously inserts a new <see cref="PumpAlarmEvent"/> document into the underlying MongoDB collection.
/// </summary>
/// <param name="alarmEvent">The <see cref="PumpAlarmEvent"/> record to persist.</param>
/// <!-- aidoc:v1 sig=5de5fec body=d69d42c -->
public async Task InsertAsync(PumpAlarmEvent alarmEvent)
{
await Collection.InsertOneAsync(alarmEvent);
@@ -85,6 +105,12 @@ public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IPumpAl
return await find.ToListAsync();
}
/// <summary>
/// Asynchronously retrieves the most recent <see cref="PumpAlarmEvent"/> for the device identified by <paramref name="deviceId"/>, returning the entry with the latest time stamp, or <c>null</c> if no event exists.
/// </summary>
/// <param name="deviceId">The identifier of the device whose latest alarm event is being retrieved.</param>
/// <returns>A <see cref="Task{PumpAlarmEvent}"/> that yields the latest <see cref="PumpAlarmEvent"/> associated with <paramref name="deviceId"/>, or <c>null</c> if no matching event is found.</returns>
/// <!-- aidoc:v1 sig=f0fbfb3 body=088b34a -->
public async Task<PumpAlarmEvent?> FindLastByDeviceIdAsync(string deviceId)
{
return await Collection
@@ -93,12 +119,25 @@ public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IPumpAl
.FirstOrDefaultAsync();
}
/// <summary>
/// Asynchronously removes all documents linked to the specified patient by deleting every record whose PatientId matches the supplied <paramref name="patientId"/>.
/// </summary>
/// <param name="patientId">The <see cref="ObjectId"/> of the patient whose associated documents should be deleted.</param>
/// <!-- aidoc:v1 sig=4776e51 body=395df12 -->
public async Task DeleteByPatientId(ObjectId patientId)
{
await Collection.DeleteManyAsync(x => x.PatientId == patientId);
}
/// <summary>
/// Asynchronously updates the value of the specified field across multiple <see cref="PumpAlarmEvent"/> documents, replacing occurrences of <paramref name="oldId"/> with <paramref name="newId"/>, and returns the number of documents that were modified.
/// </summary>
/// <param name="fieldName">The name of the <see cref="MongoDB.Bson.ObjectId"/> field on <see cref="PumpAlarmEvent"/> whose value should be replaced.</param>
/// <param name="newId">The new <see cref="MongoDB.Bson.ObjectId"/> value to assign to the field in matching documents.</param>
/// <param name="oldId">The existing <see cref="MongoDB.Bson.ObjectId"/> value used to identify documents to be updated.</param>
/// <returns>The number of <see cref="PumpAlarmEvent"/> documents modified by the bulk update.</returns>
/// <!-- aidoc:v1 sig=207e960 body=64489e6 -->
public async Task<long> UpdateManyObjectIdByFiledNameAsync(string fieldName, ObjectId newId, ObjectId oldId)
{
var filter = Builders<PumpAlarmEvent>.Filter.Eq(fieldName, oldId);