# Class CalculatedObservations

Namespace
  adas_core.Application.Customizations.HGM

Assembly
  adas-core.Application.dll

Represents a collection of calculated observations, providing a concrete implementation of the ICalculatedObservations contract.

    public class CalculatedObservations : ICalculatedObservations

Inheritance
  object
  CalculatedObservations

Implements
  ICalculatedObservations

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

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

## Constructors

### CalculatedObservations(IServiceProvider)

    public CalculatedObservations(IServiceProvider serviceProvider)

#### Parameters

`serviceProvider` IServiceProvider

## Methods

### CalculateActiveBolus(ObjectId)

Asynchronously calculates the active bolus for the specified patient.

    public Task CalculateActiveBolus(ObjectId patientId)

#### Parameters

`patientId` ObjectId

  The unique identifier of the patient for whom the active bolus is calculated.

#### Returns

Task

#### Exceptions

NotImplementedException

  The method is not yet implemented.

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

Calculates the medicine observation for a patient based on the provided active medicines.

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

#### Parameters

`activeMedicines` List<Medicine>

  The list of active medicines currently associated with the patient.

`patientId` ObjectId

  The unique identifier of the patient for whom the observation is being calculated.

#### Returns

Task

#### Exceptions

NotImplementedException

  The method is not yet implemented.

### FixTimeInconsistencyWithLast(PatientObservation)

Resolves time inconsistencies between the specified `newObservation` and the last recorded patient observation, returning a corrected observation when applicable.

    public Task<PatientObservation?> FixTimeInconsistencyWithLast(PatientObservation newObservation)

#### Parameters

`newObservation` PatientObservation

  The new patient observation to reconcile against the last recorded observation.

#### Returns

Task<PatientObservation>

  A task that returns the corrected PatientObservation, or `null` when no last observation is available to compare against.

#### Exceptions

NotImplementedException

  The method is not yet implemented.

### GetActiveTreatmentsByPatient(ObjectId)

Retrieves the active treatments currently associated with the specified patient.

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

#### Parameters

`id` ObjectId

  The identifier of the patient whose active treatments are being requested.

#### Returns

Task<IEnumerable<PatientTreatment>>

  A task that yields a collection of active PatientTreatment entries for the patient.

#### Exceptions

NotImplementedException

  Thrown because the method has not been implemented yet.

### Map(PatientDiagnosis)

Maps the provided patient diagnosis to the target representation asynchronously.

    public 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.

#### Exceptions

NotImplementedException

  Thrown when the method is invoked, as the mapping logic has not been implemented yet.

### Map(PatientTreatment)

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

    public Task<PatientTreatment> Map(PatientTreatment treatment)

#### Parameters

`treatment` PatientTreatment

  The PatientTreatment instance to be mapped.

#### Returns

Task<PatientTreatment>

  A task that represents the asynchronous mapping operation, containing the resulting PatientTreatment.

#### Exceptions

NotImplementedException

  Thrown to indicate that the method has not yet been implemented.

### Map(PumpObservation)

Maps the provided PumpObservation by returning it unchanged, wrapped in a completed task.

    public Task<PumpObservation> Map(PumpObservation pumpObservation)

#### Parameters

`pumpObservation` PumpObservation

  The pump observation to map.

#### Returns

Task<PumpObservation>

  A completed task containing the provided PumpObservation.

### MapSourceAlarm(PatientObservation, PatientObservationAlarm)

Maps a source alarm to a patient observation, returning the provided observation as the result.

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

#### Parameters

`obs` PatientObservation

  The patient observation to return as the mapped result.

`alarmToInsert` PatientObservationAlarm

  The patient observation alarm to be considered during mapping.

#### Returns

Task<PatientObservation>

  A Task<TResult> containing the provided `obs`.

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

Maps a patient observation by applying domain-specific transformations based on the observation name. Handles the "Resp_Mode" case by calculating the ventilation mode, while observations with a null or empty name are returned unchanged.

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

#### Parameters

`obs` T

  The patient observation to be mapped.

`onlyByName` bool

  Flag indicating whether the mapping should be restricted to name-based criteria.

#### Returns

Task<T>

  The mapped patient observation, or the original observation if no applicable mapping is found.

#### Type Parameters

`T`

### PreMapList(List<PatientObservation>)

Pre-maps the provided list of patient observations before further processing, returning the list as-is in a completed task.

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

#### Parameters

`listToInsert` List<PatientObservation>

  The list of patient observations to be pre-mapped.

#### Returns

Task<List<PatientObservation>>

  A completed task containing the provided list of patient observations.

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

Sends an alarm for the specified patient observation.

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

#### Parameters

`obs` PatientObservation

  The patient observation that triggers the alarm.

`name` string

  The name associated with the alarm.

`code` AlarmEnum.Name?

  The optional alarm code identifying the alarm type.

#### Returns

Task

  A task that represents the asynchronous alarm sending operation.

#### Exceptions

NotImplementedException

  Thrown when the method is invoked, as it is not yet implemented.