Merge branch 'classification' into Homocube
This commit is contained in:
@@ -29,5 +29,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 = ""
|
||||
)
|
||||
|
||||
@@ -169,12 +169,20 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
currentDeviceData = it
|
||||
// showToast(calculateRatio(0.17).toString())
|
||||
|
||||
}
|
||||
|
||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
isOnline = isNetworkAvailable
|
||||
apply {
|
||||
DataHolder.hemoCubeTestData?.let {
|
||||
currentDeviceData?.coefficients?.let { coefficients ->
|
||||
val coefficient1 = coefficients[0]
|
||||
val coefficient2 = coefficients[1]
|
||||
val result = coefficient1 * coefficient2
|
||||
showToast("coefficients: $coefficient1, $coefficient2")
|
||||
}
|
||||
}
|
||||
isOnline = isNetworkAvailable
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||
@@ -393,6 +401,7 @@ class HemoCubeFragment : Fragment() {
|
||||
override fun onClickNegativeButton() {}
|
||||
|
||||
override fun onClickPositiveButton() {
|
||||
listenToHemoCube()
|
||||
startSampleProcess()
|
||||
}
|
||||
})
|
||||
@@ -439,7 +448,9 @@ class HemoCubeFragment : Fragment() {
|
||||
this.led1Average = led1Average
|
||||
this.led2Average = led2Average
|
||||
this.deviceRatio = deviceRatio
|
||||
// this.calculatedRatio = calculateRatio(deviceRatio)
|
||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||
this.classificationResult = findResult(calculatedRatio)
|
||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||
this.resultData = fullReadOutput
|
||||
if (!isBufferValueAvailable()) {
|
||||
with(sharedPreferences.edit()) {
|
||||
@@ -467,6 +478,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()
|
||||
}
|
||||
@@ -510,11 +548,11 @@ class HemoCubeFragment : Fragment() {
|
||||
})
|
||||
}
|
||||
|
||||
// private fun calculateRatio(ratio: Double): Double {
|
||||
// val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||
// val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||
// return coefficient1 * ratio + coefficient2
|
||||
// }
|
||||
private fun calculateRatio(ratio: Double): Double {
|
||||
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||
return coefficient1 * ratio + coefficient2
|
||||
}
|
||||
|
||||
private fun parseResult(frames: List<String>): String {
|
||||
val lines = mutableListOf<String>()
|
||||
|
||||
@@ -92,6 +92,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!!
|
||||
}
|
||||
|
||||
private fun addResultTestToDb() {
|
||||
|
||||
Reference in New Issue
Block a user