# Class CalculatedObservations

Namespace
  adas_core.Application.Customizations.CHUO

Assembly
  adas-core.Application.dll

Provides calculated observation data by implementing 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?)

## Remarks

Instances are constructed with an IServiceProvider used to resolve dependencies required by the implementation.

## Constructors

### CalculatedObservations(IServiceProvider)

Provides calculated observation data by implementing the ICalculatedObservations contract.

    public CalculatedObservations(IServiceProvider serviceProvider)

#### Parameters

`serviceProvider` IServiceProvider

#### Remarks

Instances are constructed with an IServiceProvider used to resolve dependencies required by the implementation.

## 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 being calculated.

#### Returns

Task

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

Calculates medicine observations for the specified patient based on the provided active medicines.

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

#### Parameters

`activeMedicines` List<Medicine>

  The list of medicines currently active for the patient.

`patientId` ObjectId

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

#### Returns

Task

### FixTimeInconsistencyWithLast(PatientObservation)

Resolves time inconsistencies between a new patient observation and the most recent one, returning a corrected observation when a discrepancy is detected.

    public Task<PatientObservation?> FixTimeInconsistencyWithLast(PatientObservation newObservation)

#### Parameters

`newObservation` PatientObservation

  The new patient observation to compare and reconcile against the last stored observation.

#### Returns

Task<PatientObservation>

  A task that yields the corrected PatientObservation, or `null` when no time inconsistency is found.

#### Exceptions

NotImplementedException

  Thrown because the method has not been implemented yet.

### GetActiveTreatmentsByPatient(ObjectId)

Retrieves the active treatment records associated with the specified patient.

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

#### Parameters

`id` ObjectId

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

#### Returns

Task<IEnumerable<PatientTreatment>>

  A task that represents the asynchronous operation. The task result contains a collection of nullable PatientTreatment objects representing the patient's active treatments.

#### Exceptions

NotImplementedException

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

### Map(PatientDiagnosis)

Maps a PatientDiagnosis instance to a PatientDiagnosis result.

    public Task<PatientDiagnosis> Map(PatientDiagnosis diagnosis)

#### Parameters

`diagnosis` PatientDiagnosis

  The patient diagnosis to be mapped.

#### Returns

Task<PatientDiagnosis>

  A task representing the asynchronous operation, containing the mapped PatientDiagnosis.

#### Exceptions

NotImplementedException

  Thrown because the mapping logic has not yet been implemented.

### Map(PatientTreatment)

Maps the specified PatientTreatment to a resulting PatientTreatment instance asynchronously.

    public Task<PatientTreatment> Map(PatientTreatment treatment)

#### Parameters

`treatment` PatientTreatment

  The patient treatment to be mapped.

#### Returns

Task<PatientTreatment>

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

#### Exceptions

NotImplementedException

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

### Map(PumpObservation)

Asynchronously maps the provided PumpObservation instance, returning the same instance as the result.

    public Task<PumpObservation> Map(PumpObservation pumpObservation)

#### Parameters

`pumpObservation` PumpObservation

  The pump observation to map.

#### Returns

Task<PumpObservation>

  A Task<TResult> containing the provided pump observation.

### MapSourceAlarm(PatientObservation, PatientObservationAlarm)

Maps a source alarm onto a PatientObservation, returning the observation as-is without applying the alarm's changes.

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

#### Parameters

`obs` PatientObservation

  The existing patient observation to be returned.

`alarmToInsert` PatientObservationAlarm

  The alarm to be associated with the observation (currently not applied).

#### Returns

Task<PatientObservation>

  A completed Task<TResult> containing the original observation.

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

Maps a patient observation by returning it as-is, logging the operation as a trace entry.

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

#### Parameters

`obs` T

  The patient observation to map.

`onlyByName` bool

  Indicates whether mapping should be performed by name only.

#### Returns

Task<T>

  A task containing the provided observation.

#### Type Parameters

`T`

### PreMapList(List<PatientObservation>)

Performs a pre-mapping step on a list of patient observations before they are inserted. Currently acts as a pass-through, returning the provided list unchanged as a completed task, but can be overridden to apply transformations or validations.

    public 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 completed task containing the provided list of patient observations.

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

Sends an alarm notification for the specified patient observation, identified by the given name and optional alarm code.

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

#### Parameters

`obs` PatientObservation

  The patient observation that triggers the alarm.

`name` string

  The name of the alarm to send.

`code` AlarmEnum.Name?

  The optional alarm code providing additional classification for the alarm.

#### Returns

Task