Documentation modifications
This commit is contained in:
@@ -12,10 +12,28 @@ using Options = Microsoft.Extensions.Options.Options;
|
||||
|
||||
namespace adas_core.Test.Customizations.H12O.UCIN;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a test fixture that contains unit tests for calculated observations, executing with an order priority of 2 relative to other test fixtures.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This fixture is annotated with <see cref="TestFixtureAttribute"/> to mark it as a container of NUnit test methods, and with <see cref="OrderAttribute"/> to control its execution sequence within the test suite.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=d5b9e22 -->
|
||||
[TestFixture]
|
||||
[Order(2)]
|
||||
public class CalculatedObservationsTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the test fixture for <see cref="CalculatedObservations"/> by creating mocked instances of
|
||||
/// <see cref="IObservationService"/>, <see cref="IConfigObservationService"/>, <see cref="IMedicineService"/>,
|
||||
/// <see cref="ITreatmentService"/>, and <see cref="ILogger{CalculatedObservations}"/>, configuring
|
||||
/// <see cref="IOptions{TOptions}"/> settings for medication bolus, transcutaneous, regional brain saturation,
|
||||
/// electroencephalogram, respiratory, high-frequency ventilation, invasive ventilation, non-invasive
|
||||
/// ventilation, one-lung isolation, and ECMO codes, and registering all dependencies in a
|
||||
/// <see cref="ServiceCollection"/> so that a fully wired <see cref="CalculatedObservations"/> instance
|
||||
/// is produced for each test.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dee8bf2 body=3c4f27b -->
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -79,6 +97,10 @@ public class CalculatedObservationsTest
|
||||
|
||||
private IOptions<ApiSettings> _optionsApiSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that processing a new <see cref="PatientTreatment"/> that contains a medicine—matched by code to a known <see cref="Medicine"/> with an assigned <see cref="MedicineEnum.Types"/>—for the first time for a patient (no prior observations and no active treatments) results in a <see cref="PatientObservation"/> named <c>Medication</c> with value <c>1</c> associated to the treatment's <see cref="PatientTreatment.PatientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e86b69e body=2015ef3 -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Medicine_Observation_With_Type_Should_Return_1()
|
||||
{
|
||||
@@ -128,6 +150,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientTreatment"/> containing a medicine, when no prior
|
||||
/// observations or active treatments exist for the patient, results in the insertion of a
|
||||
/// <see cref="PatientObservation"/> named "Medication" with value <c>0</c> for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9a4b425 body=8e4c1db -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Medicine_Observation_With_Out_Type_Should_Return_1()
|
||||
{
|
||||
@@ -176,6 +204,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new <see cref="PatientTreatment"/> with an <c>OrderControl</c> of <see cref="OrderControlType.Nw"/> is mapped for the first time and contains a medicine code, a <see cref="PatientObservation"/> with name <c>Medication</c> and value <c>1</c> is inserted for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=58845f5 body=90a5eab -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_New_Type_Should_Sum_1()
|
||||
{
|
||||
@@ -226,6 +258,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new <see cref="PatientTreatment"/> is mapped and a prior <see cref="PatientObservation"/> of name "Medication" with value 0 already exists for the patient, the calculated observations service inserts a new observation with value 1 (the sum of the existing value 0 plus the new contribution).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=cb5c407 body=b26efc0 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_Type_Already_Exists_Should_Sum_0()
|
||||
{
|
||||
@@ -296,6 +332,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a medicine observation of type <see cref="OrderControlType.Dc"/> already exists for the patient,
|
||||
/// <see cref="CalculatedObservations.Map(PatientTreatment)"/> subtracts the existing value and inserts a new observation with a resulting value of 0.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous unit test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=91b1fbb body=81816e9 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_DC_Type_Already_Exists_Should_Subtract_0()
|
||||
{
|
||||
@@ -357,6 +399,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="OrderControlType.Dc"/> treatment is processed and the patient has two active medicines, a <c>Medication</c> observation is inserted with the last observation value decremented by one (2 - 1 = 1).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a244df0 body=151d371 -->
|
||||
[Test]
|
||||
public async Task Calculate__Medicine_Observation_DC_OF_TYPE_WITH_TWO_MEDICINES_Should_Subtract_0()
|
||||
{
|
||||
@@ -439,6 +485,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientTreatment"/> containing a medicine without a defined type results in the insertion of a <see cref="PatientObservation"/> named "Medication" with a value of 1 for the associated patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=9e218b6 body=fd802ff -->
|
||||
[Test]
|
||||
public async Task Calculate_Medicine_Observation_New_Medicine_Without_Type_Should_Insert_Medication_1_point()
|
||||
{
|
||||
@@ -514,6 +564,12 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="PatientObservation"/>.<see cref="PatientObservation.Map"/> inserts a new
|
||||
/// <see cref="PatientIntravenousLinesValue"/> observation with a score of <c>5</c> when processing the first
|
||||
/// intravenous arterial observation for a patient, given that no previous observations exist.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a3cd1e1 body=93b85d0 -->
|
||||
[Test]
|
||||
public async Task Calculate_First_Intravenous_Arterial_Observation_Should_Return_5()
|
||||
{
|
||||
@@ -550,6 +606,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a previous <see cref="PatientObservation"/> for the same patient and location has already been removed, the intravenous calculation performed by <see cref="CalculatedObservations.Map"/> produces a result of 0.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ca5324a body=aae89b4 -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_Obs_Already_Exist_Removed_Should_Return_0()
|
||||
{
|
||||
@@ -600,6 +660,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with an <see cref="PatientIntravenousLinesValue"/> whose type and location match the last stored observation for the same patient does not trigger an insertion of a calculated "IntravenousLines" observation.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=076ddee body=f4d6ebd -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_two_observations_of_same_type_and_same_location_should_return_null()
|
||||
{
|
||||
@@ -647,6 +711,10 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a new PatientObservation of type "IntravenousLinesObs" is processed alongside a previous observation of the same type for the same patient, the calculator produces a derived PatientObservation named "IntravenousLines" with a value of 10.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=fd6a90d body=bae7c5e -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_two_observations_of_same_type_should_return_10()
|
||||
{
|
||||
@@ -696,6 +764,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the <see cref="Map"/> method limits the calculated sum of <see cref="PatientIntravenousLinesValue"/> observations to a maximum value of ten when the total exceeds that threshold.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8681a17 body=b0efb6d -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_sum_more_than_10_should_limit_to_ten()
|
||||
{
|
||||
@@ -761,6 +833,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a new <see cref="PatientObservation"/> with a "Catéter línea media" type, when two prior intravenous lines exist (one "Catéter EPICUTÁNEO PERIFÉRICO" and one "Catéter Venoso PERIFÉRICO"), inserts an <see cref="PatientObservation"/> named "IntravenousLines" with a summed value of 5 for the given <paramref name="patientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=1e74e0a body=1cc02b8 -->
|
||||
[Test]
|
||||
public async Task Calculate_Intravenous_sum_one_middle_line_and_two_Peripheral_should_return_5()
|
||||
{
|
||||
@@ -825,6 +901,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="_calculatedObservations"/>.<see cref="_calculatedObservations.Map"/> produces a monitor observation with value 3 for a treatment containing the EEG code <c>42803009</c>, based on the most recent transcutaneous and regional brain saturation observations retrieved for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=a0a8af2 body=b1ce181 -->
|
||||
[Test]
|
||||
public async Task Calculate_Monitor_Transcuatenous_Regional_Brain_Saturation_and_enter_EEG_should_return_3()
|
||||
{
|
||||
@@ -896,6 +976,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a ventilation <see cref="PatientObservation"/> with value <c>OXIDO NITRICO 800 PPM MOL</c> for a patient with no prior observations produces a derived <see cref="PatientObservation"/> named "Respiratory" with an integer value of 10.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c24a7f7 body=316af0f -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_INO_should_return_10()
|
||||
{
|
||||
@@ -924,6 +1008,13 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="RespiratoryCalculations.Map"/> calculates a respiratory value of 5 when the patient observation
|
||||
/// represents a "V.A.F.O." (ventilación de alta frecuencia oscilatoria) entry coded as <c>361110005</c> in the SNM coding system,
|
||||
/// using an empty list returned by <see cref="IPatientObservationService.FindLastObservations"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> that completes when the assertions have been executed.</returns>
|
||||
/// <!-- aidoc:v1 sig=ff64ea1 body=e0741e9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VAFO_should_return_5()
|
||||
{
|
||||
@@ -952,6 +1043,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with value "V.M.C." (ventilation type, SNOMED code "361110005") produces a calculated respiratory observation with value <c>3</c> for the same <see cref="PatientObservation.PatientId"/>, when no previous observations are returned by the observation service.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b50bb78 body=fbe450e -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VMC_should_return_3()
|
||||
{
|
||||
@@ -980,6 +1075,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the ventilation type <c>V.N.I. Ciclada</c> (Non-Invasive Mechanical Ventilation) results in the insertion of a calculated respiratory observation with an integer value of <c>2</c> for the same patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=8bbe6fe body=f6304b9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_VMNI_should_return_2()
|
||||
{
|
||||
@@ -1008,6 +1107,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with name "Tipo de ventilación" and value "Bajo Flujo" is mapped, a calculated respiratory observation is inserted with value 1 for the associated patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dc95390 body=7ee3ef7 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_Nassal_Canulas_Bajo_Flujo_should_return_2()
|
||||
{
|
||||
@@ -1036,6 +1139,10 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.Map"/> returns a respiratory value of 1 when the patient observation indicates an "Alto Flujo" (high flow nasal cannula) ventilation type, identified by <see cref="PatientObservation.Code"/> "361110005" in the SNM coding system.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=513d3e9 body=b065156 -->
|
||||
[Test]
|
||||
public async Task Calculate_Respiratory_Nassal_Canulas_Alto_Flujo_should_return_1()
|
||||
{
|
||||
@@ -1064,6 +1171,12 @@ public class CalculatedObservationsTest
|
||||
), true, false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name "Resp_Mode" and the value "PC-AC"
|
||||
/// produces a calculated observation for "Resp_Type" using the "ADAS" coding system with the
|
||||
/// <see cref="RespirationType.Invasive"/> value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=b5d9b6c body=e8d6f79 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_INVASIVE()
|
||||
{
|
||||
@@ -1085,6 +1198,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the name <c>Resp_Mode</c> and value <c>DUOPAP</c> triggers an insert of a new observation named <c>Resp_Type</c> using the <see cref="RespirationType.NonInvasive"/> value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=f5e26c4 body=47ff0a9 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_NON_INVASIVE()
|
||||
{
|
||||
@@ -1106,6 +1223,10 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that mapping a <see cref="PatientObservation"/> with the <c>Resp_Mode</c> name and the <c>PC-HFO</c> value produces a calculated observation named <c>Resp_Type</c> using the <c>ADAS</c> coding system whose value resolves to <see cref="RespirationType.HighFrequencyVentilation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=0b62048 body=f640d1b -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_HIGH_FREQUENCY()
|
||||
{
|
||||
@@ -1127,6 +1248,11 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when a <see cref="PatientObservation"/> with <see cref="PatientObservation.Name"/> "Resp_Mode" and <see cref="PatientObservation.Value"/> "VENTAPNEA" is mapped, the calculated observation for "Resp_Type" is produced with <see cref="RespirationType.None"/> using the "ADAS" coding system.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous test execution.</returns>
|
||||
/// <!-- aidoc:v1 sig=d1932f8 body=7b268e3 -->
|
||||
[Test]
|
||||
public async Task Calculate_Ventilation_Mode_Returns_NONE()
|
||||
{
|
||||
@@ -1148,6 +1274,12 @@ public class CalculatedObservationsTest
|
||||
), true, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that CalculateOxygenationIndex retrieves the latest AirPressure_Mean, FiO2, and PaO2
|
||||
/// <see cref="PatientObservation"/> values for the patient via FindLastObservations and inserts a new
|
||||
/// <see cref="PatientObservation"/> named "Oxygenation_Index" with the correctly computed value of 1250.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c1d2ff2 body=25f4ca1 -->
|
||||
[Test]
|
||||
public async Task CalculateOxygenationIndex_ShouldInsertCorrectObservation()
|
||||
{
|
||||
@@ -1178,6 +1310,13 @@ public class CalculatedObservationsTest
|
||||
It.IsAny<bool>(), It.IsAny<bool>()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateAsistResp(BasePatientObservation)"/> inserts a new
|
||||
/// <see cref="PatientObservation"/> with the name <c>Respiratory</c> for the patient when the most recent
|
||||
/// retrieved observation matches the expected respiratory mode (<c>Resp_Mode</c>), and returns the
|
||||
/// original <paramref name="observation"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=52c29ce body=d802db9 -->
|
||||
[Test]
|
||||
public async Task CalculateAsistResp_ShouldUpdateObservation_WhenConditionsMet()
|
||||
{
|
||||
@@ -1215,6 +1354,13 @@ public class CalculatedObservationsTest
|
||||
// [TestCase("valorInvasive", RespirationType.INVASIVE)]
|
||||
// [TestCase("valorNonInvasive", RespirationType.NON_INVASIVE)]
|
||||
// [TestCase("valorNone", RespirationType.NONE)]
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculateVentilationMode"/> maps the supplied input value to the expected <see cref="RespirationType"/> and persists it as a <c>Resp_Type</c> observation via <see cref="PatientObservationService.InsertIfChanged"/>.
|
||||
/// Handles the localized input cases <c>valorHFV</c> (mapped to <c>PC-HFO</c>), <c>valorInvasive</c> (mapped to <c>PRVC</c>), and <c>valorNonInvasive</c> (mapped to <c>DUOPAP</c>); any other value falls back to <paramref name="expectedRespType"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The raw <c>Resp_Mode</c> input value from the observation; when it does not match a known ventilation label, it is replaced by <paramref name="expectedRespType"/>.</param>
|
||||
/// <param name="expectedRespType">The <see cref="RespirationType"/> expected to be inserted as <c>Resp_Type</c> after the calculation runs.</param>
|
||||
/// <!-- aidoc:v1 sig=f257d24 body=b077ba8 -->
|
||||
public async Task CalculateVentilationMode_ShouldInsertCorrectRespType(string value,
|
||||
RespirationType expectedRespType)
|
||||
{
|
||||
@@ -1246,6 +1392,16 @@ public class CalculatedObservationsTest
|
||||
// [TestCase("Age_Gestational", 1, 2, ObservationStatus.Alert)]
|
||||
// [TestCase("Age_Gestational", 1, 12, ObservationStatus.Ok)]
|
||||
// [TestCase("Age_Gestational_Fixed", 5, 10, ObservationStatus.Ok)]
|
||||
/// <summary>
|
||||
/// Verifies that the <c>CalculateTAmAlert</c> method updates the status of a <c>TAm</c> observation
|
||||
/// to the expected <see cref="StatusEnum.Type"/> when the observation name is "TAm", and inserts a new
|
||||
/// <c>TAm</c> observation when the name is "Age_Gestational" or "Age_Gestational_Fixed".
|
||||
/// </summary>
|
||||
/// <param name="observationName">The name of the observation under test, expected to be "TAm", "Age_Gestational", or "Age_Gestational_Fixed".</param>
|
||||
/// <param name="tamValue">The numeric TAm value assigned to the observation and related grouped observations.</param>
|
||||
/// <param name="gestationalAge">The numeric gestational age value used in the related grouped observations.</param>
|
||||
/// <param name="expectedType">The expected <see cref="StatusEnum.Type"/> used to assert the resulting observation status.</param>
|
||||
/// <!-- aidoc:v1 sig=8451823 body=20a4dd1 -->
|
||||
public async Task CalculateTAmAlert_ShouldUpdateStatusCorrectly(string observationName, int tamValue,
|
||||
int gestationalAge, StatusEnum.Type expectedType)
|
||||
{
|
||||
@@ -1306,6 +1462,10 @@ public class CalculatedObservationsTest
|
||||
It.Is<PatientObservation>(o => o.PatientId == patientId && o.Name == "TAm"),
|
||||
It.IsAny<bool>(), It.IsAny<bool>()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Verifies that the ParseWeight method correctly converts the units to "gr" and scales the value (multiplying by 1000) when given a valid <see cref="PatientObservation"/> with a numeric <see cref="PatientObservation.Value"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dd3fee8 body=5df6de0 -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenValidObservation_ShouldConvertUnitsAndValue()
|
||||
{
|
||||
@@ -1328,6 +1488,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that ParseWeight handles non-numeric <see cref="PatientObservation.Value"/> gracefully by returning the original <see cref="PatientObservation"/> unchanged.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=e9945f6 body=ed7a0ab -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenValueIsNotNumeric_ShouldHandleGracefullyAndReturnOriginal()
|
||||
{
|
||||
@@ -1339,6 +1503,10 @@ public class CalculatedObservationsTest
|
||||
Assert.That(result, Is.EqualTo(obs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the ParseWeight method returns the original <see cref="BasePatientObservation"/> unchanged when the observation cannot be converted to a <c>PatientObservation</c>, exercising the fallback behavior for invalid input types.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=62502e3 body=f2a846f -->
|
||||
[Test]
|
||||
public async Task ParseWeight_WhenInvalidObservation_ShouldReturnOriginal()
|
||||
{
|
||||
@@ -1350,6 +1518,10 @@ public class CalculatedObservationsTest
|
||||
Assert.That(result, Is.EqualTo(obs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when the patient temperature <see cref="PatientObservation"/> and the latest incubator temperature observation are both recent, <c>CalculateTempGradient</c> triggers an <c>InsertObservation</c> call exactly once to persist the computed <c>Temp_Gradient</c> value (incubator minus patient temperature).
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dadceb5 body=9a088dd -->
|
||||
[Test]
|
||||
public async Task CalculateTempGradient_WhenTempPatientAndTempIncubatorAreRecent_ShouldCalculateGradient()
|
||||
{
|
||||
@@ -1410,6 +1582,11 @@ public class CalculatedObservationsTest
|
||||
), Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the temperature gradient calculation does not persist a new <see cref="PatientObservation"/>
|
||||
/// when the lookup for the complementary temperature reading returns no observations.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=eb711fb body=d83838d -->
|
||||
[Test]
|
||||
public async Task CalculateTempGradient_WhenOneTemperatureIsMissing_ShouldNotCalculateGradient()
|
||||
{
|
||||
@@ -1437,6 +1614,10 @@ public class CalculatedObservationsTest
|
||||
), Times.Never()); // Verificamos que InsertObservation no se llama
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the intravenous line observation calculation maps <see cref="PatientObservation.Name"/> to "IntravenousLines", preserves <see cref="PatientObservation.PatientId"/>, and ensures <see cref="PatientObservation.Time"/> is not earlier than the current time when no prior intravenous lines observation exists.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=6d30754 body=9402c27 -->
|
||||
[Test]
|
||||
public async Task CalculateIntravenousLineObservation_ShouldCalculateObservationAndAdjustTimeIfNecessary()
|
||||
{
|
||||
@@ -1474,6 +1655,10 @@ public class CalculatedObservationsTest
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateMonitor(PatientObservation)"/> correctly calculates and inserts a "Monitor" <see cref="PatientObservation"/> when the patient has a valid existing observation matching the configured regional brain saturation code or an active treatment.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=489567e body=5acaf14 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithValidObservationOrTreatment_ShouldCalculateAndInsertObservation()
|
||||
{
|
||||
@@ -1520,6 +1705,10 @@ public class CalculatedObservationsTest
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <c>CalculateMonitor</c> calculates and inserts a new Monitor observation for the patient when invoked with a <see cref="PatientTreatment"/>, provided an active treatment exists and a matching non-expired <see cref="PatientObservation"/> is returned by <c>FindLastObservations</c>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4a87817 body=2f68585 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithPatientTreatment_ShouldCalculateAndInsertObservation()
|
||||
{
|
||||
@@ -1565,6 +1754,13 @@ public class CalculatedObservationsTest
|
||||
Times.Once());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateMonitor(PatientObservation)"/> does not invoke
|
||||
/// <see cref="ObservationService.InsertObservation(PatientObservation, bool, bool)"/> when the supplied
|
||||
/// <see cref="PatientObservation"/> contains incomplete data (only <see cref="BasePatientObservation.PatientId"/>
|
||||
/// is populated), and the prior observations returned by <see cref="ObservationService.FindLastObservations"/> are empty.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=62f5906 body=d3d0023 -->
|
||||
[Test]
|
||||
public async Task CalculateMonitor_WithIncompleteData_ShouldNotInsertObservation()
|
||||
{
|
||||
@@ -1594,6 +1790,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the surgery expiration check does not insert the <see cref="PatientObservation"/> when its <see cref="PatientObservation.Expired"/> flag is set to <c>false</c>, ensuring that only expired observations trigger an insertion.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=51d7692 body=0f0f138 -->
|
||||
[Test]
|
||||
public async Task CheckSurgeryExpired_WhenNotExpired_DoesNotInsertObservation()
|
||||
{
|
||||
@@ -1608,6 +1808,10 @@ public class CalculatedObservationsTest
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that when a <see cref="PatientObservation"/> has expired, <see cref="CalculatedObservations.CheckSurgeryExpired(PatientObservation)"/> inserts a new <see cref="PatientObservation"/> named "Surgery" with value 0, range 0 to 5, coding system "ADAS", timestamp offset by one second from the original observation, and matching patient identifier and expiry duration.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ce416cc body=331e208 -->
|
||||
[Test]
|
||||
public async Task CheckSurgeryExpired_WhenExpired_InsertsCorrectObservation()
|
||||
{
|
||||
@@ -1634,6 +1838,10 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CalculateComplexity"/> inserts a new complexity observation when processing a patient observation in a non-ECMO treatment context, ensuring the active treatments and recent observations are retrieved and the resulting complexity value is persisted.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=83462d4 body=c26dd24 -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_NewObservation_NoECMO_AddsComplexity()
|
||||
{
|
||||
@@ -1693,6 +1901,12 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when an expired <see cref="PatientObservation"/> is passed to the complexity calculation,
|
||||
/// no new complexity record is inserted into the database, ensuring that expired observations are excluded
|
||||
/// from contributing to the patient's calculated complexity value.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=dbd49ea body=f99d711 -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_ExpiredObservation_DoesNotAddToComplexity()
|
||||
{
|
||||
@@ -1725,6 +1939,12 @@ public class CalculatedObservationsTest
|
||||
), true, true), Times.Never); // No se debe llamar InsertObservation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that when an active treatment includes ECMO, <see cref="CalculatedObservations.CalculateComplexity(BasePatientObservation)"/>
|
||||
/// preserves the original <see cref="PatientObservation"/> value and records a derived <c>Complexity</c> observation labeled
|
||||
/// "1 ECMO" for the patient.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=188c976 body=8b97b7c -->
|
||||
[Test]
|
||||
public async Task CalculateComplexity_ECMOActive_AdjustsComplexity()
|
||||
{
|
||||
@@ -1784,6 +2004,10 @@ public class CalculatedObservationsTest
|
||||
), true, false), Times.Once);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckObsExistsAndIncrementTime"/> increments the <see cref="BasePatientObservation.Time"/> by one second beyond the existing observation when the lookup returns a <see cref="PatientObservation"/> sharing the same timestamp, patient, and observation name as the supplied instance.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=4530eaf body=d89050c -->
|
||||
[Test]
|
||||
public async Task CheckObsExistsAndIncrementTime_SameHourObservation_IncrementsTime()
|
||||
{
|
||||
@@ -1823,6 +2047,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckObsWithSameTimeExistsAndIncrementTime"/> increments the <see cref="BasePatientObservation.Time"/> of the supplied <see cref="PatientObservation"/> by one second and assigns a new <see cref="BasePatientObservation.Id"/> when another observation with the same time and <see cref="BasePatientObservation.Name"/> already exists for the same <see cref="BasePatientObservation.PatientId"/>.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3e1e2ae body=5370e25 -->
|
||||
[Test]
|
||||
public async Task CheckObsWithSameTimeExistsAndIncrementTime_WhenObservationWithSameTimeExists_IncrementsTime()
|
||||
{
|
||||
@@ -1869,6 +2097,10 @@ public class CalculatedObservationsTest
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="CalculatedObservations.CheckTreatmentMedicines"/> correctly processes a treatment whose notes contain a parental nutrition formulation (comment "NPT" with comment type "formularybaseformulation"), looking up the associated <see cref="Medicine"/> by code, retrieving active treatments and the last medication observation for the patient, and inserting a new <see cref="PatientObservation"/> with <see cref="BasePatientObservation.Name"/> "Medication", <see cref="BasePatientObservation.CodingSystem"/> "ADAS" and <see cref="BasePatientObservation.Value"/> 1.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=28e758c body=0996b61 -->
|
||||
[Test]
|
||||
public async Task CheckTreatmentMedicines_ProcessesTreatmentCorrectly_WithParentalNutritionMedicine()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user