From 9d00e046803d6881aadfb495b4ed89ef7f07e2bf Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sun, 14 Jan 2024 14:02:33 +0530 Subject: [PATCH] show device ratio class with new thresholds --- .../presentation/hemocube/HemoCubeFragment.kt | 60 ++++++++----------- .../hemocube/HemoCubeViewModel.kt | 4 ++ app/src/main/res/values-kn/strings.xml | 6 +- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 6 +- 5 files changed, 36 insertions(+), 41 deletions(-) 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 d403f7c..0769fb2 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 @@ -631,7 +631,7 @@ class HemoCubeFragment : Fragment() { val led2Average = log10(led2BufferForDevice.div(led2SampleForDevice)) val led3Average = log10(led3BufferForDevice.div(led3SampleForDevice)) val led4Average = log10(led4BufferForDevice.div(led4SampleForDevice)) - val deviceRatio = led3Average / led1Average + val deviceRatio = led4Average / led1Average if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0) ?.get(0)!! @@ -674,8 +674,6 @@ class HemoCubeFragment : Fragment() { } } - - var gradient = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(0) var constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(1) fittedAbs1 = gradient?.times(led1Average)?.plus(constant!!)!! @@ -767,12 +765,12 @@ class HemoCubeFragment : Fragment() { this.slopeRatio = _slopeRatio this.coefficients = currentDeviceData?.coefficients?.get(0) .toString() + ", " + currentDeviceData?.coefficients?.get(1).toString() - this.classificationResult = findResult(calculatedRatio) this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio) hemoCubeViewModel.messages.postValue("Hb3: $_hb3,\n Hb4: $_hb4") this.deviceRatioClass = deviceRatioClassification(deviceRatio) this.slopeRatioClass = slopeClass - hemoCubeViewModel.messages.postValue("Slope Ratio: ${round(slopeRatio!!)},\n Slope Class: ${this.slopeRatioClass}\n") + this.classificationResult = deviceRatioClass //findResult(calculatedRatio) + hemoCubeViewModel.messages.postValue("${this.deviceRatioClass} ${if (led4Average < 0.17) " - Low Hb" else ""}\n") this.errorMessages = allErrorMessages this.resultData = deviceLog this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString() @@ -794,15 +792,6 @@ class HemoCubeFragment : Fragment() { apply() } } - -// if (!validationError) { -// activity?.runOnUiThread { -// binding.btnSubmit.visibility = View.VISIBLE -// binding.btnSubmit.isEnabled = true -// binding.btnSubmit.isClickable = true -// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd")) -// } -// } } catch (e: Exception) { Toast.makeText( requireContext(), @@ -820,14 +809,6 @@ class HemoCubeFragment : Fragment() { if (calculatedRatio < 0.05) return getString(R.string.error_repeat_test_higher_volume) if (calculatedRatio in 0.05..0.155) { - activity?.runOnUiThread { - binding.tvSubtitle4.setTextColor( - ContextCompat.getColor( - requireContext(), - R.color.brightGreen - ) - ) - } return getString(R.string.normal) } if (calculatedRatio in 0.155..0.175) @@ -855,15 +836,24 @@ class HemoCubeFragment : Fragment() { try { hemoCubeViewModel.messages.postValue("result classification") if (ratio != null) { - if (ratio in 0.0..0.4) + if (ratio in 0.2..0.29) { + activity?.runOnUiThread { + binding.tvSubtitle4.setTextColor( + ContextCompat.getColor( + requireContext(), + R.color.green_2 + ) + ) + } return getString(R.string.normal) - if (ratio in 0.4..0.45) + } + if (ratio in 0.29..0.32) return getString(R.string.negative_borderline) - if (ratio in 0.45..0.55) + if (ratio in 0.32..0.35) return getString(R.string.sickle_cell_trait) - if (ratio in 0.55..0.575) + if (ratio in 0.35..0.38) return getString(R.string.positive_for_sickle_cell) - if (ratio in 0.09..1.0) + if (ratio in 0.38..0.5) return getString(R.string.sickle_cell_disease) } else { return getString(R.string.invalid) @@ -906,14 +896,14 @@ class HemoCubeFragment : Fragment() { hemoCubeViewModel.messages.postValue("result classification") if (predictedDenovixRatio != null) { if (predictedDenovixRatio in 0.0..0.16) { - activity?.runOnUiThread { - binding.tvSubtitle4.setTextColor( - ContextCompat.getColor( - requireContext(), - R.color.brightGreen - ) - ) - } +// activity?.runOnUiThread { +// binding.tvSubtitle4.setTextColor( +// ContextCompat.getColor( +// requireContext(), +// R.color.brightGreen +// ) +// ) +// } return getString(R.string.normal) } if (predictedDenovixRatio in 0.16..0.165) 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 a1d0c99..b9ed623 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 @@ -267,11 +267,15 @@ class HemoCubeViewModel @Inject constructor( testDetails?.abs3 = DataHolder.hemoCubeTestData?.abs3 testDetails?.abs4 = DataHolder.hemoCubeTestData?.abs4 testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio + testDetails?.slopeRatio = DataHolder.hemoCubeTestData?.slopeRatio testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!! testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString() + testDetails?.deviceRatioClass = DataHolder.hemoCubeTestData?.deviceRatioClass.toString() + testDetails?.slopeRatioClass = DataHolder.hemoCubeTestData?.slopeRatioClass.toString() + testDetails?.errorMessages = DataHolder.hemoCubeTestData?.errorMessages.toString() testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString() testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString() testDetails?.batteryMaxCapacity = DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString() diff --git a/app/src/main/res/values-kn/strings.xml b/app/src/main/res/values-kn/strings.xml index e62ed5d..4eef86a 100644 --- a/app/src/main/res/values-kn/strings.xml +++ b/app/src/main/res/values-kn/strings.xml @@ -97,9 +97,9 @@ ಈಗ ಪ್ರಾರಂಭಿಸಿ ಹೆಮೋ ಕ್ಯೂಬ್ ಹೆಮೊಗ್ಲೊಬಿನ್ - ಸಾಮಾನ್ಯ\ \ - ಸಿಕ್ಲ್ ಸೆಲ್ ರೋಗ\ \ - ಸಿಕ್ಲ್ ಸೆಲ್ ಗುಣ\ \ + ಸಾಮಾನ್ಯ + ಸಿಕ್ಲ್ ಸೆಲ್ ರೋಗ + ಸಿಕ್ಲ್ ಸೆಲ್ ಗುಣ ಅವ್ಯಾಖ್ಯಾತ\ \ ಸಿಕ್ಲ್‌ಸೆಲ್\nದೃಢೀಕರಣ ಸಿಕ್ಲ್ ಸೆಲ್ ಸ್ಕ್ರೀನಿಂಗ್ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c33ea7c..7a0998f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,6 +10,7 @@ #808080 #00FF00 + #295F2D #FF0000 #4daaff #005db3 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 549281d..a0824d2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -98,9 +98,9 @@ Start Now Hemo Cube Hb - Normal\ \ - Sickle Cell Disease\ \ - Sickle Cell Trait\ \ + Normal + Sickle Cell Disease + Sickle Cell Trait Undefined\ \ Sicklecell\nConfirmatory Sicklecell Screening