From 515ab24ce6548c8a34cabe3fe8cc8adfa16b801a Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 17 Sep 2023 23:46:30 +0530 Subject: [PATCH] add result classification - add result classification - add sample start command for positive confirmation - remove toast on result screen --- .../data/model/patient/HemoCubeTestData.kt | 3 +- .../presentation/hemocube/HemoCubeFragment.kt | 35 ++++++++++++++++--- .../hemocube/HemoCubeViewModel.kt | 1 + 3 files changed, 34 insertions(+), 5 deletions(-) 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 0417a28..b3bbad7 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 @@ -27,5 +27,6 @@ data class HemoCubeTestData( var led1Average: Double? = null, var led2Average: Double? = null, var deviceRatio: Double? = null, - var calculatedRatio: Double? = null + var calculatedRatio: Double? = null, + var classificationResult: String = "" ) 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 9328097..3efcc92 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 @@ -104,8 +104,6 @@ class HemoCubeFragment : Fragment() { hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { currentDeviceData = it - showToast(calculateRatio(0.17).toString()) - } hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable -> @@ -115,7 +113,7 @@ class HemoCubeFragment : Fragment() { val coefficient1 = coefficients[0] val coefficient2 = coefficients[1] val result = coefficient1 * coefficient2 - showToast("Result: $result") + showToast("coefficients: $coefficient1, $coefficient2") } } isOnline = isNetworkAvailable @@ -279,7 +277,8 @@ class HemoCubeFragment : Fragment() { override fun onClickNegativeButton() {} override fun onClickPositiveButton() { - + listenToHemoCube() + startSampleProcess() } }) } @@ -316,6 +315,7 @@ class HemoCubeFragment : Fragment() { this.led2Average = led2Average this.deviceRatio = deviceRatio this.calculatedRatio = calculateRatio(deviceRatio) + this.classificationResult = findResult(calculatedRatio) this.resultData = fullReadOutput if (!isBufferValueAvailable()) { with(sharedPreferences.edit()) { @@ -331,6 +331,33 @@ class HemoCubeFragment : Fragment() { } } + private fun findResult(calculatedRatio: Double?): String { + try { + if (calculatedRatio != null) { + if (calculatedRatio < 0.085) + return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume" + if (calculatedRatio in 0.085 .. 0.155) + return "Normal" + if (calculatedRatio in 0.155 .. 0.175) + return "Negative Borderline. Repeat Test" + if (calculatedRatio in 0.175 .. 0.22) + return "Sickle Cell Trait" + if (calculatedRatio in 0.22 .. 0.25) + return "Positive for Sickle Cell. HPLC for Confirmation" + if (calculatedRatio in 0.25 .. 0.35) + return "Sickle Cell Disease" + if (calculatedRatio > 0.35) + return "Inconclusive. Repeat with test with lower volume of blood" + } else { + return "NULL" + } + } catch (_: Exception) { + showToast("error while performing classification") + return "ERROR" + } + return "NULL" + } + private fun showToast(message: String) { Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() } 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 bfeeb90..945cf1b 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 @@ -85,6 +85,7 @@ class HemoCubeViewModel @Inject constructor( testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio + testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!! viewModelScope.launch { try {