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
apiSettingsIOptions<ApiSettings>serviceProviderIServiceProviderloggerILogger<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
patientIdObjectIdThe unique identifier of the patient for whom the active bolus opiates calculation is performed.
Returns
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
activeMedicinesList<Medicine>The list of medicines currently active for the patient.
patientIdObjectIdThe unique identifier of the patient whose medicine observations are being calculated.
Returns
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
idObjectIdThe 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
diagnosisPatientDiagnosisThe patient diagnosis to be mapped.
Returns
- Task<PatientDiagnosis>
A task that yields the mapped PatientDiagnosis, or
nullif 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
obsPatientObservationThe patient observation to map.
onlyByNameboolWhen
true, restricts the mapping to lookups by name only.
Returns
- Task<PatientObservation>
The mapped PatientObservation, or
nullwhen the service yields no result; the inputobsis 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
obsPatientObservationAlarmThe patient observation alarm to be mapped.
onlyByNameboolWhen true, restricts the mapping to a name-based lookup only.
Returns
- Task<PatientObservationAlarm>
The mapped PatientObservationAlarm, or
nullif the service mapped it to null, or the originalobswhen 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
obsPatientRecordingAlertThe PatientRecordingAlert instance to be mapped.
Returns
- Task<PatientRecordingAlert>
The mapped PatientRecordingAlert, the original
obsif no service is available, ornullif 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
treatmentPatientTreatmentThe patient treatment instance to be mapped or transformed.
Returns
- Task<PatientTreatment>
A task that represents the asynchronous mapping operation, containing the mapped PatientTreatment or
nullif 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
obsPumpObservationThe 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
listToInsertList<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
observationPatientObservationThe patient observation onto which the source alarm will be mapped.
observationAlarmPatientObservationAlarmThe source alarm to be applied to the observation.
Returns
- Task<PatientObservation>
The PatientObservation produced by the service mapping, or the original
observationwhen no service is configured.