Class CalculatedObservationsTest
- Namespace
- adas_core.Test.Customizations.HUVH.UCIA
- Assembly
- adas-core.Test.dll
[TestFixture]
[Order(2)]
public class CalculatedObservationsTest
- Inheritance
-
CalculatedObservationsTest
- Inherited Members
- Extension Methods
Methods
CalculateDiuresis_Should_Calculate_Correctly_When_Observations_Are_Available()
Verifies that the diuresis calculation produces the correct value when prior diuresis observations and a weight observation are available for the patient, resulting in a new "Calculated_Diuresis" observation being inserted.
[Test]
public Task CalculateDiuresis_Should_Calculate_Correctly_When_Observations_Are_Available()
Returns
CalculateDiuresis_Should_Not_Calculate_If_Diuresis_Observations_Are_Missing()
Verifies that diuresis is not calculated when no diuresis observations are found for the patient. Ensures the mapping logic skips persistence of a calculated diuresis observation when required prior observations are missing.
[Test]
public Task CalculateDiuresis_Should_Not_Calculate_If_Diuresis_Observations_Are_Missing()
Returns
CalculateDiuresis_Should_Not_Calculate_If_Weight_Is_Invalid()
Verifies that the diuresis calculation is not performed when the patient has no weight observation available, ensuring no new observation is inserted.
[Test]
public Task CalculateDiuresis_Should_Not_Calculate_If_Weight_Is_Invalid()
Returns
CalculateDrivingPressure_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
Verifies that the mapping correctly calculates and inserts the driving pressure (Pmeset minus PEEP) when both source observations are available.
[Test]
public Task CalculateDrivingPressure_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
Returns
CalculateDrivingPressure_Should_Not_Calculate_If_Observation_Is_Missing()
[Test]
public Task CalculateDrivingPressure_Should_Not_Calculate_If_Observation_Is_Missing()
Returns
CalculateEcmoLocation_Should_Not_Change_Value_When_Not_In_Ecmo_List()
Verifies that the ECMO Location mapping does not alter the observation value when the provided value is not present in the recognized ECMO list, leaving the original value unchanged.
[Test]
public Task CalculateEcmoLocation_Should_Not_Change_Value_When_Not_In_Ecmo_List()
Returns
CalculateEcmoLocation_Should_Return_ECMO_When_Value_Is_In_Ecmo_List(string)
Verifies that the mapping logic returns "ECMO" when the observation value is one of the recognized ECMO location codes (e.g., "ECCO2r", "VVDL", "VA+V", "VVDL+V", "VV+V", "VVA").
[Test]
[TestCase("ECCO2r")]
[TestCase("VVDL")]
[TestCase("VA+V")]
[TestCase("VVDL+V")]
[TestCase("VV+V")]
[TestCase("VVA")]
public Task CalculateEcmoLocation_Should_Return_ECMO_When_Value_Is_In_Ecmo_List(string inputValue)
Parameters
inputValuestringThe ECMO location code assigned to the PatientObservation value under test.
Returns
CalculateEcmoLocation_Should_Return_Original_Observation_When_Not_PatientObservation()
Verifies that the mapping of a PatientObservation through the calculated observations mapper returns the original observation unchanged, ensuring the mapping is a no-op for patient observations.
[Test]
public Task CalculateEcmoLocation_Should_Return_Original_Observation_When_Not_PatientObservation()
Returns
CalculateEcmoLocation_Should_Return_VA_When_Value_Is_VA()
Verifies that the ECMO location calculation returns "VA" when the input observation value is "VA".
[Test]
public Task CalculateEcmoLocation_Should_Return_VA_When_Value_Is_VA()
Returns
CalculateEcmoLocation_Should_Return_VV_When_Value_Is_VV()
Verifies that mapping a PatientObservation with Name "ECMO_Location" and Value "VV" returns a non-null result whose value is "VV".
[Test]
public Task CalculateEcmoLocation_Should_Return_VV_When_Value_Is_VV()
Returns
CalculateOverAnalgesia_Should_Create_Observation_When_Conditions_Are_Met()
Verifies that an "Over_Analgesia" observation with value "True" is created when the patient has active analgesic treatments (Morfina, Remifentanilo) and the last ANI observation indicates a high value (80), suggesting over-analgesia.
[Test]
public Task CalculateOverAnalgesia_Should_Create_Observation_When_Conditions_Are_Met()
Returns
CalculateOverAnalgesia_Should_Not_Create_Observation_When_Conditions_Are_Not_Met()
[Test]
public Task CalculateOverAnalgesia_Should_Not_Create_Observation_When_Conditions_Are_Not_Met()
Returns
CalculateOverSedation_Should_Insert_Observation_When_Conditions_Met()
Verifies that an over-sedation observation is inserted when the patient meets the clinical criteria: a RASS observation with a sufficiently low score, recent PSI and TS observations, and an active treatment (e.g., Propofol) with a minimum requested give amount that triggers the over-sedation condition.
[Test]
public Task CalculateOverSedation_Should_Insert_Observation_When_Conditions_Met()
Returns
CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_PSI_Observation()
Verifies that an over-sedation observation is inserted when the calculation is triggered by a PSI observation and the patient's last RASS and TS observations, combined with active treatment data, meet the triggering criteria.
[Test]
public Task CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_PSI_Observation()
Returns
CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_TS_Observation()
Verifies that the over-sedation calculation logic inserts a new observation when a triggering TS (Twitch Score) observation is received, given the presence of related RASS and PSI observations and an active treatment (e.g., Propofol) meeting the required minimum amount threshold.
[Test]
public Task CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_TS_Observation()
Returns
CalculateOverSedation_Should_Not_Insert_Observation_When_No_Treatments_Exceed_Threshold()
Verifies that no observation is inserted when the patient has no active treatments that exceed the configured threshold during the over-sedation calculation.
[Test]
public Task CalculateOverSedation_Should_Not_Insert_Observation_When_No_Treatments_Exceed_Threshold()
Returns
CalculateOverSedation_Should_Not_Insert_Observation_When_PSI_Is_25_Or_Higher()
Verifies that no observation is inserted when calculating over-sedation and the patient's PSI (Sedation Intensity Index) is 25 or higher, which indicates the threshold above which the over-sedation mapping should not produce an observation.
[Test]
public Task CalculateOverSedation_Should_Not_Insert_Observation_When_PSI_Is_25_Or_Higher()
Returns
CalculateOverSedation_Should_Not_Insert_Observation_When_RASS_Is_Not_Negative4_Or_Negative5()
Verifies that no over-sedation observation is inserted when the patient's RASS score is not -4 or -5, ensuring the over-sedation calculation only applies for those specific values.
[Test]
public Task CalculateOverSedation_Should_Not_Insert_Observation_When_RASS_Is_Not_Negative4_Or_Negative5()
Returns
CalculateOverSedation_Should_Not_Insert_Observation_When_TS_Is_5_Or_Lower()
Verifies that the over-sedation calculation does not insert an observation when the patient's TS (Tidal Spontaneous) value is 5 or lower, even with a low RASS score and an elevated PSI value.
[Test]
public Task CalculateOverSedation_Should_Not_Insert_Observation_When_TS_Is_5_Or_Lower()
Returns
CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Condition_Is_Not_Met()
Verifies that the rehabilitation alarm calculation does not set the alert status when the configured condition is not met, even when the most recent observation values are within an expected range and an out-of-range value is present among the evaluated history.
[Test]
public Task CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Condition_Is_Not_Met()
Returns
CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Value_Is_Greater_Than_2()
Verifies that the Map method does not set an alert for a Rehabilitation observation when its value is greater than 2, returning the original observation unchanged.
[Test]
public Task CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Value_Is_Greater_Than_2()
Returns
CalculateRehabilitationAlarm_Should_Return_Same_Observation_If_Not_PatientObservation()
Verifies that the rehabilitation alarm calculation returns the same observation unchanged when the input observation is not a PatientObservation. This ensures that the mapping method does not perform any transformation for non-patient observations.
[Test]
public Task CalculateRehabilitationAlarm_Should_Return_Same_Observation_If_Not_PatientObservation()
Returns
CalculateRehabilitationAlarm_Should_Set_Alert_When_Condition_Is_Met()
Verifies that the rehabilitation observation mapping sets the status to Alert when the recent rehabilitation values meet the alert condition.
[Test]
public Task CalculateRehabilitationAlarm_Should_Set_Alert_When_Condition_Is_Met()
Returns
CalculateRoxIndex_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
Verifies that the Rox Index is calculated correctly by dividing the SpO2/FiO2 ratio by the respiratory rate (FR) when both required observations are available, and that the result is persisted as a new "Rox_Index" observation.
[Test]
public Task CalculateRoxIndex_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
Returns
CalculateRoxIndex_Should_Not_Calculate_If_Observation_Is_Missing()
[Test]
public Task CalculateRoxIndex_Should_Not_Calculate_If_Observation_Is_Missing()
Returns
CalculateRoxIndex_Should_Not_Calculate_When_FR_Is_Zero_To_Avoid_Division_By_Zero()
Verifies that the ROX index calculation is not performed when the respiratory rate (FR) is zero, preventing a division by zero error.
[Test]
public Task CalculateRoxIndex_Should_Not_Calculate_When_FR_Is_Zero_To_Avoid_Division_By_Zero()
Returns
CalculateVentilationMode_Should_Insert_When_AirFlow_Arrives_And_CCC_Mode()
[Test]
public Task CalculateVentilationMode_Should_Insert_When_AirFlow_Arrives_And_CCC_Mode()
Returns
CalculateVentilationMode_Should_Not_Insert_When_PI_Arrives_And_COMPL_Already_Exists()
Verifies that when a PI observation is processed and a COMPL observation already exists for the patient, no new calculated observation is inserted.
[Test]
public Task CalculateVentilationMode_Should_Not_Insert_When_PI_Arrives_And_COMPL_Already_Exists()
Returns
CalculateVentilationMode_Should_Not_Insert_When_PS_Arrives_And_COMPL_Already_Exists()
Verifies that no calculated observation is inserted when a PS (Pressure Support) observation is processed and a COMPL observation already exists for the patient.
[Test]
public Task CalculateVentilationMode_Should_Not_Insert_When_PS_Arrives_And_COMPL_Already_Exists()
Returns
CalculateVentilationMode_Should_Set_CCC_Mode_When_AirFlow_Arrives_And_CCC_Has_Mode()
Verifies that when an Air Flow observation is processed and a CCC Ventilation Mode observation exists for the patient, the calculated ventilation mode is set to the value retrieved from the CCC source (e.g., "CNAF") and persisted via an insert call.
[Test]
public Task CalculateVentilationMode_Should_Set_CCC_Mode_When_AirFlow_Arrives_And_CCC_Has_Mode()
Returns
CalculateVentilationMode_Should_Set_VMI_When_COMPL_Arrives()
Verifies that when a "Compliancia" (COMPL) observation is mapped, the ventilation mode is calculated and set to "VMI".
[Test]
public Task CalculateVentilationMode_Should_Set_VMI_When_COMPL_Arrives()
Returns
CalculateVentilationMode_Should_Set_VMNI_When_PI_PS_Arrives_Without_COMPL()
Verifies that when an Inspiratory Pressure (PI) observation is processed and no Compliancia (COMPL) observation is found for the patient, the ventilation mode is set to "VMNI".
[Test]
public Task CalculateVentilationMode_Should_Set_VMNI_When_PI_PS_Arrives_Without_COMPL()
Returns
Setup()
Initializes the test environment by creating mock instances of the observation, medicine, and treatment services, configuring a service provider with these dependencies, and instantiating the CalculatedObservations class under test.
[SetUp]
public void Setup()