diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt index 1b45de0..9aeb193 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt @@ -766,6 +766,7 @@ class HemoCubeFragment : Fragment() { val led3Average = log10(led3BufferForDevice.div(led3SampleForDevice)) val led4Average = log10(led4BufferForDevice.div(led4SampleForDevice)) val deviceRatio = led2Average / led1Average + val borderlineMetric = (led1Average - led2Average) / deviceRatio if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0) ?.get(0)!! @@ -911,7 +912,11 @@ class HemoCubeFragment : Fragment() { this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio) this.deviceRatioClass = deviceRatioClassification(deviceRatio) this.slopeRatioClass = slopeClass - this.classificationResult = deviceRatioClass + this.classificationResult = findResultWithAdditionalMethods( + deviceRatio, + deviceRatioClass, + borderlineMetric + ) hemoCubeViewModel.messages.postValue( "${this.classificationResult} \n Device Ratio: ${ "%.3f".format( @@ -955,14 +960,22 @@ class HemoCubeFragment : Fragment() { fun findResultWithAdditionalMethods( deviceRatio: Double?, deviceRatioClass: String?, - slopeRatio: Double?, + borderlineMetric: Double?, ): String { try { // hemoCubeViewModel.messages.postValue("post classification checks") - if (deviceRatio != null) { - if (slopeRatio != null) { - if (deviceRatioClass == "Normal" && slopeRatio > 45.0) - return "Negative Borderline, Repeat Test" + if (deviceRatio != null && borderlineMetric != null) { + if (deviceRatioClass == "Negative Borderline") { + return if (borderlineMetric >= 2.4) + "Borderline. Normal" + else + "Borderline. Sickle Cell Trait" + } + if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") { + return if (borderlineMetric >= 1.34) + "Borderline. Sickle Cell Trait" + else + "Borderline. Sickle Cell Disease" } } } catch (e: Exception) { @@ -975,17 +988,17 @@ class HemoCubeFragment : Fragment() { fun deviceRatioClassification(ratio: Double?): String { try { if (ratio != null) { - if (ratio in 0.016..0.22) { + if (ratio in 0.16..0.22) { // setSubtitleTextColor(R.color.green_2) return "Normal" } - if (ratio in 0.22..0.24) + if (ratio in 0.23..0.25) return "Negative Borderline" - if (ratio in 0.24..0.32) + if (ratio in 0.25..0.31) return "Sickle Cell Trait" - if (ratio in 0.32..0.37) + if (ratio in 0.31..0.36) return "Positive for Sickle Cell. HPLC for Confirmation" - if (ratio in 0.37..0.56) + if (ratio in 0.36..0.56) return "Sickle Cell Disease" } else { return "Invalid" diff --git a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt index d8e2a7e..dee8880 100644 --- a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt +++ b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt @@ -316,6 +316,13 @@ class HemoCubeFragmentTest { assertEquals("HPP-000-5001", result) } + @Test + fun testDeviceRatioClassificationNormalWithStartRange() { + val ratio = 0.16 + val result = hemoCubeFragment.deviceRatioClassification(ratio) + assertEquals("Normal", result) + } + @Test fun testDeviceRatioClassificationNormal() { val ratio = 0.22 @@ -331,19 +338,33 @@ class HemoCubeFragmentTest { } @Test - fun testDeviceRatioClassificationSickleCellTrait() { - val ratio = 0.25 + fun testDeviceRatioClassificationSickleCellTraitLowerBound() { + val ratio = 0.251 + val result = hemoCubeFragment.deviceRatioClassification(ratio) + assertEquals("Sickle Cell Trait", result) + } + + @Test + fun testDeviceRatioClassificationSickleCellTraitUpperBound() { + val ratio = 0.309 val result = hemoCubeFragment.deviceRatioClassification(ratio) assertEquals("Sickle Cell Trait", result) } @Test fun testDeviceRatioClassificationPositiveForSickleCell() { - val ratio = 0.37 + val ratio = 0.359 val result = hemoCubeFragment.deviceRatioClassification(ratio) assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result) } + @Test + fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() { + val ratio = 0.361 + val result = hemoCubeFragment.deviceRatioClassification(ratio) + assertEquals("Sickle Cell Disease", result) + } + @Test fun testDeviceRatioClassificationSickleCellDisease() { val ratio = 0.45 @@ -359,10 +380,31 @@ class HemoCubeFragmentTest { } @Test - fun findResultWithAdditionalMethods_ValidInput_ReturnsNegativeBorderlineRepeatTest() { + fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() { // `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test") - val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0) - assertEquals("Negative Borderline, Repeat Test", result) + val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5) + assertEquals("Borderline. Normal", result) + } + + @Test + fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() { +// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test") + val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2) + assertEquals("Borderline. Sickle Cell Trait", result) + } + + @Test + fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() { +// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test") + val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.35) + assertEquals("Borderline. Sickle Cell Trait", result) + } + + @Test + fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() { +// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test") + val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.33) + assertEquals("Borderline. Sickle Cell Disease", result) } @Test @@ -389,8 +431,8 @@ class HemoCubeFragmentTest { @Test fun findResultWithAdditionalMethods_PBL_ReturnsPBL() { // `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid") - val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 70.0) - assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result) + val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.35) + assertEquals("Borderline. Sickle Cell Trait", result) } @Test