=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -14,6 +14,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// <summary>
|
||||
/// Represents a MongoDB-backed repository for <see cref="PatientTreatment"/> entities, inheriting common data access functionality from <see cref="MongoRepository{T}"/> and implementing the <see cref="ITreatmentRepository"/> contract.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ff348dc -->
|
||||
public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatmentRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
@@ -37,6 +38,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// Retrieves the collection name for patients treatments, using the value configured in API settings or falling back to the default "patients_treatments" when the setting is not specified.
|
||||
/// </summary>
|
||||
/// <returns>The configured patients treatments collection name, or "patients_treatments" if no setting is defined.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=9f934d7 -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.PatientsTreatments ?? "patients_treatments";
|
||||
@@ -47,6 +49,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose treatments are being queried.</param>
|
||||
/// <returns>A collection of <see cref="PatientTreatment"/> records matching the specified patient identifier.</returns>
|
||||
/// <!-- aidoc:v1 sig=378ba8a body=7965a74 -->
|
||||
public async Task<IEnumerable<PatientTreatment>> GetByPatientId(ObjectId patientId)
|
||||
{
|
||||
var filter = Builders<PatientTreatment>.Filter.Eq(ob => ob.PatientId, patientId);
|
||||
@@ -59,6 +62,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient treatment to locate.</param>
|
||||
/// <returns>An asynchronous cursor containing the patient treatment matching the provided identifier.</returns>
|
||||
/// <!-- aidoc:v1 sig=9df111b body=2d38c53 -->
|
||||
public async Task<IAsyncCursor<PatientTreatment>> GetById(ObjectId id)
|
||||
{
|
||||
var filter = Builders<PatientTreatment>.Filter.Eq(ob => ob.Id, id);
|
||||
@@ -70,6 +74,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// Inserts a patient treatment record, defaulting the order time to the current UTC time when it is not already set.
|
||||
/// </summary>
|
||||
/// <param name="treatment">The patient treatment to insert.</param>
|
||||
/// <!-- aidoc:v1 sig=e510e9e body=e2feaed -->
|
||||
public override async Task InsertOneAsync(PatientTreatment treatment)
|
||||
{
|
||||
treatment.OrderTime ??= DateTime.UtcNow;
|
||||
@@ -80,6 +85,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// Deletes a patient treatment record from the database by its unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient treatment to remove.</param>
|
||||
/// <!-- aidoc:v1 sig=78c6c5d body=ffccab9 -->
|
||||
public new async Task DeleteAsync(ObjectId id)
|
||||
{
|
||||
var filter = Builders<PatientTreatment>.Filter.Eq(ob => ob.Id, id);
|
||||
@@ -92,6 +98,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique ObjectId of the patient whose treatment records should be returned.</param>
|
||||
/// <returns>An <see cref="IAsyncCursor{TDocument}"/> of <see cref="PatientTreatment"/> containing the matching treatment records.</returns>
|
||||
/// <!-- aidoc:v1 sig=2560a5d body=b55629b -->
|
||||
public async Task<IAsyncCursor<PatientTreatment>> FindByPatientIdAsync(ObjectId patientId)
|
||||
{
|
||||
var filter = Builders<PatientTreatment>.Filter.Eq(ob => ob.PatientId, patientId);
|
||||
@@ -105,6 +112,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="patientId">The identifier of the patient whose treatment records should be removed.</param>
|
||||
/// <returns>A task that resolves to <c>true</c> on successful deletion, or <c>false</c> if the operation failed due to an exception.</returns>
|
||||
/// <!-- aidoc:v1 sig=792a636 body=a3d746d -->
|
||||
public async Task<bool> DeleteByPatientId(ObjectId patientId)
|
||||
{
|
||||
try
|
||||
@@ -126,6 +134,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="treatment">The patient treatment entity containing the updated information, identified by its <c>Id</c>.</param>
|
||||
/// <returns><c>true</c> if the update succeeds; otherwise, <c>false</c> if an exception occurs during the operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=c17e7d4 body=21b1397 -->
|
||||
public async Task<bool> Update(PatientTreatment treatment)
|
||||
{
|
||||
try
|
||||
@@ -145,6 +154,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose bolus treatments are being queried.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of <see cref="PatientTreatment"/> documents matching the patient and having a non-empty <c>RequestedGiveCodesStatus</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=cf3ed2a body=b450746 -->
|
||||
public async Task<List<PatientTreatment>> FindBolusTreatments(ObjectId patientId)
|
||||
{
|
||||
var builder = Builders<PatientTreatment>.Filter;
|
||||
@@ -166,6 +176,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// <param name="patientId">The identifier of the patient whose treatments will be searched.</param>
|
||||
/// <param name="order">The entity identifier of the placer order used to match treatments.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the list of matching <see cref="PatientTreatment"/> entries.</returns>
|
||||
/// <!-- aidoc:v1 sig=3821694 body=b830b97 -->
|
||||
public async Task<List<PatientTreatment>> GetActiveTreatmentsByPatientIdAndOrder(ObjectId patientId, string order)
|
||||
{
|
||||
var builder = Builders<PatientTreatment>.Filter;
|
||||
@@ -193,6 +204,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// <param name="nameId">The name of the field or relationship whose object identifier should be updated.</param>
|
||||
/// <param name="id">The new object identifier to replace the old one with.</param>
|
||||
/// <param name="oldId">The existing object identifier that should be replaced.</param>
|
||||
/// <!-- aidoc:v1 sig=72ce1ca body=b9b81e9 -->
|
||||
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
|
||||
{
|
||||
await UpdateManyObjectIdAsync(nameId, id, oldId);
|
||||
@@ -203,6 +215,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique <see cref="ObjectId"/> of the patient whose treatments are being queried.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing an <see cref="IEnumerable{PatientTreatment}"/> with the matching treatment records. Returns an empty sequence if no treatments are found.</returns>
|
||||
/// <!-- aidoc:v1 sig=1aafccf body=7965a74 -->
|
||||
public async Task<IEnumerable<PatientTreatment>> FindByPatientId(ObjectId patientId)
|
||||
{
|
||||
var filter = Builders<PatientTreatment>.Filter.Eq(ob => ob.PatientId, patientId);
|
||||
@@ -252,6 +265,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// <summary>
|
||||
/// Ensures the required MongoDB indexes exist for the <see cref="PatientTreatment"/> collection, creating a non-unique background index on the <c>patientid</c> field to optimize query performance without blocking other database operations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4955da2 body=7b72bb5 -->
|
||||
public override async Task CreateIndexes()
|
||||
{
|
||||
var options = new CreateIndexOptions { Background = true, Unique = false };
|
||||
@@ -268,6 +282,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// </summary>
|
||||
/// <param name="filters">The collection of filter definitions to which the active treatment criteria will be appended.</param>
|
||||
/// <param name="filterBuilder">The builder used to construct the individual filter conditions combined for the active treatment logic.</param>
|
||||
/// <!-- aidoc:v1 sig=52a33ae body=7b0cd33 -->
|
||||
private static void AddActiveTreatmentFilters(List<FilterDefinition<PatientTreatment>> filters,
|
||||
FilterDefinitionBuilder<PatientTreatment> filterBuilder)
|
||||
{
|
||||
@@ -311,6 +326,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// <param name="filters">The list of filter definitions to which the start and end time filters will be added.</param>
|
||||
/// <param name="filter">The pagination filter containing the optional start and end date values from the request.</param>
|
||||
/// <param name="filterBuilder">The filter definition builder used to construct the MongoDB filter expressions.</param>
|
||||
/// <!-- aidoc:v1 sig=b6dabce body=a3424c3 -->
|
||||
private void AddDefaultTimeFilters(List<FilterDefinition<PatientTreatment>> filters, PaginationFilter filter,
|
||||
FilterDefinitionBuilder<PatientTreatment> filterBuilder)
|
||||
{
|
||||
@@ -336,6 +352,7 @@ public class TreatmentRepository : MongoRepository<PatientTreatment>, ITreatment
|
||||
/// <param name="filters">The list of filter definitions to combine; if empty, an empty filter is used instead.</param>
|
||||
/// <param name="sort">The sort definition to apply to the query results.</param>
|
||||
/// <returns>An <see cref="IFindFluent{PatientTreatment, PatientTreatment}"/> representing the configured find query with the combined filter and sort applied.</returns>
|
||||
/// <!-- aidoc:v1 sig=45f2edf body=8cd8049 -->
|
||||
private IFindFluent<PatientTreatment, PatientTreatment> CreateFindFluent(
|
||||
List<FilterDefinition<PatientTreatment>> filters, SortDefinition<PatientTreatment> sort)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user