Class TreatmentArchiveRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Provides a MongoDB-backed repository for persisting and retrieving archived patient treatment records. Inherits from MongoRepository<T> and implements the ITreatmentArchiveRepository contract.
public class TreatmentArchiveRepository : MongoRepository<PatientTreatment>, IMongoRepository<PatientTreatment>, ITreatmentArchiveRepository
- Inheritance
-
TreatmentArchiveRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
TreatmentArchiveRepository(IOptions<ApiSettings>, IMongoDatabase)
public TreatmentArchiveRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>databaseIMongoDatabase
Methods
DeleteBeforeDate(DateTime)
Deletes all patient treatments whose order time is before the specified date.
public Task DeleteBeforeDate(DateTime date)
Parameters
dateDateTimeThe cutoff date; treatments with an order time earlier than this are removed.
Returns
FindAllFromPatient(ObjectId)
Retrieves all patient treatment records associated with the specified patient identifier from the collection.
public Task<List<PatientTreatment>> FindAllFromPatient(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose treatment records are to be retrieved.
Returns
- Task<List<PatientTreatment>>
A task that represents the asynchronous operation, containing a list of PatientTreatment records matching the specified patient.
GetCollectionName()
Retrieves the collection name for archive patients treatments, falling back to the default "archive_patients_treatments" value when the API settings do not specify one.
public override string GetCollectionName()
Returns
- string
The configured collection name from the API settings, or the default "archive_patients_treatments" if the setting is null.
InsertBatch(IEnumerable<PatientTreatment>)
Inserts a batch of PatientTreatment records into the underlying collection using a bulk write operation and returns the number of documents that were successfully inserted.
public Task<long> InsertBatch(IEnumerable<PatientTreatment> treatments)
Parameters
treatmentsIEnumerable<PatientTreatment>The collection of patient treatment records to insert into the database.
Returns
InsertOneAsync(PatientTreatment)
Asynchronously inserts a single PatientTreatment document into the collection.
public override Task InsertOneAsync(PatientTreatment patientTreatment)
Parameters
patientTreatmentPatientTreatmentThe patient treatment entity to persist.