=== 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:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -14,6 +14,7 @@ namespace adas_core.Infrastructure.Repositories;
/// This class provides methods to perform CRUD operations and queries related to patient appointments, such as retrieving appointments by patient ID, finding appointments by point of care, and updating or deleting appointments.
/// It utilizes the MongoDB driver for database interactions and is configured using application settings for collection names and other parameters.
/// </summary>
/// <!-- aidoc:v1 sig=2015cdb -->
public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppointmentRepository
{
/// <summary>
@@ -27,6 +28,8 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// <param name="apiSettings">The API settings containing configuration for the repository.</param>
/// <param name="database">The MongoDB database instance.</param>
/// <exception cref="ArgumentNullException">Thrown when any of the input parameters are null.</exception>
/// <!-- aidoc-review:v1 severity=medium kind=wrong_exception
/// "Documentation states ArgumentNullException is thrown when 'any of the input parameters are null', but only apiSettings is null-checked in the constructor body; database is passed to the base constructor without an explicit null check." -->
public AppointmentRepository(
IOptions<ApiSettings> apiSettings,
IMongoDatabase database) : base(database)
@@ -41,6 +44,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// If the collection name is not specified in the settings, it defaults to "patients_appointments".
/// </summary>
/// <returns>The name of the MongoDB collection for patient appointments.</returns>
/// <!-- aidoc:v1 sig=94e22ff body=d8275f8 -->
public override string GetCollectionName()
{
return _apiSettings.PatientsAppointments ?? "patients_appointments";
@@ -51,6 +55,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="patientId">The ID of the patient whose appointments are to be retrieved.</param>
/// <returns>A list of patient appointments for the specified patient ID.</returns>
/// <!-- aidoc:v1 sig=c45e6c0 body=7fc6917 -->
public async Task<List<PatientAppointment>> GetByPatient(ObjectId patientId)
{
var filter = Builders<PatientAppointment>.Filter.Eq(ob => ob.PatientId, patientId);
@@ -69,6 +74,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="poc">The point of care details to filter appointments.</param>
/// <returns>A list of patient appointments that match the specified point of care.</returns>
/// <!-- aidoc:v1 sig=6e05c46 body=b220747 -->
public async Task<List<PatientAppointment>> FindByPoC(PointOfCare poc)
{
var location = new PatientLocation()
@@ -85,6 +91,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="appointment">The patient appointment to be inserted.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=160dca2 body=b1d1f38 -->
public override async Task InsertOneAsync(PatientAppointment appointment)
{
appointment.CreateTime ??= DateTime.UtcNow;
@@ -97,6 +104,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="appointment">The patient appointment to be updated.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=6653577 body=7202215 -->
public async Task Update(PatientAppointment appointment)
{
await UpdateOneAsync(appointment.Id, appointment);
@@ -107,6 +115,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="id">The ID of the patient appointment to be deleted.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=78c6c5d body=673af1f -->
public new async Task DeleteAsync(ObjectId id)
{
var filter = Builders<PatientAppointment>.Filter.Eq(t => t.Id, id); // Replace 'T' with your actual class name.
@@ -118,6 +127,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="patientId">The ID of the patient whose appointments are to be retrieved.</param>
/// <returns>An asynchronous cursor to iterate through the patient appointments.</returns>
/// <!-- aidoc:v1 sig=737aa7b body=4dc939c -->
public Task<IAsyncCursor<PatientAppointment>> FindByPatientIdAsync(ObjectId patientId)
{
var filter = Builders<PatientAppointment>.Filter.Eq(ob => ob.PatientId, patientId);
@@ -129,6 +139,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="patientId">The ID of the patient whose appointments are to be deleted.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=4776e51 body=b5830ef -->
public async Task DeleteByPatientId(ObjectId patientId)
{
var filter = Builders<PatientAppointment>.Filter.Eq(po => po.PatientId, patientId);
@@ -141,6 +152,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// <param name="patientId">The ID of the patient whose appointment is to be retrieved.</param>
/// <param name="visitNumber">The visit number of the appointment to be retrieved.</param>
/// <returns>The first matching patient appointment if found, or null if no match is found.</returns>
/// <!-- aidoc:v1 sig=713bd29 body=0453b7b -->
public async Task<PatientAppointment?> FindByPatientAndVisitNumber(ObjectId patientId, string visitNumber)
{
var builder = Builders<PatientAppointment>.Filter;
@@ -160,6 +172,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// <param name="patientId">The ID of the patient whose appointment is to be retrieved.</param>
/// <param name="appointmentReason">The reason for the appointment to be retrieved.</param>
/// <returns>The first matching patient appointment if found, or null if no match is found.</returns>
/// <!-- aidoc:v1 sig=0d22413 body=622cd38 -->
public async Task<PatientAppointment?> FindByPatientAndReason(ObjectId patientId, string? appointmentReason)
{
var builder = Builders<PatientAppointment>.Filter;
@@ -178,6 +191,8 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// </summary>
/// <param name="location">The location details to filter patient appointments by.</param>
/// <returns>A list of patient appointments that match the specified location.</returns>
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
/// "The summary states the location 'includes details such as bed, room, and unit name', but the code only filters by Bed and UnitName; Room is not part of the filter." -->
public async Task<List<PatientAppointment>> FindByLocation(PatientLocation location)
{
var builder = Builders<PatientAppointmentResourceGroup>.Filter;
@@ -200,6 +215,10 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// <param name="id">The new ObjectId to replace the old patient ID.</param>
/// <param name="oldId">The old ObjectId of the patient whose appointments are to be updated.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary states this method constructs a filter and uses UpdateManyAsync, but the code only awaits a call to UpdateManyObjectIdAsync without constructing any filter or calling UpdateManyAsync directly." -->
/// <!-- aidoc-review:v1 severity=high kind=mentions_removed_behavior
/// "Mentions 'UpdateManyAsync method' which is not invoked here; the method delegates to UpdateManyObjectIdAsync instead." -->
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
{
await UpdateManyObjectIdAsync(nameId, id, oldId);
@@ -210,6 +229,7 @@ public class AppointmentRepository : MongoRepository<PatientAppointment>, IAppoi
/// The indexes are created in the background and are not unique.
/// </summary>
/// <returns>A task representing the asynchronous operation.</returns>
/// <!-- aidoc:v1 sig=4955da2 body=178452d -->
public override async Task CreateIndexes()
{
var options = new CreateIndexOptions { Background = true, Unique = false };