# 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
  object
  MongoRepository<PatientTreatment>
  TreatmentArchiveRepository

Implements
  IMongoRepository<PatientTreatment>
  ITreatmentArchiveRepository

Inherited Members
  MongoRepository<PatientTreatment>.Db
  MongoRepository<PatientTreatment>.Collection
  MongoRepository<PatientTreatment>.UpdateOneAsync(ObjectId, PatientTreatment)
  MongoRepository<PatientTreatment>.DeleteAsync(ObjectId)
  MongoRepository<PatientTreatment>.CreateIndexes()
  MongoRepository<PatientTreatment>.InsertInitialLoad()
  MongoRepository<PatientTreatment>.InsertManyAsync(List<PatientTreatment>)
  MongoRepository<PatientTreatment>.UpdateManyObjectIdAsync(string, ObjectId, ObjectId)
  MongoRepository<PatientTreatment>.DeleteAsync(string)
  MongoRepository<PatientTreatment>.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

### TreatmentArchiveRepository(IOptions<ApiSettings>, IMongoDatabase)

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

#### Parameters

`apiSettings` IOptions<ApiSettings>
`database` IMongoDatabase

## Methods

### DeleteBeforeDate(DateTime)

Deletes all patient treatments whose order time is before the specified date.

    public Task DeleteBeforeDate(DateTime date)

#### Parameters

`date` DateTime

  The cutoff date; treatments with an order time earlier than this are removed.

#### Returns

Task

### FindAllFromPatient(ObjectId)

Retrieves all patient treatment records associated with the specified patient identifier from the collection.

    public Task<List<PatientTreatment>> FindAllFromPatient(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The 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

`treatments` IEnumerable<PatientTreatment>

  The collection of patient treatment records to insert into the database.

#### Returns

Task<long>

  The total count of patient treatment records inserted by the bulk write operation.

### InsertOneAsync(PatientTreatment)

Asynchronously inserts a single PatientTreatment document into the collection.

    public override Task InsertOneAsync(PatientTreatment patientTreatment)

#### Parameters

`patientTreatment` PatientTreatment

  The patient treatment entity to persist.

#### Returns

Task