Class CalculatedObservations
- Namespace
- adas_core.Application.Customizations.HRYC
- Assembly
- adas-core.Application.dll
Implements the HRYC-specific clinical calculations that derive secondary PatientObservation values (NEWS alarms, IROX, Resp_Rate_Calculated, Hydric_Balance_Calculated, Weight_Diff, Diuresis_Weight, Delta_Pressure, Daily_Balance_Calculated, Allergies, DVE, Drainage_Height, Resp_Type, and Hour_Balance) from incoming raw observations and active configurations loaded from ApiSettings.
public class CalculatedObservations : ICalculatedObservations
- Inheritance
-
CalculatedObservations
- Implements
- Inherited Members
- Extension Methods
Constructors
CalculatedObservations(IServiceProvider)
Initializes a new instance of the CalculatedObservations class, resolving its dependencies (observation, patient, light-beacon, and config-observation services, plus the logger) from the supplied IServiceProvider and loading the configured code catalogues (high-frequency ventilation, non-invasive ventilation, and invasive ventilation) from ApiSettings.
public CalculatedObservations(IServiceProvider serviceProvider)
Parameters
serviceProviderIServiceProviderThe application's service provider used to resolve the required dependencies and configuration.
Methods
CalculateActiveBolus(ObjectId)
No-op implementation of the active-bolus calculation hook. The HRYC customization does not derive an OpiateBoluses observation.
public Task CalculateActiveBolus(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient (ignored).
Returns
- Task
A completed task.
CalculateMedicineObservation(List<Medicine>, ObjectId)
No-op implementation of the medicine-observation calculation hook. The HRYC customization does not derive Medication or ERMedication observations from the active medicine list.
public Task CalculateMedicineObservation(List<Medicine> activeMedicines, ObjectId patientId)
Parameters
activeMedicinesList<Medicine>The list of active medicines (ignored).
patientIdObjectIdThe unique identifier of the patient (ignored).
Returns
- Task
A completed task.
FixTimeInconsistencyWithLast(PatientObservation)
Resolves time-inconsistencies for a new patient observation when it arrives with the same
(down-to-the-second) timestamp as the latest stored observation of the same name. The new
observation's Time is shifted forward by one second to avoid duplicate-key collisions.
public Task<PatientObservation?> FixTimeInconsistencyWithLast(PatientObservation newObservation)
Parameters
newObservationPatientObservationThe new patient observation to evaluate for time inconsistencies.
Returns
- Task<PatientObservation>
A task that resolves to the (possibly time-shifted) PatientObservation. Returns the input unchanged when its
Nameis null or empty, logging the error.
GetActiveTreatmentsByPatient(ObjectId)
Returns an empty enumerable of active treatments. The HRYC customization does not currently maintain a per-patient active-treatment cache.
public Task<IEnumerable<PatientTreatment?>> GetActiveTreatmentsByPatient(ObjectId id)
Parameters
idObjectIdThe unique identifier of the patient (ignored).
Returns
- Task<IEnumerable<PatientTreatment>>
A completed task containing an empty IEnumerable<T>.
Map(PatientDiagnosis)
Identity mapping for a PatientDiagnosis: returns the supplied instance unchanged, wrapped in a completed task. Provided to satisfy the customization contract.
public Task<PatientDiagnosis> Map(PatientDiagnosis diagnosis)
Parameters
diagnosisPatientDiagnosisThe PatientDiagnosis to map.
Returns
- Task<PatientDiagnosis>
A task containing the same PatientDiagnosis instance that was passed in.
Map(PatientTreatment)
Placeholder mapping for a PatientTreatment. The HRYC customization does not currently derive observations from treatments.
public Task<PatientTreatment> Map(PatientTreatment treatment)
Parameters
treatmentPatientTreatmentThe treatment to map.
Returns
- Task<PatientTreatment>
Never returns a result.
Exceptions
- NotImplementedException
Always thrown because treatment mapping is not implemented in the HRYC customization.
Map(PumpObservation)
Identity mapping for a PumpObservation: returns the supplied instance unchanged, wrapped in a completed task. Provided to satisfy the customization contract; pump observations do not require HRYC-specific calculation.
public Task<PumpObservation> Map(PumpObservation pumpObservation)
Parameters
pumpObservationPumpObservationThe pump observation to map.
Returns
- Task<PumpObservation>
A task containing the same PumpObservation instance that was passed in.
MapSourceAlarm(PatientObservation, PatientObservationAlarm)
Identity mapping for a source alarm observation paired with a PatientObservationAlarm: returns the supplied observation unchanged, wrapped in a completed task. Provided to satisfy the customization contract.
public Task<PatientObservation> MapSourceAlarm(PatientObservation obs, PatientObservationAlarm alarmToInsert)
Parameters
obsPatientObservationThe patient observation that triggered the alarm.
alarmToInsertPatientObservationAlarmThe alarm metadata to be inserted alongside the observation.
Returns
- Task<PatientObservation>
A task containing the same PatientObservation instance that was passed in.
Map<T>(T, bool)
Dispatches the supplied raw observation to the appropriate HRYC calculation based on its
Name. The set of supported calculations includes
Resp_Mode (ventilation type), Diuresis / Weight_Current
(weight difference and diuresis-per-kilogram), AllergiesObs, DrainagesObs,
PEEP / Pleateu_Pressure (driving pressure), Daily_Balance,
Hydric_Balance / Hour_Balance (time shifting), FR / Vent_Rate
(respiratory rate), SpO2 / FiO2 (IROX), and NEWS (alarms).
public Task<T?> Map<T>(T obs, bool onlyByName) where T : BasePatientObservation
Parameters
obsTThe observation to map or transform in-place.
onlyByNameboolReserved for future use. When true, restricts the mapping strategy to name-based lookups only.
Returns
- Task<T>
A Task<TResult> that resolves to the (possibly transformed) observation, or null when the input observation has no name.
Type Parameters
TThe concrete observation type, deriving from BasePatientObservation.
PreMapList(List<PatientObservation>)
Pre-maps a batch of patient observations, optimising the order in which they are persisted
when both Vent_Rate and FR are present. If both observations are present with
non-zero values, Vent_Rate is inserted first (and removed from the returned list) so
that adas_core.Application.Customizations.HRYC.CalculatedObservations.CalculateRespRate(adas_core.Domain.Models.BasePatientObservation) can derive Resp_Rate_Calculated correctly.
public Task<List<PatientObservation>> PreMapList(List<PatientObservation> listToInsert)
Parameters
listToInsertList<PatientObservation>The list of patient observations to pre-map. Modified in-place.
Returns
- Task<List<PatientObservation>>
A task that resolves to the resulting list of observations (with
Vent_Rateremoved when it was inserted synchronously, or the original list otherwise).
SendAlarm(PatientObservation, string, Name?)
Placeholder alarm dispatch hook used by the customization contract. The HRYC customization
dispatches NEWS alarms through its private SendAlarm(BasePatientObservation, AlarmEnum.Name)
overload; calling this public overload always throws.
public Task SendAlarm(PatientObservation obs, string name, AlarmEnum.Name? code)
Parameters
obsPatientObservationThe patient observation that triggered the alarm.
namestringThe alarm display name.
codeAlarmEnum.Name?The optional alarm code from AlarmEnum.Name.
Returns
- Task
Never returns a result.
Exceptions
- NotImplementedException
Always thrown because this overload is not used in the HRYC customization.