Interface IObservationService
- Namespace
- adas_core.Application.Services.Interfaces
- Assembly
- adas-core.Application.dll
public interface IObservationService : IApiRequestService
- Inherited Members
- Extension Methods
Methods
Archive(Patient)
Archives the specified patient, moving their record out of the active set so that it is retained for historical or compliance purposes while no longer appearing in routine operational queries.
Task Archive(Patient patient)
Parameters
patientPatientThe patient whose record is to be archived.
Returns
Archive(PatientObservation)
Asynchronously archives the specified patient observation, preserving it for historical or compliance purposes while removing it from the active set.
Task Archive(PatientObservation observation)
Parameters
observationPatientObservationThe patient observation to archive.
Returns
- Task
A task that represents the asynchronous archive operation.
ArchiveByPatientId(ObjectId)
Archives records associated with the specified patient identifier.
Task ArchiveByPatientId(ObjectId id)
Parameters
idObjectIdThe unique identifier of the patient whose records should be archived.
Returns
CheckAndExpireObservations()
Checks observations and expires those that meet the expiration criteria.
Task CheckAndExpireObservations()
Returns
DeleteByPatientId(ObjectId)
Asynchronously deletes records associated with the specified patient identifier.
Task DeleteByPatientId(ObjectId id)
Parameters
idObjectIdThe MongoDB.Bson.ObjectId of the patient whose related records should be removed.
Returns
ExpireAlertsAndPowerOffAsync()
Asynchronously expires active alerts and powers off the device.
Task ExpireAlertsAndPowerOffAsync()
Returns
ExpireObservations()
Asynchronously processes and expires observations that have exceeded their validity period.
Task ExpireObservations()
Returns
ExpireObservationsAndRecalculateAsync()
Asynchronously expires observations that are no longer valid and recalculates the dependent data.
Task ExpireObservationsAndRecalculateAsync()
Returns
FindAllAfterDate(ObjectId, DateTime, List<string>?)
Retrieves all PatientObservation entries for the specified patient recorded after the given date, optionally restricted to a subset of observation names.
Task<List<PatientObservation>> FindAllAfterDate(ObjectId patientId, DateTime date, List<string>? filterObservations = null)
Parameters
patientIdObjectIdThe identifier of the patient whose observations are being queried.
dateDateTimeThe cutoff date; only observations with a timestamp after this value are returned.
filterObservationsList<string>An optional list of observation names to restrict the result to. When
nullor empty, all observations after the date are returned.
Returns
- Task<List<PatientObservation>>
A Task<TResult> that yields the list of matching PatientObservation entries.
FindAllBeforeDate(ObjectId, DateTime, List<string>?)
Retrieves all patient observations recorded before the specified date, optionally filtered to a specific set of observation types.
Task<List<PatientObservation>> FindAllBeforeDate(ObjectId patientId, DateTime date, List<string>? filterObservations = null)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
dateDateTimeThe cutoff date; only observations recorded before this date will be returned.
filterObservationsList<string>An optional list of observation identifiers used to restrict the results to specific observation types. When null, all observation types are included.
Returns
- Task<List<PatientObservation>>
A task that resolves to a list of PatientObservation instances matching the criteria.
FindAllBetweenDates(ObjectId, DateTime?, DateTime?, List<string>?, bool, PaginationFilter?)
Retrieves a paginated list of patient observations for the specified patient within an optional date range, optionally filtered by observation names and including archived records when requested.
Task<List<PatientObservation>> FindAllBetweenDates(ObjectId patientId, DateTime? startDate, DateTime? endDate, List<string>? filterObservations = null, bool fromArchived = false, PaginationFilter? filter = null)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
startDateDateTime?The inclusive lower bound of the observation date range, or null to apply no lower bound.
endDateDateTime?The inclusive upper bound of the observation date range, or null to apply no upper bound.
filterObservationsList<string>An optional list of observation names used to restrict the returned observations.
fromArchivedboolWhen true, observations are retrieved from archived records; otherwise, only active records are considered.
filterPaginationFilterAn optional pagination filter applied to the result set.
Returns
- Task<List<PatientObservation>>
A task that resolves to a list of PatientObservation entries matching the provided criteria.
FindAllLastPatientObservationTime()
Asynchronously retrieves the most recent observation time for each patient, returning a mapping of patient identifiers to their last observation timestamps.
Task<Dictionary<ObjectId, DateTime>> FindAllLastPatientObservationTime()
Returns
- Task<Dictionary<ObjectId, DateTime>>
A task that represents the asynchronous operation. The task result contains a dictionary where each key is a patient MongoDB.Bson.ObjectId and the associated value is the DateTime of that patient's latest observation.
FindAnyWithSameDate(ObjectId, DateTime, string?)
Asynchronously retrieves the patient observations for the specified patient that share the given date, optionally filtered by observation name.
Task<List<PatientObservation>?> FindAnyWithSameDate(ObjectId patientId, DateTime date, string? obsName)
Parameters
patientIdObjectIdThe identifier of the patient whose observations will be searched.
dateDateTimeThe date used to match observations.
obsNamestringThe optional observation name used to filter the results. When null, observations are not filtered by name.
Returns
- Task<List<PatientObservation>>
A task that represents the asynchronous operation. The task result contains a list of matching PatientObservation records, or null when no observations match the criteria.
FindByPatientIdAndCodingSystemAsync(ObjectId, string, string)
Asynchronously retrieves patient observations matching the specified patient identifier, coding system, and name.
Task<IAsyncCursor<PatientObservation>> FindByPatientIdAndCodingSystemAsync(ObjectId patientId, string codingSystem, string name)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
codingSystemstringThe coding system used to classify the observations (e.g., LOINC, SNOMED).
namestringThe name of the observation to filter by.
Returns
- Task<IAsyncCursor<PatientObservation>>
A task that represents the asynchronous operation, containing an MongoDB.Driver.IAsyncCursor<TDocument> of PatientObservation matching the criteria.
FindByPatientIdAsync(ObjectId)
Asynchronously retrieves all patient observations associated with the specified patient identifier.
Task<IAsyncCursor<PatientObservation>> FindByPatientIdAsync(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are to be retrieved.
Returns
- Task<IAsyncCursor<PatientObservation>>
A task that returns an MongoDB.Driver.IAsyncCursor<TDocument> of PatientObservation instances for the given patient.
FindLastBeforeDate(ObjectId, DateTime, string?)
Asynchronously retrieves the most recent PatientObservation for a patient recorded before the specified date, optionally filtered by observation name.
Task<PatientObservation?> FindLastBeforeDate(ObjectId patientId, DateTime date, string? obsName)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observation is being queried.
dateDateTimeThe cutoff date; only observations recorded strictly before this date are considered.
obsNamestringThe optional name of the observation to filter by, or
nullto match any observation.
Returns
- Task<PatientObservation>
A task that represents the asynchronous operation. The task result contains the latest matching PatientObservation, or
nullif none was found before the given date.
FindLastIntravenousLinesObservationByLocation(ObjectId)
Retrieves the most recent intravenous line observations associated with a specific location for the given patient.
Task<List<PatientObservation?>> FindLastIntravenousLinesObservationByLocation(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose intravenous line observations are being queried.
Returns
- Task<List<PatientObservation>>
A task that represents the asynchronous operation. The task result contains a list of nullable PatientObservation entries representing the latest intravenous line observations by location, where individual entries may be
nullwhen no data is available.
FindLastNotExpiredObservatonsByPatient(ObjectId, string, int?, int?)
Asynchronously retrieves the most recent non-expired observations for the specified patient, optionally filtered by observation name and constrained by pagination parameters.
Task<IEnumerable<PatientObservation>> FindLastNotExpiredObservatonsByPatient(ObjectId patientId, string name, int? endAfter = null, int? num = null)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
namestringThe name of the observation type used to filter the results.
endAfterint?Optional parameter that defines the pagination boundary; when provided, observations are returned starting after this position.
numint?Optional parameter that limits the maximum number of observations returned.
Returns
- Task<IEnumerable<PatientObservation>>
A task representing the asynchronous operation, containing a collection of matching non-expired PatientObservation records; an empty collection is returned if none are found.
FindLastObservations(ObjectId, int, List<string>?)
Retrieves the most recent patient observations for the specified patient, optionally filtered by a set of observation codes.
Task<List<PatientObservation>> FindLastObservations(ObjectId patientId, int num = 2, List<string>? filterObservations = null)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
numintThe maximum number of most recent observations to return. Defaults to 2.
filterObservationsList<string>An optional list of observation codes used to restrict the result set; if null, observations are not filtered by code.
Returns
- Task<List<PatientObservation>>
A task that resolves to a list of the most recent PatientObservation entries matching the criteria.
FindLastObservationsByField(ObjectId, List<Field>?, bool, CancellationToken)
Retrieves the most recent observations recorded for a patient, optionally filtered to a specific set of fields.
Task<List<PatientObservation>> FindLastObservationsByField(ObjectId patientId, List<Field>? filterObservations = null, bool mapped = true, CancellationToken ct = default)
Parameters
patientIdObjectIdThe identifier of the patient whose observations are being retrieved.
filterObservationsList<Field>An optional list of fields used to restrict which observations are returned. When null, observations for all fields are considered.
mappedboolIndicates whether the returned observations should be mapped (default true) or returned in their raw form.
ctCancellationTokenThe cancellation token used to cancel the asynchronous operation.
Returns
- Task<List<PatientObservation>>
A task that resolves to a list of the patient's most recent PatientObservation entries.
FindLatestUniqueValuesByName(ObjectId, string, int?)
Retrieves the most recent unique patient observations for the specified patient, filtered by observation name, with an optional cache expiration window in seconds.
Task<List<PatientObservation>> FindLatestUniqueValuesByName(ObjectId patientId, string name, int? expires)
Parameters
patientIdObjectIdThe unique identifier of the patient whose observations are being queried.
namestringThe name of the observation to filter by.
expiresint?Optional expiration time in seconds applied to the cached results. If
null, no expiration is applied.
Returns
- Task<List<PatientObservation>>
A task that represents the asynchronous operation. The task result contains a list of the latest unique PatientObservation values matching the specified patient and name.
FindNotExpiredObservationsShouldBeExpired()
Retrieves patient observations that have not been marked as expired but should be, based on their validity period or business rules.
IAsyncEnumerable<PatientObservation> FindNotExpiredObservationsShouldBeExpired()
Returns
- IAsyncEnumerable<PatientObservation>
An asynchronous stream of PatientObservation instances that are not expired but meet the criteria to be expired.
GetPaginatedObservations(PaginationFilter)
Asynchronously retrieves a paginated collection of patient observations based on the specified filter criteria.
Task<PaginationResponse<PatientObservation>> GetPaginatedObservations(PaginationFilter filter)
Parameters
filterPaginationFilterThe pagination filter that controls the page size, page number, and any additional query criteria applied to the patient observations.
Returns
- Task<PaginationResponse<PatientObservation>>
A task that represents the asynchronous operation, containing a PaginationResponse<T> of PatientObservation with the requested page of results.
InsertIfChanged(string, PatientObservation, bool, bool)
Inserts the specified patient observation only if it has changed, optionally persisting the observation and applying a mapping during the insert.
Task<bool> InsertIfChanged(string name, PatientObservation observation, bool persistObs = true, bool mapObs = true)
Parameters
namestringThe name associated with the patient observation being evaluated for changes.
observationPatientObservationThe patient observation to compare against the existing value and potentially insert.
persistObsboolIndicates whether the observation should be persisted when it is inserted. Defaults to
true.mapObsboolIndicates whether the observation should be mapped as part of the insert operation. Defaults to
true.
Returns
- Task<bool>
A task that returns
trueif the observation was inserted because a change was detected; otherwise,falseif no insert was performed.
InsertNurseObservation(PatientObservation)
Inserts a new nurse observation for a patient into the underlying data store.
Task InsertNurseObservation(PatientObservation obs)
Parameters
obsPatientObservationThe patient observation data recorded by the nurse to be persisted.
Returns
InsertObservation(PatientObservation, bool, bool)
Asynchronously inserts a patient observation, with options to control whether the observation is persisted and whether it is mapped.
Task InsertObservation(PatientObservation patientObservation, bool persistObs = true, bool mapObs = true)
Parameters
patientObservationPatientObservationThe patient observation to insert.
persistObsboolIndicates whether the observation should be persisted; defaults to
true.mapObsboolIndicates whether the observation should be mapped; defaults to
true.
Returns
InsertSimpleObservation(PatientObservation)
Asynchronously inserts a simple patient observation record.
Task InsertSimpleObservation(PatientObservation observation)
Parameters
observationPatientObservationThe patient observation to insert.
Returns
- Task
A task that represents the asynchronous insert operation.
MapObservation(PatientObservation, bool)
Asynchronously maps a PatientObservation to a corresponding observation, optionally restricting the lookup to name-based matching. Returns null when no matching observation is found.
Task<PatientObservation?> MapObservation(PatientObservation obs, bool onlyByName = false)
Parameters
obsPatientObservationThe source PatientObservation to be mapped.
onlyByNameboolWhen true, restricts the lookup to name-based matching; otherwise, the default mapping behavior is applied.
Returns
- Task<PatientObservation>
A Task<TResult> containing the mapped PatientObservation, or null if no match is found.
MapObservationsByName(PatientObservation)
Asynchronously maps or looks up a PatientObservation based on the name of the provided observation, returning the matching observation or null when no match is found.
Task<PatientObservation?> MapObservationsByName(PatientObservation obs)
Parameters
obsPatientObservationThe PatientObservation whose name is used to perform the mapping or lookup.
Returns
- Task<PatientObservation>
A Task<TResult> that resolves to the matching PatientObservation, or
nullif no corresponding observation is found.
ProcessObservations(List<PatientObservation>, Patient, DateTime, ObservationData?)
Processes a collection of patient observations, associating them with the specified patient and recording the message time.
void ProcessObservations(List<PatientObservation> observations, Patient patient, DateTime messageTime, ObservationData? observationData = null)
Parameters
observationsList<PatientObservation>The list of patient observations to process.
patientPatientThe patient associated with the observations.
messageTimeDateTimeThe timestamp of the message containing the observations.
observationDataObservationDataOptional additional data related to the observations.
SaveRequestNurseObsAsync(ApiRequest)
Asynchronously saves a nurse observation request.
Task SaveRequestNurseObsAsync(ApiRequest request)
Parameters
requestApiRequestThe API request containing the nurse observation data to save.
Returns
SendObsBroadcast(List<PatientObservation>, ObjectId)
Asynchronously sends a broadcast of patient observations to the specified Point of Care (POC) system.
Task SendObsBroadcast(List<PatientObservation> obs, ObjectId pocId)
Parameters
obsList<PatientObservation>The list of patient observations to be transmitted in the broadcast.
pocIdObjectIdThe identifier of the Point of Care system that will receive the observations.
Returns
SendObsBroadcast(List<PatientObservation>, PatientLocation)
Sends a broadcast containing the specified patient observations to the given patient location.
Task SendObsBroadcast(List<PatientObservation> obs, PatientLocation location)
Parameters
obsList<PatientObservation>The list of patient observations to include in the broadcast.
locationPatientLocationThe target patient location that will receive the broadcast.
Returns
SendObsBroadcast(BasePatientObservation)
Asynchronously broadcasts a patient observation to subscribed listeners or endpoints.
Task SendObsBroadcast(BasePatientObservation obs)
Parameters
obsBasePatientObservationThe base patient observation to be broadcast.
Returns
UpdateExpiredObservations(List<PatientObservation>)
Updates the status of the provided patient observations that have reached their expiration.
Task UpdateExpiredObservations(List<PatientObservation> expiredObservations)
Parameters
expiredObservationsList<PatientObservation>The list of patient observations to update as expired.
Returns
UpdateManyObjectId(string, ObjectId, ObjectId)
Updates the specified identifier field (nameId) across multiple objects, replacing the existing value oldId with the new value id.
Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
Parameters
nameIdstringThe name of the identifier field to be updated.
idObjectIdThe new MongoDB.Bson.ObjectId value to assign to the field.
oldIdObjectIdThe current MongoDB.Bson.ObjectId value to be replaced.
Returns
- Task
A task that represents the asynchronous bulk update operation.
UpdateObservation(PatientObservation)
Updates an existing patient observation in the data store.
Task UpdateObservation(PatientObservation observation)
Parameters
observationPatientObservationThe patient observation containing the updated information.
Returns
- Task
A task that represents the asynchronous update operation.