# Class CalculatedObservationsTest

Namespace
  adas_core.Test.Customizations.HPAZ

Assembly
  adas-core.Test.dll

    [TestFixture]
    public class CalculatedObservationsTest

Inheritance
  object
  CalculatedObservationsTest

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?)

## Methods

### CalculateOxygenationIndex_FiO2_Returns_Oxygenation_Index()

Verifies that when an FiO2 observation is processed, the Oxygenation Index is calculated and inserted using the related P_VAM and PaO2_Tidal observations retrieved for the same patient.

    [Test]
    public Task CalculateOxygenationIndex_FiO2_Returns_Oxygenation_Index()

#### Returns

Task

### CalculateOxygenationIndex_P_VAM_Returns_Oxygenation_Index()

Verifies that mapping a `P_VAM` patient observation produces a derived `Oxygenation_Index` observation (computed as `P_VAM × FiO2 × 100 / PaO2`) that is inserted through the observation service for the same patient.

    [Test]
    public Task CalculateOxygenationIndex_P_VAM_Returns_Oxygenation_Index()

#### Returns

Task

  A task that completes when the expected `Oxygenation_Index` observation has been inserted via the mocked observation service.

### CalculateOxygenationIndex_PaO2_Tidal_0_Not_Returns_Oxygenation_Index()

Verifies that the Oxygenation_Index is not calculated or persisted when the PaO2_Tidal observation value is zero. Ensures that the mapping logic skips downstream calculation and InsertObservation is never invoked in this edge case.

    [Test]
    public Task CalculateOxygenationIndex_PaO2_Tidal_0_Not_Returns_Oxygenation_Index()

#### Returns

Task

### CalculateOxygenationIndex_PaO2_Tidal_Not_Returns_Oxygenation_Index()

Verifies that the oxygenation index is not calculated and persisted when the required FiO2 observation is missing from the patient's most recent observations, even when a PaO2_Tidal observation is provided. Ensures that the mapping logic does not insert a new Oxygenation_Index observation in this scenario.

    [Test]
    public Task CalculateOxygenationIndex_PaO2_Tidal_Not_Returns_Oxygenation_Index()

#### Returns

Task

### CalculateOxygenationIndex_PaO2_Tidal_Returns_Oxygenation_Index()

Verifies that when a PaO2_Tidal observation is mapped, the calculated Oxygenation_Index is derived using the formula P_VAM * FiO2 * 100 / PaO2_Tidal and persisted as an ADAS-coded observation for the same patient.

    [Test]
    public Task CalculateOxygenationIndex_PaO2_Tidal_Returns_Oxygenation_Index()

#### Returns

Task

### CalculatePF_FiO2_0_Not_Returns_PaO2_FiO2()

Verifies that the PF ratio calculation does not produce a PaO2/FiO2 observation when the FiO2 value is zero. Ensures that no calculated observation is inserted for the patient under this condition.

    [Test]
    public Task CalculatePF_FiO2_0_Not_Returns_PaO2_FiO2()

#### Returns

Task

### CalculatePF_FiO2_Returns_PaO2_FiO2()

Verifies that the calculated observation mapping produces a PaO2/FiO2 ratio observation when an FiO2 observation is processed, by inserting a new patient observation with the expected ratio value and coding system.

    [Test]
    public Task CalculatePF_FiO2_Returns_PaO2_FiO2()

#### Returns

Task

### CalculatePF_PaO2_Returns_PaO2_FiO2()

Verifies that the mapping process correctly computes the PaO2/FiO2 ratio when a PaO2 observation is provided, by dividing the PaO2 value by the most recent FiO2 observation for the patient and inserting the result as a new PatientObservation with the ADAS coding system.

    [Test]
    public Task CalculatePF_PaO2_Returns_PaO2_FiO2()

#### Returns

Task

### CalculateSF_Sattc_98_Returns_Not_Sattc_FiO2()

Verifies that the calculated observations mapping does not produce a Sattc_FiO2 observation when the Sattc value is 98, ensuring the calculation is suppressed for this specific input case.

    [Test]
    public Task CalculateSF_Sattc_98_Returns_Not_Sattc_FiO2()

#### Returns

Task

### Calculate_Ventilation_Mode_FLUJ_ALTO_Returns_OAF()

Verifies that the calculated observations mapping translates the ventilation mode value "FLUJ.ALTO" (High Flow) into the respiratory support code "OAF". Ensures that a patient observation with the name "Resp_Mode" and value "FLUJ.ALTO" produces a non-null mapped result with the expected output value.

    [Test]
    public Task Calculate_Ventilation_Mode_FLUJ_ALTO_Returns_OAF()

#### Returns

Task

### Calculate_Ventilation_Mode_Not_PRVC_Not_FLUJ_ALTO_Returns_Other()

Verifies that when a patient observation's respiratory mode is neither "PRVC" nor "FLUJ_ALTO" (for example, "VNI PC"), the calculated observation is not mapped to "VCRP" or "OAF".

    [Test]
    public Task Calculate_Ventilation_Mode_Not_PRVC_Not_FLUJ_ALTO_Returns_Other()

#### Returns

Task

### Calculate_Ventilation_Mode_PRVC_Returns_VCRP()

Verifies that a PatientObservation with the ventilation mode "PRVC" is mapped to a calculated observation with the value "VCRP".

    [Test]
    public Task Calculate_Ventilation_Mode_PRVC_Returns_VCRP()

#### Returns

Task

### Map_PatientObservation_Alarm_Pump_Retur_obs()

Verifies that a PatientObservation representing a pump volumetric air occlusion alarm is correctly mapped by the calculated observations mapper, returning a non-null result with a matching name.

    [Test]
    public Task Map_PatientObservation_Alarm_Pump_Retur_obs()

#### Returns

Task

### Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_Aux_PositionName()

    [Test]
    public Task Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_Aux_PositionName()

#### Returns

Task

### Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_PositionName()

    [Test]
    public Task Map_PumpObservation_DrugName_Null_AlarmType_Occlusion_Return_Insert_Pump_Insert_PositionName()

#### Returns

Task

### SendAlarm_BlueCode_FC_SpO2_Alarm_True_Returns_SendAlarm_BlueCode()

Verifies that when patient observations include a low SpO2 (Sattc) value of 50 and a low FC value of 50, the calculated observations processing triggers a BlueCode alarm by inserting the observation and sending the alarm.

    [Test]
    public Task SendAlarm_BlueCode_FC_SpO2_Alarm_True_Returns_SendAlarm_BlueCode()

#### Returns

Task

### SendAlarm_BlueCode_FC_TAm_Alarm_False()

Verifies that a BlueCode alarm is not triggered when the heart rate (FC) is at 50 and the mean arterial pressure (TAm) values do not meet the BlueCode criteria.

    [Test]
    public Task SendAlarm_BlueCode_FC_TAm_Alarm_False()

#### Returns

Task

### SendAlarm_BlueCode_FC_TAm_Alarm_True_Returns_SendAlarm_BlueCode()

Verifies that when a BlueCode alarm condition is triggered by FC and TAm observations, the calculated blue code list is generated, the observation is inserted, and the blue code alarm is sent with the expected severity and type.

    [Test]
    public Task SendAlarm_BlueCode_FC_TAm_Alarm_True_Returns_SendAlarm_BlueCode()

#### Returns

Task

  A task that completes when the blue code alarm verification has been executed.

### Setup()

Initializes mocked dependencies and configures the dependency injection container required to instantiate the CalculatedObservations service under test.

    [SetUp]
    public void Setup()