add borderline method 2 based on led2Average
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 = "",
|
||||
|
||||
@@ -116,13 +116,13 @@ class HomeFragment : Fragment() {
|
||||
binding.rvOrderOffline.adapter = adapter
|
||||
}
|
||||
}
|
||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData ->
|
||||
val devicelist = mutableListOf<DeviceData>()
|
||||
if (deviceData != null) {
|
||||
devicelist.add(DeviceData(deviceData.deviceId))
|
||||
}
|
||||
|
||||
}
|
||||
// hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData ->
|
||||
// val devicelist = mutableListOf<DeviceData>()
|
||||
// if (deviceData != null) {
|
||||
// devicelist.add(DeviceData(deviceData.deviceId))
|
||||
// }
|
||||
//
|
||||
// }
|
||||
viewModel.networkStatusLiveData?.observe(viewLifecycleOwner) { isConnected ->
|
||||
if (isConnected) {
|
||||
binding.internetAvailableCL.visibility = View.VISIBLE
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user