Class AlarmRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Repository for managing patient observation alarms in MongoDB. Provides methods to retrieve aggregated patient observations based on specified fields and expiration status. Implements the IAlarmRepository interface and extends the MongoRepository base class for common MongoDB operations.
public class AlarmRepository : MongoRepository<PatientObservationAlarm>, IAlarmRepository, IMongoRepository<PatientObservationAlarm>
- Inheritance
-
AlarmRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
AlarmRepository(IOptions<ApiSettings>, IMongoDatabase, ILogger<AlarmRepository>)
Constructor for the AlarmRepository class. Initializes the repository with the provided API settings, MongoDB database instance, and logger. Validates the input parameters and sets up the necessary configurations for accessing the patient observation alarms collection in MongoDB.
public AlarmRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database, ILogger<AlarmRepository> logger)
Parameters
apiSettingsIOptions<ApiSettings>The API settings containing configuration for the MongoDB collection name and other relevant settings.
databaseIMongoDatabaseThe MongoDB database instance.
loggerILogger<AlarmRepository>The logger instance for logging errors and information.
Exceptions
- ArgumentNullException
Thrown when any of the input parameters are null.
Methods
AggregatedPatientLastObservationsByField(ObjectId, List<Field>?)
Retrieves a list of patient observation alarms for a specific patient based on the provided filter criteria. The method allows filtering observations by name and expiration status, and returns the most recent observations for each specified field. If no filter is provided, it retrieves all observations for the patient sorted by time in descending order.
public Task<List<PatientObservationAlarm>> AggregatedPatientLastObservationsByField(ObjectId patientId, List<Field>? filterObservations = null)
Parameters
patientIdObjectIdThe unique identifier of the patient.
filterObservationsList<Field>A list of fields to filter the observations. If null, all observations for the patient are retrieved.
Returns
- Task<List<PatientObservationAlarm>>
A list of patient observation alarms matching the filter criteria.
AggregatedPatientNotExpiredObservationsByField(ObjectId, List<Field>?, List<ConfigObservation>)
Retrieves a list of patient observation alarms for a specific patient based on the provided filter criteria, including expiration status.
public Task<List<PatientObservationAlarm>> AggregatedPatientNotExpiredObservationsByField(ObjectId patientId, List<Field>? filterObservations, List<ConfigObservation> configAlarm)
Parameters
patientIdObjectIdThe unique identifier of the patient.
filterObservationsList<Field>A list of fields to filter the observations. If null, all observations for the patient are retrieved.
configAlarmList<ConfigObservation>A list of configuration settings for the observations, including expiration times.
Returns
- Task<List<PatientObservationAlarm>>
A list of patient observation alarms matching the filter criteria and expiration settings.
CreateIndexes()
Creates indexes for the patient observation alarms collection in MongoDB to optimize query performance.
public override Task CreateIndexes()
Returns
- Task
A task that represents the asynchronous operation of creating indexes.
GetCollectionName()
Gets the name of the MongoDB collection for patient observation alarms. The collection name is determined based on the API settings provided during the repository initialization. If the collection name is not specified in the API settings, it defaults to "patients_alarms".
public override string GetCollectionName()
Returns
- string
The name of the MongoDB collection for patient observation alarms.