add low Hb check and log errors
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting"
|
applicationId "in.sminnovations.hpostesting"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 35
|
versionCode 38
|
||||||
versionName "2.1.35"
|
versionName "2.1.38"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,15 +80,15 @@ object Constants {
|
|||||||
|
|
||||||
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
||||||
"HCV-000-3001" to listOf(
|
"HCV-000-3001" to listOf(
|
||||||
listOf(1.313, -0.9191), // LED1, 435nm
|
listOf(1.313, -0.89), // LED1, 435nm
|
||||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
listOf(0.2012, 0.0092), // LED3, 555nm
|
listOf(0.2012, 0.0092), // LED3, 555nm
|
||||||
listOf(1.0, 0.0) // LED4
|
listOf(1.0, 0.0) // LED4
|
||||||
),
|
),
|
||||||
"HCV-000-3002" to listOf(
|
"HCV-000-3002" to listOf(
|
||||||
listOf(0.587389, 0.0), // LED1, 435nm
|
listOf(1.313, -0.89), // LED1, 435nm
|
||||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
listOf(0.166459, 0.0), // LED3, 555nm
|
listOf(0.2012, 0.0092), // LED3, 555nm
|
||||||
listOf(1.0, 0.0) // LED4
|
listOf(1.0, 0.0) // LED4
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.google.android.datatransport.runtime.dagger.Provides
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 10, exportSchema = false)
|
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 11, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
abstract fun userDao(): UserDao
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ data class HemoCubeTestData(
|
|||||||
var coefficients: String? = "",
|
var coefficients: String? = "",
|
||||||
var classificationResult: String = "",
|
var classificationResult: String = "",
|
||||||
var prdClassification: String = "",
|
var prdClassification: String = "",
|
||||||
|
var errorMessages: String = "",
|
||||||
var batteryLevel: String = "",
|
var batteryLevel: String = "",
|
||||||
var batteryCapacity: String = "",
|
var batteryCapacity: String = "",
|
||||||
var batteryMaxCapacity: String = "",
|
var batteryMaxCapacity: String = "",
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private var _predictedDenovixRatio = 0.0
|
private var _predictedDenovixRatio = 0.0
|
||||||
private var validationError = false
|
private var validationError = false
|
||||||
private var deviceHardwareId = ""
|
private var deviceHardwareId = ""
|
||||||
|
private var allErrorMessages = ""
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
@@ -423,8 +424,9 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|| led4BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(0)!!
|
|| led4BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(0)!!
|
||||||
) {
|
) {
|
||||||
validationError = true
|
validationError = true
|
||||||
|
allErrorMessages += "Error: Invalid Test. Improper buffer reading (low)"
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.errorMessage.text = "Error: Invalid Test. Improper buffer reading (low)"
|
binding.errorMessage.text = "Error: Invalid Test. Improper buffer reading (low)" + "\n"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,6 +437,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|| led4BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(1)!!
|
|| led4BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(1)!!
|
||||||
) {
|
) {
|
||||||
validationError = true
|
validationError = true
|
||||||
|
allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.errorMessage.text =
|
binding.errorMessage.text =
|
||||||
"Error: Invalid Test. Improper buffer reading (high)"
|
"Error: Invalid Test. Improper buffer reading (high)"
|
||||||
@@ -462,6 +465,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
if (fittedAbs1!! <= fittedAbs2!!) {
|
if (fittedAbs1!! <= fittedAbs2!!) {
|
||||||
validationError = true
|
validationError = true
|
||||||
|
allErrorMessages += "Error: Invalid Test. Problem with de-oxygenation" + "\n"
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.errorMessage.text = "Error: Invalid Test. Problem with de-oxygenation"
|
binding.errorMessage.text = "Error: Invalid Test. Problem with de-oxygenation"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
@@ -476,6 +480,15 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fittedAbs3 < 0.1) {
|
||||||
|
validationError = true
|
||||||
|
allErrorMessages += "Error: Low Hb. Repeat test" + "\n"
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.errorMessage.text = "Error: Low Hb. Repeat test"
|
||||||
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()
|
||||||
led1Buffer = led1BufferForDevice
|
led1Buffer = led1BufferForDevice
|
||||||
@@ -503,6 +516,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.classificationResult = findResult(calculatedRatio)
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||||
hemoCubeViewModel.messages.postValue(this.prdClassification)
|
hemoCubeViewModel.messages.postValue(this.prdClassification)
|
||||||
|
this.errorMessages = allErrorMessages
|
||||||
this.resultData = deviceLog
|
this.resultData = deviceLog
|
||||||
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()
|
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()
|
||||||
this.batteryCapacity = hemoCubeViewModel.getBatteryCapacity(requireContext()).toString()
|
this.batteryCapacity = hemoCubeViewModel.getBatteryCapacity(requireContext()).toString()
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||||
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||||
|
testDetails?.errorMessages = DataHolder.hemoCubeTestData?.errorMessages.toString()
|
||||||
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
||||||
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
||||||
testDetails?.batteryMaxCapacity = DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString()
|
testDetails?.batteryMaxCapacity = DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user