Table of Contents

Class CalculatedObservationsService

Namespace
adas_core.Application.Services
Assembly
adas-core.Application.dll

Implements the ICalculatedObservationsService contract, providing a service for working with calculated observations.

public class CalculatedObservationsService : ICalculatedObservationsService
Inheritance
CalculatedObservationsService
Implements
Inherited Members
Extension Methods

Constructors

CalculatedObservationsService(IOptions<ApiSettings>, IServiceProvider, ILogger<CalculatedObservationsService>)

public CalculatedObservationsService(IOptions<ApiSettings> apiSettings, IServiceProvider serviceProvider, ILogger<CalculatedObservationsService> logger)

Parameters

apiSettings IOptions<ApiSettings>
serviceProvider IServiceProvider
logger ILogger<CalculatedObservationsService>

Methods

CalculateBolusOpiates(ObjectId)

Asynchronously calculates the active bolus dosage of opiates for the specified patient by delegating to the underlying service. If the service dependency is not initialized, the call is skipped silently as a no-op fallback.

public Task CalculateBolusOpiates(ObjectId patientId)

Parameters

patientId ObjectId

The unique identifier of the patient for whom the active bolus opiates calculation is performed.

Returns

Task

CalculateMedicineObservation(List<Medicine>, ObjectId)

Asynchronously calculates medicine observations for a patient based on their active medicines. Delegates the calculation to the underlying service if it has been initialized; otherwise, the call is silently skipped.

public virtual Task CalculateMedicineObservation(List<Medicine> activeMedicines, ObjectId patientId)

Parameters

activeMedicines List<Medicine>

The list of medicines currently active for the patient.

patientId ObjectId

The unique identifier of the patient whose medicine observations are being calculated.

Returns

Task

GetActiveTreatmentsByPatient(ObjectId)

Retrieves the active treatments associated with the specified patient. If the underlying service is not available, returns an empty list as a fallback instead of throwing.

public virtual Task<IEnumerable<PatientTreatment?>> GetActiveTreatmentsByPatient(ObjectId id)

Parameters

id ObjectId

The unique identifier of the patient whose active treatments should be retrieved.

Returns

Task<IEnumerable<PatientTreatment>>

A task that yields the collection of active PatientTreatment entries for the patient, or an empty list when the service is unavailable.

Map(PatientDiagnosis)

Maps a PatientDiagnosis by delegating to the configured mapping service. If no service is available, the original diagnosis is returned as a fallback.

public virtual Task<PatientDiagnosis?> Map(PatientDiagnosis diagnosis)

Parameters

diagnosis PatientDiagnosis

The patient diagnosis to be mapped.

Returns

Task<PatientDiagnosis>

A task that yields the mapped PatientDiagnosis, or null if the underlying service returns no result.

Map(PatientObservation, bool)

Maps a PatientObservation by delegating to the configured mapping service. If no service is available, the original observation is returned unchanged; if the service produces no mapping, a debug message is logged and null is returned.

public virtual Task<PatientObservation?> Map(PatientObservation obs, bool onlyByName = false)

Parameters

obs PatientObservation

The patient observation to map.

onlyByName bool

When true, restricts the mapping to lookups by name only.

Returns

Task<PatientObservation>

The mapped PatientObservation, or null when the service yields no result; the input obs is returned unchanged when no mapping service is configured.

Map(PatientObservationAlarm, bool)

Maps a PatientObservationAlarm using the configured mapping service. Falls back to returning the original alarm unchanged when no service is available, and logs a debug entry when the service produces a null result (i.e., the alarm is ignored).

public virtual Task<PatientObservationAlarm?> Map(PatientObservationAlarm obs, bool onlyByName = false)

Parameters

obs PatientObservationAlarm

The patient observation alarm to be mapped.

onlyByName bool

When true, restricts the mapping to a name-based lookup only.

Returns

Task<PatientObservationAlarm>

The mapped PatientObservationAlarm, or null if the service mapped it to null, or the original obs when no service is configured.

Map(PatientRecordingAlert)

Maps a PatientRecordingAlert using the configured mapping service. Falls back to returning the original alert when no service is configured, and logs a debug entry when the service produces no mapping.

public Task<PatientRecordingAlert?> Map(PatientRecordingAlert obs)

Parameters

obs PatientRecordingAlert

The PatientRecordingAlert instance to be mapped.

Returns

Task<PatientRecordingAlert>

The mapped PatientRecordingAlert, the original obs if no service is available, or null if the service returned no result.

Map(PatientTreatment)

Asynchronously maps a PatientTreatment using the underlying service. If the service is unavailable (null), the original treatment is returned unchanged as a fallback.

public Task<PatientTreatment?> Map(PatientTreatment treatment)

Parameters

treatment PatientTreatment

The patient treatment instance to be mapped or transformed.

Returns

Task<PatientTreatment>

A task that represents the asynchronous mapping operation, containing the mapped PatientTreatment or null if the service returns no result.

Map(PumpObservation)

Maps the supplied PumpObservation by delegating to the configured mapping service. Returns null when the underlying service has not been initialized.

public virtual Task<PumpObservation?> Map(PumpObservation obs)

Parameters

obs PumpObservation

The pump observation to be mapped.

Returns

Task<PumpObservation>

A task that yields the mapped PumpObservation, or null if no mapping service is available.

MapList(List<PatientObservation>)

Maps a list of patient observations by delegating to the configured service's pre-mapping logic when available; otherwise, returns an empty list.

public virtual Task<List<PatientObservation>> MapList(List<PatientObservation> listToInsert)

Parameters

listToInsert List<PatientObservation>

The list of patient observations to be mapped.

Returns

Task<List<PatientObservation>>

A task containing the mapped list of patient observations, or an empty list if no service is configured.

MapSourceAlarm(PatientObservation, PatientObservationAlarm)

Maps a source alarm onto the given patient observation by delegating to the configured service when available; if no service is configured, returns the original observation unchanged.

public virtual Task<PatientObservation> MapSourceAlarm(PatientObservation observation, PatientObservationAlarm observationAlarm)

Parameters

observation PatientObservation

The patient observation onto which the source alarm will be mapped.

observationAlarm PatientObservationAlarm

The source alarm to be applied to the observation.

Returns

Task<PatientObservation>

The PatientObservation produced by the service mapping, or the original observation when no service is configured.