# Interface ICalculatedObservations

Namespace
  adas_core.Application.Services.Interfaces

Assembly
  adas-core.Application.dll

    public interface ICalculatedObservations

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Methods

### CalculateActiveBolus(ObjectId)

Calculates the active bolus for the specified patient.

    Task CalculateActiveBolus(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient whose active bolus is to be calculated.

#### Returns

Task

### CalculateMedicineObservation(List<Medicine>, ObjectId)

Asynchronously calculates a medicine observation for a patient based on their active medicines.

    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 observation is being calculated.

#### Returns

Task

### FixTimeInconsistencyWithLast(PatientObservation)

Resolves time inconsistencies between the new observation and the last stored observation, returning a corrected version when applicable.

    Task<PatientObservation?> FixTimeInconsistencyWithLast(PatientObservation newObservation)

#### Parameters

`newObservation` PatientObservation

  The new patient observation to validate and reconcile against the previous observation's time information.

#### Returns

Task<PatientObservation>

  A task that yields the fixed PatientObservation, or `null` when no time inconsistency is detected or no correction is required.

### GetActiveTreatmentsByPatient(ObjectId)

Retrieves the active treatments associated with a specific patient by their unique identifier.

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

#### Parameters

`id` ObjectId

  The unique identifier of the patient whose active treatments are being queried.

#### Returns

Task<IEnumerable<PatientTreatment>>

  A task that represents the asynchronous operation, containing a collection of nullable PatientTreatment entries that represent the active treatments for the specified patient.

### Map(PatientDiagnosis)

Asynchronously maps a PatientDiagnosis to a PatientDiagnosis representation.

    Task<PatientDiagnosis> Map(PatientDiagnosis diagnosis)

#### Parameters

`diagnosis` PatientDiagnosis

  The patient diagnosis to be mapped.

#### Returns

Task<PatientDiagnosis>

  A task that represents the asynchronous mapping operation, containing the mapped PatientDiagnosis.

### Map(PatientTreatment)

Asynchronously maps the specified `treatment` to a PatientTreatment result.

    Task<PatientTreatment> Map(PatientTreatment treatment)

#### Parameters

`treatment` PatientTreatment

  The patient treatment instance to map.

#### Returns

Task<PatientTreatment>

  A task that represents the asynchronous mapping operation. The task result contains the mapped PatientTreatment.

### Map(PumpObservation)

Asynchronously maps the specified PumpObservation to a PumpObservation result.

    Task<PumpObservation> Map(PumpObservation pumpObservation)

#### Parameters

`pumpObservation` PumpObservation

  The PumpObservation to be mapped.

#### Returns

Task<PumpObservation>

  A Task<TResult> representing the asynchronous operation, containing the mapped PumpObservation.

### MapSourceAlarm(PatientObservation, PatientObservationAlarm)

Maps the source alarm onto the specified patient observation and returns the resulting observation.

    Task<PatientObservation> MapSourceAlarm(PatientObservation obs, PatientObservationAlarm alarmToInsert)

#### Parameters

`obs` PatientObservation

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

`alarmToInsert` PatientObservationAlarm

  The patient observation alarm to insert and map as the source alarm.

#### Returns

Task<PatientObservation>

  A task representing the asynchronous operation, containing the patient observation with the source alarm mapped.

### Map<T>(T, bool)

Asynchronously maps a patient observation to a corresponding target type, optionally restricting the mapping to name-based matching only.

    Task<T?> Map<T>(T obs, bool onlyByName = false) where T : BasePatientObservation

#### Parameters

`obs` T

  The source patient observation to be mapped.

`onlyByName` bool

  When set to `true`, the mapping is performed considering only the observation name; otherwise, additional mapping criteria are applied. Defaults to `false`.

#### Returns

Task<T>

  A Task<TResult> that represents the asynchronous mapping operation. The result is the mapped observation of type `T`, or `null` when no matching mapping is found.

#### Type Parameters

`T`

### PreMapList(List<PatientObservation>)

Performs pre-insertion mapping on a list of patient observations, transforming or preparing the data before it is persisted.

    Task<List<PatientObservation>> PreMapList(List<PatientObservation> listToInsert)

#### Parameters

`listToInsert` List<PatientObservation>

  The list of patient observations to be pre-mapped prior to insertion.

#### Returns

Task<List<PatientObservation>>

  A task that represents the asynchronous operation, containing the mapped list of patient observations.

### SendAlarm(PatientObservation, string, Name?)

Sends an alarm associated with the specified patient observation, optionally classified by an alarm code.

    Task SendAlarm(PatientObservation obs, string name, AlarmEnum.Name? code)

#### Parameters

`obs` PatientObservation

  The patient observation that triggered the alarm.

`name` string

  The name associated with the alarm.

`code` AlarmEnum.Name?

  An optional alarm code categorizing the type of alarm to send.

#### Returns

Task