From f2d6916aa6ca900ee896c1f94511632ef34a660a Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Fri, 16 Feb 2024 14:27:40 +0530 Subject: [PATCH 1/8] add borderline metric --- .../presentation/hemocube/HemoCubeFragment.kt | 29 ++++++++++++----- .../hpostesting/HemoCubeFragmentTest.kt | 31 ++++++++++++++++--- 2 files changed, 47 insertions(+), 13 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 005b0e0..7977db1 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 @@ -738,6 +738,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)!! @@ -883,7 +884,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( @@ -927,14 +932,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) { @@ -953,9 +966,9 @@ class HemoCubeFragment : Fragment() { } if (ratio in 0.22..0.24) return "Negative Borderline" - if (ratio in 0.24..0.32) + if (ratio in 0.24..0.31) return "Sickle Cell Trait" - if (ratio in 0.32..0.37) + if (ratio in 0.31..0.37) return "Positive for Sickle Cell. HPLC for Confirmation" if (ratio in 0.37..0.56) return "Sickle Cell Disease" diff --git a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt index d8e2a7e..6d10f99 100644 --- a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt +++ b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt @@ -359,10 +359,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 +410,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 From e64aa27f8a00db2ffc19f5694fdadae11219c8a8 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sat, 17 Feb 2024 09:09:45 +0530 Subject: [PATCH 2/8] refine borderline --- app/build.gradle | 2 +- .../presentation/hemocube/HemoCubeFragment.kt | 8 ++++---- .../com/example/hpostesting/HemoCubeFragmentTest.kt | 11 +++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e035742..939eaa4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ android { // dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production defaultConfig { - applicationId "in.sminnovations.hpostesting.quality" + applicationId "in.sminnovations.hpostesting.dev" minSdk 21 targetSdk 34 versionCode 112 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 7977db1..5de50c2 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 @@ -960,15 +960,15 @@ 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.31) + if (ratio in 0.25..0.31) return "Sickle Cell Trait" - if (ratio in 0.31..0.37) + if (ratio in 0.31..0.36) return "Positive for Sickle Cell. HPLC for Confirmation" if (ratio in 0.37..0.56) return "Sickle Cell Disease" diff --git a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt index 6d10f99..9fb9b0c 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 @@ -332,14 +339,14 @@ class HemoCubeFragmentTest { @Test fun testDeviceRatioClassificationSickleCellTrait() { - val ratio = 0.25 + val ratio = 0.251 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) } From c91657c5295d93739285e9ff59f3649320eb2d46 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Sat, 17 Feb 2024 09:43:14 +0530 Subject: [PATCH 3/8] unit tests for lower and uppper bounds --- .../presentation/hemocube/HemoCubeFragment.kt | 2 +- .../example/hpostesting/HemoCubeFragmentTest.kt | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 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 5de50c2..4d702a8 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 @@ -970,7 +970,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.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 9fb9b0c..dee8880 100644 --- a/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt +++ b/app/src/test/java/com/example/hpostesting/HemoCubeFragmentTest.kt @@ -338,12 +338,19 @@ class HemoCubeFragmentTest { } @Test - fun testDeviceRatioClassificationSickleCellTrait() { + 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.359 @@ -351,6 +358,13 @@ class HemoCubeFragmentTest { 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 From 14516cad5f5b8d3cac093aead796c09696296e95 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Mon, 19 Feb 2024 23:14:42 +0530 Subject: [PATCH 4/8] change binding logic --- .../presentation/dashboard/HomeFragment.kt | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) 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 c954fe6..1cb6e9e 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 @@ -63,8 +63,7 @@ import java.util.zip.ZipInputStream @AndroidEntryPoint class HomeFragment : Fragment() { - private var _binding: FragmentHomeBinding? = null - private val binding get() = _binding!! + private lateinit var binding: FragmentHomeBinding private val viewModel: TestRightViewModel by activityViewModels() private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels() private lateinit var rvAdapter: UserListAdapter @@ -76,20 +75,12 @@ class HomeFragment : Fragment() { private var isTokenAvailable = false private var natsToken: String = "" private var deviceId: String = "" - - private lateinit var sharedPreference: SharedPreferences + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, - ): View? { - _binding = FragmentHomeBinding.inflate(inflater, container, false) - - // Check if _binding is null - if (_binding == null) { - // Handle the case where binding could not be initialized - // You may want to log an error or return a default view in this case - return super.onCreateView(inflater, container, savedInstanceState) - } + ): View { + binding = FragmentHomeBinding.inflate(inflater, container, false) sharedPreference = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE) DataHolder.selectedTest = null @@ -254,9 +245,6 @@ class HomeFragment : Fragment() { var password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString() var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString() deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString() - Log.e("idpass", userID) - Log.e("idpass", password) - Log.e("idpass", deviceId) if (userID.isNotEmpty() && password.isNotEmpty()) { if (!isTokenAvailable) { hemoCubeViewModel.login(createLoginRequestData(userID, password)) @@ -937,7 +925,6 @@ class HomeFragment : Fragment() { override fun onDestroyView() { super.onDestroyView() - _binding = null } private fun downloadCsv() { From d4c66e5e1a685c6f78bc3ad1f397d032c0ab1606 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Mon, 19 Feb 2024 23:15:42 +0530 Subject: [PATCH 5/8] refactor code --- .../hpostesting/presentation/hemocube/HemoCubeFragment.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 3966723..1b45de0 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 @@ -1,5 +1,6 @@ package com.example.hpostesting.presentation.hemocube +import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.content.SharedPreferences @@ -90,8 +91,11 @@ class HemoCubeFragment : Fragment() { observeViewModel() } + @SuppressLint("SetTextI18n") private fun initViews() { binding.btnSubmit.setOnClickListener { + binding.btnSubmit.isEnabled = false + binding.btnSubmit.isClickable = false activity?.runOnUiThread { binding.progressBar.visibility = View.VISIBLE binding.btnSubmit.visibility = View.GONE @@ -106,8 +110,6 @@ class HemoCubeFragment : Fragment() { binding.nameEditText.visibility = View.GONE binding.tvTitle.visibility = View.GONE binding.btnGo.visibility = View.GONE -// binding.btnSubmit.isEnabled = false -// binding.btnSubmit.isClickable = false binding.btnPlacebuffer.visibility = View.GONE binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}" @@ -861,7 +863,7 @@ class HemoCubeFragment : Fragment() { } } - var absorbanceLowerLimit = 0.0 + val absorbanceLowerLimit = 0.0 if (led1Average < absorbanceLowerLimit || led2Average < absorbanceLowerLimit || led3Average < absorbanceLowerLimit || led4Average < absorbanceLowerLimit) { validationError = true activity?.runOnUiThread { From b1342580ea6d390d22f001d7932e1e8575e0f547 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Tue, 20 Feb 2024 10:50:42 +0530 Subject: [PATCH 6/8] avoid saving deviceid to pref --- .../hpostesting/presentation/autodac/AutoDacFragment.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/autodac/AutoDacFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/autodac/AutoDacFragment.kt index 2d52d2d..9702894 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/autodac/AutoDacFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/autodac/AutoDacFragment.kt @@ -163,10 +163,10 @@ class AutoDacFragment : Fragment() { val slData = stringData.split(" ") if (slData.size > 1) { val hardwareId = slData[1].trim() - with(sharedPreferences.edit()) { - putString(Constants.DEVICE_ID, hardwareId) - apply() - } +// with(sharedPreferences.edit()) { +// putString(Constants.DEVICE_ID, hardwareId) +// apply() +// } } activity?.runOnUiThread { binding.btnSubmit.visibility = View.VISIBLE From 3bad0720e3ff86c2425c716f74bb3efbd22aeaef Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Tue, 20 Feb 2024 10:52:05 +0530 Subject: [PATCH 7/8] add users --- .../java/com/example/hpostesting/data/constant/Constants.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt index 786c654..99a20e8 100644 --- a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt +++ b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt @@ -67,6 +67,8 @@ object Constants { val STATICID = listOf( "FACTORY", "ADMIN", + "PQUSER", + "QCUSER", "VIZ-1000-0004", "VIZ-1000-0005", "VIZ-1000-0006", From 1bc8b1866956a8c15104383ec5792db1442c6f09 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Wed, 21 Feb 2024 17:49:31 +0530 Subject: [PATCH 8/8] add borderline method 2 based on led2Average --- .../hpostesting/data/dao/MyDataBase.kt | 2 +- .../data/model/patient/HemoCubeTestData.kt | 1 + .../presentation/dashboard/HomeFragment.kt | 14 ++--- .../presentation/hemocube/HemoCubeFragment.kt | 53 +++++++++++++++++- .../hemocube/HemoCubeViewModel.kt | 1 + .../hpostesting/HemoCubeFragmentTest.kt | 56 +++++++++++++++++++ 6 files changed, 117 insertions(+), 10 deletions(-) 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