Table of Contents

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

patient Patient

The patient whose record is to be archived.

Returns

Task

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

observation PatientObservation

The 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

id ObjectId

The unique identifier of the patient whose records should be archived.

Returns

Task

CheckAndExpireObservations()

Checks observations and expires those that meet the expiration criteria.

Task CheckAndExpireObservations()

Returns

Task

DeleteByPatientId(ObjectId)

Asynchronously deletes records associated with the specified patient identifier.

Task DeleteByPatientId(ObjectId id)

Parameters

id ObjectId

The MongoDB.Bson.ObjectId of the patient whose related records should be removed.

Returns

Task

ExpireAlertsAndPowerOffAsync()

Asynchronously expires active alerts and powers off the device.

Task ExpireAlertsAndPowerOffAsync()

Returns

Task

ExpireObservations()

Asynchronously processes and expires observations that have exceeded their validity period.

Task ExpireObservations()

Returns

Task

ExpireObservationsAndRecalculateAsync()

Asynchronously expires observations that are no longer valid and recalculates the dependent data.

Task ExpireObservationsAndRecalculateAsync()

Returns

Task

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

patientId ObjectId

The identifier of the patient whose observations are being queried.

date DateTime

The cutoff date; only observations with a timestamp after this value are returned.

filterObservations List<string>

An optional list of observation names to restrict the result to. When null or 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

patientId ObjectId

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

date DateTime

The cutoff date; only observations recorded before this date will be returned.

filterObservations List<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

patientId ObjectId

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

startDate DateTime?

The inclusive lower bound of the observation date range, or null to apply no lower bound.

endDate DateTime?

The inclusive upper bound of the observation date range, or null to apply no upper bound.

filterObservations List<string>

An optional list of observation names used to restrict the returned observations.

fromArchived bool

When true, observations are retrieved from archived records; otherwise, only active records are considered.

filter PaginationFilter

An 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

patientId ObjectId

The identifier of the patient whose observations will be searched.

date DateTime

The date used to match observations.

obsName string

The 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

patientId ObjectId

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

codingSystem string

The coding system used to classify the observations (e.g., LOINC, SNOMED).

name string

The 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

patientId ObjectId

The 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

patientId ObjectId

The unique identifier of the patient whose observation is being queried.

date DateTime

The cutoff date; only observations recorded strictly before this date are considered.

obsName string

The optional name of the observation to filter by, or null to match any observation.

Returns

Task<PatientObservation>

A task that represents the asynchronous operation. The task result contains the latest matching PatientObservation, or null if 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

patientId ObjectId

The 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 null when 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

patientId ObjectId

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

name string

The name of the observation type used to filter the results.

endAfter int?

Optional parameter that defines the pagination boundary; when provided, observations are returned starting after this position.

num int?

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

patientId ObjectId

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

num int

The maximum number of most recent observations to return. Defaults to 2.

filterObservations List<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

patientId ObjectId

The identifier of the patient whose observations are being retrieved.

filterObservations List<Field>

An optional list of fields used to restrict which observations are returned. When null, observations for all fields are considered.

mapped bool

Indicates whether the returned observations should be mapped (default true) or returned in their raw form.

ct CancellationToken

The 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

patientId ObjectId

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

name string

The name of the observation to filter by.

expires int?

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

filter PaginationFilter

The 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

name string

The name associated with the patient observation being evaluated for changes.

observation PatientObservation

The patient observation to compare against the existing value and potentially insert.

persistObs bool

Indicates whether the observation should be persisted when it is inserted. Defaults to true.

mapObs bool

Indicates whether the observation should be mapped as part of the insert operation. Defaults to true.

Returns

Task<bool>

A task that returns true if the observation was inserted because a change was detected; otherwise, false if no insert was performed.

InsertNurseObservation(PatientObservation)

Inserts a new nurse observation for a patient into the underlying data store.

Task InsertNurseObservation(PatientObservation obs)

Parameters

obs PatientObservation

The patient observation data recorded by the nurse to be persisted.

Returns

Task

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

patientObservation PatientObservation

The patient observation to insert.

persistObs bool

Indicates whether the observation should be persisted; defaults to true.

mapObs bool

Indicates whether the observation should be mapped; defaults to true.

Returns

Task

InsertSimpleObservation(PatientObservation)

Asynchronously inserts a simple patient observation record.

Task InsertSimpleObservation(PatientObservation observation)

Parameters

observation PatientObservation

The 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

obs PatientObservation

The source PatientObservation to be mapped.

onlyByName bool

When 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

obs PatientObservation

The PatientObservation whose name is used to perform the mapping or lookup.

Returns

Task<PatientObservation>

A Task<TResult> that resolves to the matching PatientObservation, or null if 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

observations List<PatientObservation>

The list of patient observations to process.

patient Patient

The patient associated with the observations.

messageTime DateTime

The timestamp of the message containing the observations.

observationData ObservationData

Optional additional data related to the observations.

SaveRequestNurseObsAsync(ApiRequest)

Asynchronously saves a nurse observation request.

Task SaveRequestNurseObsAsync(ApiRequest request)

Parameters

request ApiRequest

The API request containing the nurse observation data to save.

Returns

Task

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

obs List<PatientObservation>

The list of patient observations to be transmitted in the broadcast.

pocId ObjectId

The identifier of the Point of Care system that will receive the observations.

Returns

Task

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

obs List<PatientObservation>

The list of patient observations to include in the broadcast.

location PatientLocation

The target patient location that will receive the broadcast.

Returns

Task

SendObsBroadcast(BasePatientObservation)

Asynchronously broadcasts a patient observation to subscribed listeners or endpoints.

Task SendObsBroadcast(BasePatientObservation obs)

Parameters

obs BasePatientObservation

The base patient observation to be broadcast.

Returns

Task

UpdateExpiredObservations(List<PatientObservation>)

Updates the status of the provided patient observations that have reached their expiration.

Task UpdateExpiredObservations(List<PatientObservation> expiredObservations)

Parameters

expiredObservations List<PatientObservation>

The list of patient observations to update as expired.

Returns

Task

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

nameId string

The name of the identifier field to be updated.

id ObjectId

The new MongoDB.Bson.ObjectId value to assign to the field.

oldId ObjectId

The 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

observation PatientObservation

The patient observation containing the updated information.

Returns

Task

A task that represents the asynchronous update operation.