# Class PumpArchiveRepository

Namespace
  adas_core.Infrastructure.Repositories

Assembly
  adas-core.Infrastructure.dll

Repositorio de archivo para observaciones de bombas. Colección: archive_pumpobservations (configurable por ApiSettings.ArchivePumpObservations).

    public class PumpArchiveRepository : MongoRepository<PumpObservation>, IMongoRepository<PumpObservation>, IPumpArchiveRepository

Inheritance
  object
  MongoRepository<PumpObservation>
  PumpArchiveRepository

Implements
  IMongoRepository<PumpObservation>
  IPumpArchiveRepository

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

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

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

#### Parameters

`apiSettings` IOptions<ApiSettings>
`database` IMongoDatabase

## Methods

### CreateIndexes()

Creates the indexes required for the collection. The base implementation is a no-op; derived classes should override this method to define their own indexes.

    public override Task CreateIndexes()

#### Returns

Task

  A Task representing the asynchronous index creation operation.

### DeleteBeforeDate(DateTime)

Deletes all pump observations whose recording time is earlier than the specified cutoff date.

    public Task DeleteBeforeDate(DateTime addDays)

#### Parameters

`addDays` DateTime

  The cutoff date; observations with a timestamp before this value are removed.

#### Returns

Task

### FindByPatientIdAsync(ObjectId, DateTime?, DateTime?, int?)

Retrieves a collection of PumpObservation records for a specific patient, optionally filtered by a time range and limited in count, sorted by time in descending order.

    public Task<IEnumerable<PumpObservation>> FindByPatientIdAsync(ObjectId patientId, DateTime? from = null, DateTime? to = null, int? limit = null)

#### Parameters

`patientId` ObjectId

  The identifier of the patient whose pump observations are being queried.

`from` DateTime?

  Optional inclusive lower bound for the observation time. When provided, only observations on or after this time are returned.

`to` DateTime?

  Optional inclusive upper bound for the observation time. When provided, only observations on or before this time are returned.

`limit` int?

  Optional maximum number of observations to return. When null, all matching observations are returned.

#### Returns

Task<IEnumerable<PumpObservation>>

  A task that represents the asynchronous operation. The task result contains an IEnumerable<T> of matching observations ordered from newest to oldest.

### GetCollectionName()

When implemented in a derived class, returns the name of the MongoDB collection used to store documents of type PumpObservation.

    public override string GetCollectionName()

#### Returns

string

  The MongoDB collection name as a string.

### InsertAsync(PumpObservation)

Asynchronously inserts a PumpObservation into the underlying MongoDB collection.

    public Task InsertAsync(PumpObservation obs)

#### Parameters

`obs` PumpObservation

  The pump observation to persist.

#### Returns

Task

### InsertManyAsync(IEnumerable<PumpObservation>)

Asynchronously inserts a batch of pump observations into the underlying data store. If the collection is empty, the method completes without performing any insertion.

    public Task InsertManyAsync(IEnumerable<PumpObservation> observations)

#### Parameters

`observations` IEnumerable<PumpObservation>

  The pump observations to insert into the collection.

#### Returns

Task