# Interface IPumpAlarmStateRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface IPumpAlarmStateRepository

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

## Methods

### DeleteByPatientId(ObjectId)

Deletes records associated with the specified patient identifier.

    Task DeleteByPatientId(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose related records should be removed.

#### Returns

Task

### FindActiveAsync(string, AlarmType?, string?)

Asynchronously retrieves the active alarm state for a specified device, optionally filtered by alarm type and alarm code. Returns `null` when no matching active alarm state is found.

    Task<PumpAlarmState?> FindActiveAsync(string deviceId, PumpEnum.AlarmType? alarmType, string? alarmCodeMdc = null)

#### Parameters

`deviceId` string

  The identifier of the device whose active alarm state is being queried.

`alarmType` PumpEnum.AlarmType?

  The optional alarm type to filter the search by; if `null`, no alarm type filter is applied.

`alarmCodeMdc` string

  The optional MDC alarm code to further filter the search; if `null`, no alarm code filter is applied.

#### Returns

Task<PumpAlarmState>

  A Task<TResult> containing the active PumpAlarmState, or `null` if no matching active alarm state exists.

### FindAllActiveByDeviceAsync(string)

Asynchronously retrieves all active pump alarm states associated with the specified device.

    Task<IEnumerable<PumpAlarmState>> FindAllActiveByDeviceAsync(string deviceId)

#### Parameters

`deviceId` string

  The unique identifier of the device whose active pump alarm states are being queried.

#### Returns

Task<IEnumerable<PumpAlarmState>>

  A task representing the asynchronous operation, containing a collection of active PumpAlarmState entries for the given device.

### RemoveAsync(string, AlarmType?, string?)

Asynchronously removes alarm records associated with the specified device, optionally filtered by alarm type and alarm code.

    Task RemoveAsync(string deviceId, PumpEnum.AlarmType? alarmType, string? alarmCodeMdc = null)

#### Parameters

`deviceId` string

  The identifier of the device whose alarms should be removed.

`alarmType` PumpEnum.AlarmType?

  The optional alarm type to filter the removal; when null, all alarm types are considered.

`alarmCodeMdc` string

  The optional alarm code (MDC) to further filter the removal; when null, no code filter is applied.

#### Returns

Task

### UpdateManyObjectIdByFieldNameAsync(string, ObjectId, ObjectId)

Asynchronously updates the MongoDB.Bson.ObjectId value in multiple documents identified by the specified field name, replacing `oldId` with `newId`, and returns the number of documents affected.

    Task<long> UpdateManyObjectIdByFieldNameAsync(string fieldName, ObjectId newId, ObjectId oldId)

#### Parameters

`fieldName` string

  The name of the field whose value will be updated.

`newId` ObjectId

  The new MongoDB.Bson.ObjectId value to assign.

`oldId` ObjectId

  The existing MongoDB.Bson.ObjectId value to be replaced.

#### Returns

Task<long>

  A Task<TResult> that represents the asynchronous operation. The task result contains the number of documents updated.

### UpsertActiveAsync(PumpAlarmState)

Inserts a new active pump alarm state or updates the existing one, maintaining the current state for the alarm.

    Task UpsertActiveAsync(PumpAlarmState state)

#### Parameters

`state` PumpAlarmState

  The pump alarm state to upsert as the active record.

#### Returns

Task