=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -20,6 +20,8 @@ namespace adas_core.Test.Customizations.HUVH.UCIA;
/// Marked with <c>TestFixture</c> and assigned <c>Order(2)</c> to control its execution sequence relative to other fixtures.
/// </remarks>
/// <!-- aidoc:v1 sig=d5b9e22 -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary is self-referential and circular: it claims the fixture 'validates the behavior of CalculatedObservationsTest related functionality,' but a test fixture does not validate its own behavior. The class likely tests `CalculatedObservations` functionality, not itself." -->
[TestFixture]
[Order(2)]
public class CalculatedObservationsTest
@@ -29,6 +31,7 @@ public class CalculatedObservationsTest
/// configuring a service provider with these dependencies, and instantiating the <see cref="CalculatedObservations"/>
/// class under test.
/// </summary>
/// <!-- aidoc:v1 sig=dee8bf2 body=20f8ac4 -->
[SetUp]
public void Setup()
{
@@ -84,6 +87,7 @@ public class CalculatedObservationsTest
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=d154c42 body=997a001 -->
[Test]
public async Task CalculateOverSedation_Should_Insert_Observation_When_Conditions_Met()
{
@@ -108,6 +112,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=be8cf87 body=bfc74a1 -->
[Test]
public async Task CalculateOverSedation_Should_Not_Insert_Observation_When_RASS_Is_Not_Negative4_Or_Negative5()
{
@@ -123,6 +128,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=4c7f3e9 body=e6d4e04 -->
[Test]
public async Task CalculateOverSedation_Should_Not_Insert_Observation_When_PSI_Is_25_Or_Higher()
{
@@ -144,6 +150,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=ddfbeb2 body=05fcbdd -->
[Test]
public async Task CalculateOverSedation_Should_Not_Insert_Observation_When_TS_Is_5_Or_Lower()
{
@@ -165,6 +172,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that no observation is inserted when the patient has no active treatments that exceed the configured threshold during the over-sedation calculation.
/// </summary>
/// <!-- aidoc:v1 sig=6d6504a body=40c020e -->
[Test]
public async Task CalculateOverSedation_Should_Not_Insert_Observation_When_No_Treatments_Exceed_Threshold()
{
@@ -190,6 +198,7 @@ public class CalculatedObservationsTest
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=2484ab7 body=6ae0e08 -->
[Test]
public async Task CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_PSI_Observation()
{
@@ -215,6 +224,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=169c7e7 body=b584f23 -->
[Test]
public async Task CalculateOverSedation_Should_Insert_Observation_When_Triggered_By_TS_Observation()
{
@@ -246,6 +256,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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".
/// </summary>
/// <!-- aidoc:v1 sig=cdcef7f body=1f1d9d7 -->
[Test]
public async Task CalculateVentilationMode_Should_Set_VMNI_When_PI_PS_Arrives_Without_COMPL()
{
@@ -266,6 +277,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that when a "Compliancia" (COMPL) observation is mapped, the ventilation mode is calculated and set to "VMI".
/// </summary>
/// <!-- aidoc:v1 sig=76c6409 body=09b9d41 -->
[Test]
public async Task CalculateVentilationMode_Should_Set_VMI_When_COMPL_Arrives()
{
@@ -282,6 +294,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=396d8de body=c8db6fd -->
[Test]
public async Task CalculateVentilationMode_Should_Set_CCC_Mode_When_AirFlow_Arrives_And_CCC_Has_Mode()
{
@@ -344,6 +357,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that when a PI observation is processed and a COMPL observation already exists for the patient, no new calculated observation is inserted.
/// </summary>
/// <!-- aidoc:v1 sig=a3a2ffc body=3e27399 -->
[Test]
public async Task CalculateVentilationMode_Should_Not_Insert_When_PI_Arrives_And_COMPL_Already_Exists()
{
@@ -363,6 +377,7 @@ public class CalculatedObservationsTest
/// Verifies that no calculated observation is inserted when a PS (Pressure Support) observation is processed
/// and a COMPL observation already exists for the patient.
/// </summary>
/// <!-- aidoc:v1 sig=f7af740 body=6680e7c -->
[Test]
public async Task CalculateVentilationMode_Should_Not_Insert_When_PS_Arrives_And_COMPL_Already_Exists()
{
@@ -386,6 +401,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that mapping a <see cref="PatientObservation"/> with Name "ECMO_Location" and Value "VV" returns a non-null result whose value is "VV".
/// </summary>
/// <!-- aidoc:v1 sig=c8afb0f body=7f629ed -->
[Test]
public async Task CalculateEcmoLocation_Should_Return_VV_When_Value_Is_VV()
{
@@ -398,6 +414,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the ECMO location calculation returns "VA" when the input observation value is "VA".
/// </summary>
/// <!-- aidoc:v1 sig=c311f8b body=5b8882f -->
[Test]
public async Task CalculateEcmoLocation_Should_Return_VA_When_Value_Is_VA()
{
@@ -412,6 +429,7 @@ public class CalculatedObservationsTest
/// (e.g., "ECCO2r", "VVDL", "VA+V", "VVDL+V", "VV+V", "VVA").
/// </summary>
/// <param name="inputValue">The ECMO location code assigned to the <see cref="PatientObservation"/> value under test.</param>
/// <!-- aidoc:v1 sig=90b3dc0 body=064eda8 -->
[Test]
[TestCase("ECCO2r")]
[TestCase("VVDL")]
@@ -430,6 +448,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=bfe3e66 body=de3ceb3 -->
[Test]
public async Task CalculateEcmoLocation_Should_Not_Change_Value_When_Not_In_Ecmo_List()
{
@@ -443,6 +462,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the mapping of a <see cref="PatientObservation"/> through the calculated observations mapper returns the original observation unchanged, ensuring the mapping is a no-op for patient observations.
/// </summary>
/// <!-- aidoc:v1 sig=cd439fd body=1a3d8c5 -->
[Test]
public async Task CalculateEcmoLocation_Should_Return_Original_Observation_When_Not_PatientObservation()
{
@@ -460,6 +480,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=0e024bd body=5783315 -->
[Test]
public async Task CalculateOverAnalgesia_Should_Create_Observation_When_Conditions_Are_Met()
{
@@ -534,6 +555,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the mapping correctly calculates and inserts the driving pressure (Pmeset minus PEEP) when both source observations are available.
/// </summary>
/// <!-- aidoc:v1 sig=52ff2df body=3ae93a9 -->
[Test]
public async Task CalculateDrivingPressure_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
{
@@ -594,6 +616,7 @@ public class CalculatedObservationsTest
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=3c50640 body=5d52d72 -->
[Test]
public async Task CalculateRoxIndex_Should_Calculate_Correctly_When_Both_Observations_Are_Present()
{
@@ -654,6 +677,7 @@ public class CalculatedObservationsTest
/// Verifies that the ROX index calculation is not performed when the respiratory rate (FR) is zero,
/// preventing a division by zero error.
/// </summary>
/// <!-- aidoc:v1 sig=30bf581 body=30b6497 -->
[Test]
public async Task CalculateRoxIndex_Should_Not_Calculate_When_FR_Is_Zero_To_Avoid_Division_By_Zero()
{
@@ -682,6 +706,7 @@ public class CalculatedObservationsTest
/// <summary>
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=e5bb5b0 body=2792c9b -->
[Test]
public async Task CalculateDiuresis_Should_Calculate_Correctly_When_Observations_Are_Available()
{
@@ -723,6 +748,7 @@ public class CalculatedObservationsTest
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=014e5d8 body=794ece0 -->
[Test]
public async Task CalculateDiuresis_Should_Not_Calculate_If_Diuresis_Observations_Are_Missing()
{
@@ -747,6 +773,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the diuresis calculation is not performed when the patient has no weight observation available, ensuring no new observation is inserted.
/// </summary>
/// <!-- aidoc:v1 sig=c3e7f69 body=c70ddf8 -->
[Test]
public async Task CalculateDiuresis_Should_Not_Calculate_If_Weight_Is_Invalid()
{
@@ -778,6 +805,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the rehabilitation observation mapping sets the status to Alert when the recent rehabilitation values meet the alert condition.
/// </summary>
/// <!-- aidoc:v1 sig=b72fc81 body=739bfe1 -->
[Test]
public async Task CalculateRehabilitationAlarm_Should_Set_Alert_When_Condition_Is_Met()
{
@@ -809,6 +837,7 @@ public class CalculatedObservationsTest
/// 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.
/// </summary>
/// <!-- aidoc:v1 sig=f5d4651 body=851916f -->
[Test]
public async Task CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Condition_Is_Not_Met()
{
@@ -838,6 +867,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the <c>Map</c> method does not set an alert for a Rehabilitation observation when its value is greater than 2, returning the original observation unchanged.
/// </summary>
/// <!-- aidoc:v1 sig=4222131 body=b1c7f39 -->
[Test]
public async Task CalculateRehabilitationAlarm_Should_Not_Set_Alert_When_Value_Is_Greater_Than_2()
{
@@ -856,6 +886,7 @@ public class CalculatedObservationsTest
/// Verifies that the rehabilitation alarm calculation returns the same observation unchanged when the input observation is not a <see cref="PatientObservation"/>.
/// This ensures that the mapping method does not perform any transformation for non-patient observations.
/// </summary>
/// <!-- aidoc:v1 sig=b686378 body=10526fb -->
[Test]
public async Task CalculateRehabilitationAlarm_Should_Return_Same_Observation_If_Not_PatientObservation()
{
@@ -1404,6 +1404,7 @@ public class CalculatedObservationsTest
/// the Map method creates and inserts a multivalue observation (Respiratory_Device_Multivalue)
/// containing the intervention description extracted from the observation value.
/// </summary>
/// <!-- aidoc:v1 sig=163c94e body=65cb819 -->
[Test]
public async Task Map_WithInterventionCodeInObservationValue_CallsCalculateInterventionMultiValueObservation()
{
@@ -1437,6 +1438,7 @@ public class CalculatedObservationsTest
/// Verifies that mapping an <c>Intervention_Out</c> observation updates an existing active multi-value observation
/// (e.g., <c>Respiratory_Device_Multivalue</c>) for the patient by setting its end time, rather than inserting a new observation.
/// </summary>
/// <!-- aidoc:v1 sig=d1e8de8 body=707d6a7 -->
[Test]
public async Task Map_WithInterventionOut_UpdatesExistingMultiValueObservation()
{
@@ -1483,6 +1485,10 @@ public class CalculatedObservationsTest
/// Verifies that when a new "Intervention_In" observation is mapped via <c>Map</c> and the patient's prior "Respiratory_Device_Multivalue" observation is expired (so there is no existing active last observation), a new <see cref="PatientObservation"/> named "Respiratory_Device_Multivalue" is inserted containing the new intervention while the existing expired observation is left untouched.
/// </summary>
/// <!-- aidoc:v1 sig=4271f27 body=7d4a79d -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary states the newly inserted observation is 'containing the new intervention', but the assertion explicitly checks that the inserted value is NOT equal to the new intervention description (`((string[])o.Value)[0] != newInterventionDescription`). The test allows a value that is neither the old nor the new intervention, contradicting the documented behavior." -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary claims 'the existing expired observation is left untouched', but the test only verifies that UpdateObservation is never called; there is no assertion specifically confirming the expired observation is untouched (e.g., it could still be replaced or modified via a path the mocks don't cover)." -->
[Test]
public async Task Map_WithNewInterventionNoExistingLastIntervention_NewMultiValueObservation()
{
@@ -1541,6 +1547,8 @@ public class CalculatedObservationsTest
/// new record through <see cref="IObservationService.InsertObservation"/>.
/// </summary>
/// <!-- aidoc:v1 sig=4e3257d body=697676f -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary states 'the new intervention is appended to the existing multi-value observation via UpdateObservation', but the UpdateObservation assertion verifies the updated observation has Length == 1 with only the existing intervention (and Expired = true), NOT the new intervention appended. The assertions verify the existing observation is expired via UpdateObservation and that no combined InsertObservation occurs, contradicting the described append-via-UpdateObservation behavior." -->
[Test]
public async Task Map_WithNewInterventionAddsToExistingMultiValueObservation()
{
@@ -1602,6 +1610,7 @@ public class CalculatedObservationsTest
/// Verifies that mapping a surgery observation inserts a new Surgery_Multivalue observation
/// when no existing multi-value observation is found, and does not trigger an update.
/// </summary>
/// <!-- aidoc:v1 sig=a509623 body=817f4ef -->
[Test]
public async Task Map_WithSurgeryObservation_InsertsNewSurgeryMultiValueObservation()
{
@@ -1645,6 +1654,7 @@ public class CalculatedObservationsTest
/// to be expired and replaced with a new multi-value observation that contains both the previously recorded
/// surgery value and the newly mapped surgery value.
/// </summary>
/// <!-- aidoc:v1 sig=d2c7ca7 body=551d45d -->
[Test]
public async Task Map_WithSurgeryObservation_UpdatesExistingSurgeryMultiValueObservation()
{
@@ -1700,6 +1710,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that mapping a Surgery observation updates the existing Surgery_Multivalue observation by expiring the duplicate entry and inserting a new observation with the duplicate value removed.
/// </summary>
/// <!-- aidoc:v1 sig=46caac9 body=55e3f72 -->
[Test]
public async Task Map_WithSurgeryObservation_UpdatesExistingSurgeryMultiValueObservation_RemovesDuplicate()
{
@@ -1754,6 +1765,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that does not insert or update any observation when a surgery observation is provided with a non-string <c>Value</c>.
/// </summary>
/// <!-- aidoc:v1 sig=e4795ba body=7bfc460 -->
[Test]
public async Task Map_WithSurgeryObservation_HandlesNonStringValue()
{
@@ -1782,6 +1794,7 @@ public class CalculatedObservationsTest
/// Verifies that the <see cref="CalculatedObservations.Map"/> method, when invoked with a respiratory device multivalue observation
/// and no prior observations, inserts a "Complexity" observation with a value of 1.
/// </summary>
/// <!-- aidoc:v1 sig=09fcb0a body=445a173 -->
[Test]
public async Task Map_WithRespiratoryDeviceMultiValueObservation_CallsCalculateComplexity_Return1()
{
@@ -1887,6 +1900,8 @@ public class CalculatedObservationsTest
/// </summary>
/// <param name="observation">The <see cref="PatientObservation"/> instance passed implicitly to the
/// test runner; not directly used as a method argument since this is a parameterless test method.</param>
/// <!-- aidoc-review:v1 severity=medium kind=extra_param
/// "The test method has no parameters, but the documentation includes a <param name=\"observation\"> tag. While the text acknowledges it is parameterless, the tag itself should not exist." -->
[Test]
public async Task Map_WithTwoMedicationMultiValueObservation_CalculatesComplexity_Return4()
{
@@ -1928,6 +1943,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that when a patient has a system multivalue observation, medication multivalue observations, and a newborn weight observation, the mapping process calculates a complexity value of 9 and inserts it as a new "Complexity" observation.
/// </summary>
/// <!-- aidoc:v1 sig=fdea61e body=5aa8c09 -->
[Test]
public async Task Map_WithSystemMedicationAndNewbornWeightMultiValueObservation_CalculatesComplexity_Return9()
{
@@ -2025,6 +2041,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that the <c>Map</c> method correctly calculates a complexity value of 13 when the input observation represents surgery, medication, and newborn weight data, by aggregating the per-section contribution of each observation type.
/// </summary>
/// <!-- aidoc:v1 sig=9b92aff body=952f1bc -->
[Test]
public async Task Map_WithSurgeryMedicationMewbornWeightMultiValueObservation_CalculatesComplexity_Returns13()
{
@@ -2356,6 +2373,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that mapping a patient treatment with no placer order returns the original treatment unchanged.
/// </summary>
/// <!-- aidoc:v1 sig=4641a92 body=97aa6f6 -->
[Test]
public async Task Map_TreatmentWithNoPlacerOrder_ReturnsOriginalTreatment()
{
@@ -2374,6 +2392,7 @@ public class CalculatedObservationsTest
/// Verifies that mapping a treatment which has active older treatments sets the order control to <c>XO</c>
/// (cancel as a result of a new order being accepted) and does not insert a new observation.
/// </summary>
/// <!-- aidoc:v1 sig=3fa3c83 body=55a8c26 -->
[Test]
public async Task Map_TreatmentWithActiveOlderTreatments_SetsOrderControlToXO()
{
@@ -2399,6 +2418,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that when mapping a patient treatment with no active older treatments, the resulting order control is set to <see cref="OrderControlType.Nw"/> and no patient observation is inserted.
/// </summary>
/// <!-- aidoc:v1 sig=a3a0846 body=9a069fa -->
[Test]
public async Task Map_TreatmentWithNoActiveOlderTreatments_SetsOrderControlToNW()
{
@@ -2423,6 +2443,7 @@ public class CalculatedObservationsTest
/// <summary>
/// Verifies that when a patient treatment has an end time set, mapping it sets the order control to <see cref="OrderControlType.Dc"/> and does not insert a new observation.
/// </summary>
/// <!-- aidoc:v1 sig=c977810 body=b9cabf5 -->
[Test]
public async Task Map_TreatmentWithEndTimeSet_SetsOrderControlToDC()
{