# 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
  object
  MongoRepository<PatientDiagnosis>
  DiagnosisArchiveRepository

Implements
  IMongoRepository<PatientDiagnosis>
  IDiagnosisArchiveRepository

Inherited Members
  MongoRepository<PatientDiagnosis>.Db
  MongoRepository<PatientDiagnosis>.Collection
  MongoRepository<PatientDiagnosis>.UpdateOneAsync(ObjectId, PatientDiagnosis)
  MongoRepository<PatientDiagnosis>.DeleteAsync(ObjectId)
  MongoRepository<PatientDiagnosis>.InsertInitialLoad()
  MongoRepository<PatientDiagnosis>.InsertManyAsync(List<PatientDiagnosis>)
  MongoRepository<PatientDiagnosis>.UpdateManyObjectIdAsync(string, ObjectId, ObjectId)
  MongoRepository<PatientDiagnosis>.DeleteAsync(string)
  MongoRepository<PatientDiagnosis>.CollectionExists(string)
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## 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.