Merge remote-tracking branch 'origin/preprod' into preprod

# Conflicts:
#	app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt
This commit is contained in:
Mariya
2023-11-14 11:55:49 +05:30
3 changed files with 56 additions and 18 deletions

View File

@@ -14,12 +14,13 @@ android {
compileSdk 34
namespace 'in.sminnovations.hpostesting'
// prod - production, preprod - preproduction, quality - qc,
defaultConfig {
applicationId "in.sminnovations.hpostesting"
minSdk 21
targetSdk 34
versionCode 24
versionName "2.1.24"
versionCode 28
versionName "2.1.28"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -74,4 +74,7 @@ object Constants {
const val BUFFER_VALUE_3 = "BufferValue3"
const val BUFFER_VALUE_4 = "BufferValue4"
const val DEVICE_ID = "DEVICE_ID"
const val BUFFER_LED_LOWER_BOUND = 20000
const val BUFFER_LED_HIGHER_BOUND = 24000
}

View File

@@ -45,12 +45,13 @@ class HemoCubeFragment : Fragment() {
private val testingTrace = Firebase.performance.newTrace("testing_trace")
private var led1BufferForDevice = 0.0
private var led2BufferForDevice = 0.0
private var led3BufferForDevice = 0.0
private var led3BufferForDevice = 0.0
private var led4BufferForDevice = 0.0
private var led1SampleForDevice = 0.0
private var led2SampleForDevice = 0.0
private var led3SampleForDevice = 0.0
private var led3SampleForDevice = 0.0
private var led4SampleForDevice = 0.0
private var validationError = false
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
@@ -84,8 +85,8 @@ class HemoCubeFragment : Fragment() {
binding.nameEditText.visibility = View.GONE
binding.tvTitle.visibility = View.GONE
binding.btnGo.visibility = View.GONE
binding.btnSubmit.isEnabled = true
binding.btnSubmit.isClickable = true
binding.btnSubmit.isEnabled = false
binding.btnSubmit.isClickable = false
binding.btnPlacebuffer.visibility = View.GONE
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
@@ -96,8 +97,8 @@ class HemoCubeFragment : Fragment() {
binding.tvSubtitle4.visibility = View.VISIBLE
binding.tvSubtitle4.text = "Sample Started"
}
startSampleProcess()
it.visibility = View.GONE
startSampleProcess()
it.visibility = View.GONE
}
binding.btnPlacebuffer.setOnClickListener {
@@ -106,10 +107,13 @@ class HemoCubeFragment : Fragment() {
} else {
activity?.runOnUiThread {
binding.tvSubtitle4.visibility = View.VISIBLE
// binding.tvSubtitle4.text = "Buffer Started"
}
checkAndStartProcess()
it.visibility = View.GONE
}
it.visibility = View.GONE
}
}
@@ -352,7 +356,8 @@ class HemoCubeFragment : Fragment() {
sampleIntensity = resultLines[7].split(' ')[1].trim()
led3SampleForDevice = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
sampleIntensity = resultLines[8].split(' ')[1].split('\r')[0].trim()
led4SampleForDevice = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
led4SampleForDevice =
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
processResult()
}
}
@@ -389,6 +394,7 @@ class HemoCubeFragment : Fragment() {
private fun processResult() {
try {
hemoCubeViewModel.messages.postValue("processing result")
val deviceLog = resultData
val pInfo = requireActivity().packageManager.getPackageInfo(
@@ -400,11 +406,36 @@ class HemoCubeFragment : Fragment() {
val led2Average = log10(led2BufferForDevice?.div(led2SampleForDevice!!) ?: 0.0)
val led3Average = log10(led3BufferForDevice?.div(led3SampleForDevice!!) ?: 0.0)
val led4Average = log10(led4BufferForDevice?.div(led4SampleForDevice!!) ?: 0.0)
val deviceRatio = led1Average / led3Average
val deviceRatio = led3Average / led1Average
if (led1Average < 0 || led2Average < 0) {
if (led1Average < 0 || led2Average < 0 || led3Average < 0 || led4Average < 0) {
validationError = true
activity?.runOnUiThread {
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
binding.errorMessage.text = "Error: Negative Abs. Retake Blank Reading"
binding.errorMessage.visibility = View.VISIBLE
}
}
if (led1BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|| led2BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|| led3BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
|| led4BufferForDevice < Constants.BUFFER_LED_LOWER_BOUND
) {
validationError = true
activity?.runOnUiThread {
binding.errorMessage.text = "Error: Invalid Test. Blank reading is too low"
binding.errorMessage.visibility = View.VISIBLE
}
}
if (led1BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|| led2BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|| led3BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
|| led4BufferForDevice > Constants.BUFFER_LED_HIGHER_BOUND
) {
validationError = true
activity?.runOnUiThread {
binding.errorMessage.text = "Error: Invalid Test. Blank reading is too high"
binding.errorMessage.visibility = View.VISIBLE
}
}
@@ -440,12 +471,14 @@ 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"))
}
binding.btnSubmit.isEnabled = true
binding.btnSubmit.isClickable = true
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
}
}
} catch (e: Exception) {
Toast.makeText(
@@ -459,6 +492,7 @@ class HemoCubeFragment : Fragment() {
private fun findResult(calculatedRatio: Double?): String {
try {
hemoCubeViewModel.messages.postValue("result classification")
if (calculatedRatio != null) {
if (calculatedRatio < 0.05)
return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
@@ -475,14 +509,14 @@ class HemoCubeFragment : Fragment() {
if (calculatedRatio > 0.35)
return "Inconclusive. Repeat with test with lower volume of blood"
} else {
return "NULL"
return "INVALID"
}
} catch (e: Exception) {
showToast("error while performing classification")
Firebase.crashlytics.recordException(e)
return "ERROR"
}
return "NULL"
return "INVALID"
}
private fun showToast(message: String) {