=== 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:
@@ -17,6 +17,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// <summary>
|
||||
/// Repository for managing Discharge entities in MongoDB. Provides methods for CRUD operations and specific queries related to discharges.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6c520ba -->
|
||||
public class DischargeRepository : MongoRepository<Discharge>, IDischargeRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
@@ -26,6 +27,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="apiSettings">The API settings containing configuration for the repository.</param>
|
||||
/// <param name="database">The MongoDB database instance.</param>
|
||||
/// <!-- aidoc:v1 sig=37f77f4 body=12fddac -->
|
||||
public DischargeRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database) : base(database)
|
||||
{
|
||||
_apiSettings = apiSettings.Value;
|
||||
@@ -35,6 +37,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// Gets the name of the MongoDB collection for discharges from the API settings.
|
||||
/// </summary>
|
||||
/// <returns>The name of the MongoDB collection for discharges.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=d8f9298 -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.Discharges;
|
||||
@@ -45,6 +48,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="discharge">The discharge record to insert.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=e47013f body=e384f70 -->
|
||||
public override async Task InsertOneAsync(Discharge discharge)
|
||||
{
|
||||
try
|
||||
@@ -63,6 +67,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the discharge record to delete.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=3de1ad6 body=7e7d153 -->
|
||||
public async Task Delete(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -83,6 +88,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// <param name="discharge">The discharge record to update.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <exception cref="ConflictException"></exception>
|
||||
/// <!-- aidoc:v1 sig=1ecc041 body=d41cd7e -->
|
||||
public async Task Update(Discharge discharge)
|
||||
{
|
||||
try
|
||||
@@ -102,6 +108,8 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// <param name="id">The ID of the discharge record to update.</param>
|
||||
/// <param name="unit">The new unit name to set.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=stale_summary
|
||||
/// "The summary claims 'If the update operation fails, an error is logged,' but the method body contains no try/catch, error handling, or logging — only an unawaited UpdateOneAsync call." -->
|
||||
public async Task UpdateUnit(ObjectId id, string unit)
|
||||
{
|
||||
var filterBuilder = Builders<Discharge>.Filter;
|
||||
@@ -119,6 +127,8 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// <param name="id">The ID of the discharge record to update.</param>
|
||||
/// <param name="patient">The new patient information to set.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Summary claims 'If the update operation fails, an error is logged', but the code has no try-catch or logging mechanism — any failure would propagate as an exception." -->
|
||||
public async Task UpdatePatient(ObjectId id, Patient patient)
|
||||
{
|
||||
var filterBuilder = Builders<Discharge>.Filter;
|
||||
@@ -134,6 +144,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// Finds and retrieves all discharge records from the MongoDB collection. If an error occurs during retrieval, an error is logged and an empty list is returned.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of all discharge records.</returns>
|
||||
/// <!-- aidoc:v1 sig=87546e9 body=77eea29 -->
|
||||
public async Task<IEnumerable<Discharge>> FindAll()
|
||||
{
|
||||
try
|
||||
@@ -153,6 +164,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the discharge record to retrieve.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the discharge record if found, or null if not found or an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=16a9670 body=05bd4d2 -->
|
||||
public async Task<Discharge?> FindById(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -174,6 +186,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="unit">The unit name to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of discharge records matching the specified unit name, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=26a3520 body=9cee09f -->
|
||||
public async Task<IEnumerable<Discharge>?> FindByUnit(string unit)
|
||||
{
|
||||
try
|
||||
@@ -195,6 +208,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="unitId">The ID of the unit to count discharge records for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the count of discharge records matching the specified unit ID, or 0 if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=baa8175 body=1403f2e -->
|
||||
public async Task<long> CountByUnitId(ObjectId unitId)
|
||||
{
|
||||
try
|
||||
@@ -214,6 +228,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="destination">The destination to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of discharge records matching the specified destination, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=7f6b4ab body=f403711 -->
|
||||
public async Task<IEnumerable<Discharge>?> FindByDestination(string destination)
|
||||
{
|
||||
try
|
||||
@@ -238,6 +253,10 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="unitIds">The IDs of the units to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of discharge records matching the specified unit IDs, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary states that on error an error is logged and null is returned, but the method has no try/catch and no logging; exceptions would propagate, not be swallowed and converted to null." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_returns
|
||||
/// "The returns tag claims 'null if an error occurs', but the implementation never returns null on error (no exception handling); it only returns the ToListAsync result." -->
|
||||
public async Task<IEnumerable<Discharge>?> GetDischargesByUnitIds(IEnumerable<ObjectId>? unitIds)
|
||||
{
|
||||
var filterUnit = Builders<Discharge>.Filter.In("unitId", unitIds);
|
||||
@@ -249,6 +268,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="pocId">The ID of the Point of Care to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of discharge records matching the specified Point of Care ID, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=13fd339 body=8de0a6c -->
|
||||
public async Task<IEnumerable<Discharge>?> FindByPoCId(ObjectId pocId)
|
||||
{
|
||||
try
|
||||
@@ -271,6 +291,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="service">The service to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing a list of discharge records matching the specified service, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=8f5cc53 body=fa9829a -->
|
||||
public async Task<IEnumerable<Discharge>?> FindByService(string service)
|
||||
{
|
||||
try
|
||||
@@ -292,6 +313,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="location">The patient location to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the discharge record matching the specified patient location, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=d6f8db9 body=a619aca -->
|
||||
public async Task<Discharge?> GetDischargeByLocation(PatientLocation location)
|
||||
{
|
||||
try
|
||||
@@ -313,6 +335,8 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the Point of Care to search for.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the discharge record matching the specified Point of Care ID, or null if an error occurs.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=low kind=wrong_returns
|
||||
/// "Returns tag only mentions null in the error case, but FirstOrDefaultAsync also returns null when no matching discharge record is found" -->
|
||||
public async Task<Discharge?> GetDischargeByPointOfCareId(ObjectId id)
|
||||
{
|
||||
try
|
||||
@@ -337,6 +361,10 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// <param name="opt">The update option specifying the changes to be applied to the master list.</param>
|
||||
/// <param name="typeName">The name of the master list type to be updated.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the updated discharge records, or an empty list if an error occurs.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary states the method 'performs updates accordingly', but the switch cases are empty (only comments) and no actual update logic is present in the code." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "The summary claims 'If an error occurs during the update process, an error is logged and an empty list is returned', but there is no error handling or logging in the code, and the method always returns an empty list." -->
|
||||
public Task<IEnumerable<Discharge>> UpdateMasterListOption(List<ObjectId> unitIds, UpdateOptionMasterListDto opt,
|
||||
string typeName)
|
||||
{
|
||||
@@ -361,6 +389,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="unitId">The ID of the unit for which to delete discharge records.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing true if the deletion was successful, or false if an error occurred.</returns>
|
||||
/// <!-- aidoc:v1 sig=d4333b3 body=a16e555 -->
|
||||
public async Task<bool> DeleteByUnitId(ObjectId unitId)
|
||||
{
|
||||
try
|
||||
@@ -383,6 +412,12 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// <param name="opt">The update option specifying the changes to be applied to the master list.</param>
|
||||
/// <param name="typeName">The name of the master list type to be updated.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the updated discharge records, or an empty list if an error occurs.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_param_role
|
||||
/// "The <param name=\"opt\"> description calls it 'The update option specifying the changes to be applied to the master list', but the method is a delete operation (DeleteMasterListOption), so this should describe a delete option, not an update option." -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_param_role
|
||||
/// "The <param name=\"typeName\"> description says 'The name of the master list type to be updated', but the method performs deletion, not update." -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_returns
|
||||
/// "The <returns> description says 'containing the updated discharge records', but the method deletes and returns discharge records, it does not update them." -->
|
||||
public Task<IEnumerable<Discharge>> DeleteMasterListOption(List<ObjectId> unitIds, OptionList opt, string typeName)
|
||||
{
|
||||
var isParsed = Enum.TryParse<MasterListType>(typeName, out var parsedTypeName);
|
||||
@@ -406,6 +441,7 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// </summary>
|
||||
/// <param name="patientId">The ID of the patient for which to retrieve the discharge record.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the discharge record if found, or null if an error occurs or the record is not found.</returns>
|
||||
/// <!-- aidoc:v1 sig=e4173bb body=474ce38 -->
|
||||
public async Task<Discharge?> GetByPatientId(ObjectId patientId)
|
||||
{
|
||||
try
|
||||
@@ -428,6 +464,8 @@ public class DischargeRepository : MongoRepository<Discharge>, IDischargeReposit
|
||||
/// If an error occurs during index creation, an error is logged.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
|
||||
/// "Summary claims 'If an error occurs during index creation, an error is logged,' but the method body has no try/catch or logging code; error handling is delegated to MongoUtils.EnsureIndexes." -->
|
||||
public override async Task CreateIndexes()
|
||||
{
|
||||
var optionsUq = new CreateIndexOptions<Discharge>
|
||||
|
||||
Reference in New Issue
Block a user