Table of Contents

Class DiagnosisArchiveRepository

Namespace
adas_core.Infrastructure.Repositories
Assembly
adas-core.Infrastructure.dll

Repository for managing archived patient diagnoses in MongoDB. This repository provides methods for inserting, deleting, and indexing patient diagnosis records in the archive collection.

public class DiagnosisArchiveRepository : MongoRepository<PatientDiagnosis>, IMongoRepository<PatientDiagnosis>, IDiagnosisArchiveRepository
Inheritance
DiagnosisArchiveRepository
Implements
Inherited Members
Extension Methods

Constructors

DiagnosisArchiveRepository(IOptions<ApiSettings>, IMongoDatabase)

Initializes a new instance of the DiagnosisArchiveRepository class with the specified API settings and MongoDB database. The API settings are used to determine the collection name for storing archived patient diagnoses.

public DiagnosisArchiveRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)

Parameters

apiSettings IOptions<ApiSettings>
database IMongoDatabase

Exceptions

ArgumentNullException

Methods

CreateIndexes()

Creates indexes on the MongoDB collection for archived patient diagnoses to optimize query performance.

public override Task CreateIndexes()

Returns

Task

A task representing the asynchronous operation.

DeleteBeforeDate(DateTime)

Deletes all patient diagnosis records from the archive collection that have a timestamp earlier than the specified date.

public Task DeleteBeforeDate(DateTime date)

Parameters

date DateTime

The date before which patient diagnosis records should be deleted.

Returns

Task

A task representing the asynchronous operation.

GetCollectionName()

Gets the name of the MongoDB collection used for storing archived patient diagnoses. The collection name is determined based on the API settings, allowing for flexibility in configuration. If the API settings do not specify a collection name, a default name of "archive_patients_diagnosis" is used.

public override string GetCollectionName()

Returns

string

The name of the MongoDB collection for archived patient diagnoses.

InsertBatch(IEnumerable<PatientDiagnosis>)

Inserts a batch of patient diagnosis records into the archive collection asynchronously. This method uses the MongoDB driver's bulk write functionality to efficiently insert multiple records in a single operation, improving performance when dealing with large datasets.

public Task<long> InsertBatch(IEnumerable<PatientDiagnosis> observations)

Parameters

observations IEnumerable<PatientDiagnosis>

The collection of patient diagnosis records to insert.

Returns

Task<long>

The number of records successfully inserted.

InsertOneAsync(PatientDiagnosis)

Inserts a single patient diagnosis record into the archive collection asynchronously. This method uses the MongoDB driver to perform the insertion operation and ensures that the record is added to the correct collection as defined in the API settings.

public override Task InsertOneAsync(PatientDiagnosis patientDiagnosis)

Parameters

patientDiagnosis PatientDiagnosis

The patient diagnosis record to insert.

Returns

Task

A task representing the asynchronous operation.