diff --git a/app/src/main/java/com/example/hpostesting/data/dao/MyDataBase.kt b/app/src/main/java/com/example/hpostesting/data/dao/MyDataBase.kt index c9e4d5f..99f4d38 100644 --- a/app/src/main/java/com/example/hpostesting/data/dao/MyDataBase.kt +++ b/app/src/main/java/com/example/hpostesting/data/dao/MyDataBase.kt @@ -10,7 +10,7 @@ import com.example.hpostesting.data.model.patient.UserData @Database( entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class], - version = 26, + version = 27, exportSchema = false ) @TypeConverters(Converters::class) diff --git a/app/src/main/java/com/example/hpostesting/data/model/patient/HemoCubeTestData.kt b/app/src/main/java/com/example/hpostesting/data/model/patient/HemoCubeTestData.kt index 8e2ed0e..43a164c 100644 --- a/app/src/main/java/com/example/hpostesting/data/model/patient/HemoCubeTestData.kt +++ b/app/src/main/java/com/example/hpostesting/data/model/patient/HemoCubeTestData.kt @@ -78,6 +78,7 @@ data class HemoCubeTestData( var prdClassification: String = "", var deviceRatioClass: String = "", var slopeRatioClass: String = "", + var borderlineMethod2Class: String = "", var errorMessages: String = "", var batteryLevel: String = "", var batteryCapacity: String = "", diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index 1cb6e9e..b71e0d9 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -116,13 +116,13 @@ class HomeFragment : Fragment() { binding.rvOrderOffline.adapter = adapter } } - hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData -> - val devicelist = mutableListOf() - if (deviceData != null) { - devicelist.add(DeviceData(deviceData.deviceId)) - } - - } +// hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData -> +// val devicelist = mutableListOf() +// if (deviceData != null) { +// devicelist.add(DeviceData(deviceData.deviceId)) +// } +// +// } viewModel.networkStatusLiveData?.observe(viewLifecycleOwner) { isConnected -> if (isConnected) { binding.internetAvailableCL.visibility = View.VISIBLE 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 9aeb193..bbc782d 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 @@ -911,6 +911,7 @@ class HemoCubeFragment : Fragment() { .toString() + ", " + currentDeviceData?.coefficients?.get(1).toString() this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio) this.deviceRatioClass = deviceRatioClassification(deviceRatio) + this.borderlineMethod2Class = reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioBorderlineThresholds(deviceRatio), led2Average) this.slopeRatioClass = slopeClass this.classificationResult = findResultWithAdditionalMethods( deviceRatio, @@ -957,6 +958,29 @@ class HemoCubeFragment : Fragment() { } } + fun reclassifyWithBorderlineMethod2(deviceRatio: Double?, deviceRatioClass: String?, led2Average: Double?): String { + try { + if (deviceRatio != null && led2Average != null) { + if (deviceRatioClass == "Negative Borderline") { + return if (led2Average >= 0.15) + "Borderline. Normal" + else + "Borderline. Sickle Cell Trait" + } + if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") { + return if (led2Average >= 0.19) + "Borderline. Sickle Cell Trait" + else + "Borderline. Sickle Cell Disease" + } + } + } catch (e: Exception) { + handleException(e) + return "Error" + } + return deviceRatioClass.toString() + } + fun findResultWithAdditionalMethods( deviceRatio: Double?, deviceRatioClass: String?, @@ -985,10 +1009,35 @@ class HemoCubeFragment : Fragment() { return deviceRatioClass.toString() } + fun deviceRatioBorderlineThresholds(ratio: Double?): String { + try { + if (ratio != null) { + if (ratio in 0.11..0.237) { +// setSubtitleTextColor(R.color.green_2) + return "Normal" + } + if (ratio in 0.237..0.242) + return "Negative Borderline" + if (ratio in 0.242..0.318) + return "Sickle Cell Trait" + if (ratio in 0.318..0.356) + return "Positive for Sickle Cell. HPLC for Confirmation" + if (ratio in 0.356..0.7) + return "Sickle Cell Disease" + } else { + return "Invalid" + } + } catch (e: Exception) { + handleException(e) + return "Error" + } + return "Invalid" + } + fun deviceRatioClassification(ratio: Double?): String { try { if (ratio != null) { - if (ratio in 0.16..0.22) { + if (ratio in 0.16..0.23) { // setSubtitleTextColor(R.color.green_2) return "Normal" } @@ -998,7 +1047,7 @@ class HemoCubeFragment : Fragment() { return "Sickle Cell Trait" if (ratio in 0.31..0.36) return "Positive for Sickle Cell. HPLC for Confirmation" - if (ratio in 0.36..0.56) + if (ratio in 0.36..0.7) return "Sickle Cell Disease" } else { return "Invalid" diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt index 819d9d7..3fd4d05 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeViewModel.kt @@ -290,6 +290,7 @@ class HemoCubeViewModel @Inject constructor( testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString() testDetails?.deviceRatioClass = DataHolder.hemoCubeTestData?.deviceRatioClass.toString() testDetails?.slopeRatioClass = DataHolder.hemoCubeTestData?.slopeRatioClass.toString() + testDetails?.borderlineMethod2Class = DataHolder.hemoCubeTestData?.borderlineMethod2Class.toString() testDetails?.errorMessages = DataHolder.hemoCubeTestData?.errorMessages.toString() testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString() testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString() diff --git a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt index dee8880..0308253 100644 --- a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt +++ b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt @@ -441,4 +441,60 @@ class HemoCubeFragmentTest { val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0) assertEquals("Sickle Cell Disease", result) } + + @Test + fun testReclassifyWithBorderlineMethod2_NegativeBorderlineToNormal() { + // Arrange + val deviceRatio = 0.1 + val deviceRatioClass = "Negative Borderline" + val led2Average = 0.2 + + // Act + val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average) + + // Assert + assertEquals("Borderline. Normal", result) + } + + @Test + fun testReclassifyWithBorderlineMethod2_NegativeBorderlineToSCT() { + // Arrange + val deviceRatio = 0.1 + val deviceRatioClass = "Negative Borderline" + val led2Average = 0.14 + + // Act + val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average) + + // Assert + assertEquals("Borderline. Sickle Cell Trait", result) + } + + @Test + fun testReclassifyWithBorderlineMethod2_PositiveSickleCell() { + // Arrange + val deviceRatio = 0.2 + val deviceRatioClass = "Positive for Sickle Cell. HPLC for Confirmation" + val led2Average = 0.18 + + // Act + val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average) + + // Assert + assertEquals("Borderline. Sickle Cell Disease", result) + } + + @Test + fun testReclassifyWithBorderlineMethod2_PositiveSickleCellToSCT() { + // Arrange + val deviceRatio = 0.2 + val deviceRatioClass = "Positive for Sickle Cell. HPLC for Confirmation" + val led2Average = 0.195 + + // Act + val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average) + + // Assert + assertEquals("Borderline. Sickle Cell Trait", result) + } } \ No newline at end of file