# Interface ITreatmentRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface ITreatmentRepository : IMongoRepository<PatientTreatment>

Inherited Members
  IMongoRepository<PatientTreatment>.Collection
  IMongoRepository<PatientTreatment>.GetCollectionName()
  IMongoRepository<PatientTreatment>.UpdateOneAsync(ObjectId, PatientTreatment)

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

## Methods

### DeleteAsync(ObjectId)

Asynchronously deletes the entity identified by the specified identifier.

    Task DeleteAsync(ObjectId id)

#### Parameters

`id` ObjectId

  The unique identifier of the entity to delete.

#### Returns

Task

### DeleteByPatientId(ObjectId)

Asynchronously deletes a record associated with the specified patient identifier.

    Task<bool> DeleteByPatientId(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose record should be deleted.

#### Returns

Task<bool>

  A task that represents the asynchronous operation. The task result is `true` if the record was successfully deleted; otherwise, `false`.

### FindBolusTreatments(ObjectId)

Asynchronously retrieves the list of bolus treatments associated with the specified patient.

    Task<List<PatientTreatment>> FindBolusTreatments(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose bolus treatments are being queried.

#### Returns

Task<List<PatientTreatment>>

  A task that represents the asynchronous operation, containing a list of PatientTreatment entries representing the patient's bolus treatments.

### FindByPatientId(ObjectId)

Asynchronously retrieves the collection of patient treatments associated with the specified patient identifier.

    Task<IEnumerable<PatientTreatment>> FindByPatientId(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose treatments are being queried.

#### Returns

Task<IEnumerable<PatientTreatment>>

  A task that represents the asynchronous operation, containing an enumerable collection of PatientTreatment records for the given patient.

### FindByPatientIdAsync(ObjectId)

Asynchronously retrieves the collection of PatientTreatment records associated with the specified patient identifier, returning the results as a cursor for streaming access.

    Task<IAsyncCursor<PatientTreatment>> FindByPatientIdAsync(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose treatments are being queried.

#### Returns

Task<IAsyncCursor<PatientTreatment>>

  A task that yields an MongoDB.Driver.IAsyncCursor<TDocument> of PatientTreatment records matching the given patient identifier.

### GetActiveTreatmentsByPatientIdAndOrder(ObjectId, string)

Asynchronously retrieves a list of active patient treatments for the specified patient, ordered according to the provided ordering criterion.

    Task<List<PatientTreatment>> GetActiveTreatmentsByPatientIdAndOrder(ObjectId patientId, string order)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose active treatments are to be retrieved.

`order` string

  The ordering criterion applied to the returned list of treatments.

#### Returns

Task<List<PatientTreatment>>

  A task that represents the asynchronous operation, containing a list of active PatientTreatment objects for the specified patient.

### GetById(ObjectId)

Asynchronously retrieves a patient treatment record from the data store that matches the specified identifier. Returns a cursor over the matching PatientTreatment document, or an empty cursor if no record is found.

    Task<IAsyncCursor<PatientTreatment>> GetById(ObjectId id)

#### Parameters

`id` ObjectId

  The unique MongoDB.Bson.ObjectId of the patient treatment record to retrieve.

#### Returns

Task<IAsyncCursor<PatientTreatment>>

  A Task<TResult> that yields a cursor containing the matching patient treatment, if any.

### GetByPatientId(ObjectId)

Retrieves the collection of PatientTreatment records associated with the specified patient identifier.

    Task<IEnumerable<PatientTreatment>> GetByPatientId(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose treatments are being queried.

#### Returns

Task<IEnumerable<PatientTreatment>>

  A task that represents the asynchronous operation. The task result contains an IEnumerable<T> of treatments for the patient; the collection is empty if no treatments are found.

### GetPaginatedTreatments(PaginationFilter)

Retrieves a paginated, fluent queryable collection of patient treatments based on the provided pagination filter.

    IFindFluent<PatientTreatment, PatientTreatment> GetPaginatedTreatments(PaginationFilter filter)

#### Parameters

`filter` PaginationFilter

  The pagination filter containing page size, page number, and other pagination criteria.

#### Returns

IFindFluent<PatientTreatment, PatientTreatment>

  An MongoDB.Driver.IFindFluent<TDocument, TProjection> for PatientTreatment that supports further fluent query composition and pagination.

### InsertOneAsync(PatientTreatment)

Asynchronously inserts a new PatientTreatment record into the data store.

    Task InsertOneAsync(PatientTreatment treatment)

#### Parameters

`treatment` PatientTreatment

  The patient treatment entity to be persisted.

#### Returns

Task

  A Task that represents the asynchronous insert operation.

### Update(PatientTreatment)

Updates an existing PatientTreatment record in the data store asynchronously.

    Task<bool> Update(PatientTreatment treatment)

#### Parameters

`treatment` PatientTreatment

  The PatientTreatment entity containing the updated information.

#### Returns

Task<bool>

  A Task<TResult> that represents the asynchronous update operation. The task result contains `true` if the update was successful; otherwise, `false`.

### UpdateManyObjectId(string, ObjectId, ObjectId)

Updates many records that reference a specific ObjectId, replacing the existing ObjectId with a new one. Typically used to remap references from `oldId` to `id` for the field identified by `nameId`.

    Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)

#### Parameters

`nameId` string

  The name of the field/property that contains the ObjectId reference to be updated.

`id` ObjectId

  The new ObjectId value that will replace the existing reference.

`oldId` ObjectId

  The current ObjectId value to match and be replaced.

#### Returns

Task