From 0b17ea9ab99ef8bcc485ab872a9e29742cacff00 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Wed, 13 Dec 2023 18:49:19 +0530 Subject: [PATCH 1/2] display hb3 and hb4 --- app/build.gradle | 2 +- .../hpostesting/data/constant/Constants.kt | 22 +++++++++++++++++-- .../hpostesting/data/dao/MyDataBase.kt | 2 +- .../data/model/patient/HemoCubeTestData.kt | 2 ++ .../presentation/adapter/UserListAdapter.kt | 3 ++- .../presentation/hemocube/HemoCubeFragment.kt | 16 ++++++++++++-- .../hemocube/HemoCubeViewModel.kt | 2 ++ 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8db906e..ff27811 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,7 +16,7 @@ android { // prod - production, preprod - preproduction, quality - qc, defaultConfig { - applicationId "in.sminnovations.hpostesting" + applicationId "in.sminnovations.hpostesting.quality" minSdk 21 targetSdk 34 versionCode 44 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 fde46ad..6f0fc66 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 @@ -63,6 +63,7 @@ object Constants { "HC-V1-020", "HCV-000-3001", "HCV-000-3002", + "devuser", ) const val password = "SMI@12345" @@ -83,19 +84,36 @@ object Constants { listOf(1.313, -0.89), // LED1, 435nm listOf(0.581462456, -0.58502), // LED2, 415nm listOf(0.2012, 0.0092), // LED3, 555nm - listOf(1.0, 0.0) // LED4 + listOf(1.0, 0.0) // LED4, 560nm ), "HCV-000-3002" to listOf( listOf(0.723142, -0.09135), // LED1, 435nm listOf(0.581462456, -0.58502), // LED2, 415nm listOf(0.1964, 0.011565), // LED3, 555nm - listOf(1.0, 0.0) // LED4 + listOf(1.0, 0.0) // LED4, 560nm + ), + ) + + val DEVICE_HB_PARAMETERS: Map>> = mapOf>>( + "HCV-000-3001" to listOf( + listOf(1.0, 0.0), // LED1, 435nm + listOf(1.0, 0.0), // LED2, 415nm + listOf(0.0305, 0.2067), // LED3, 555nm + listOf(0.0258, 0.5534) // LED4, 560nm + ), + "HCV-000-3002" to listOf( + listOf(1.0, 0.0), // LED1, 435nm + listOf(1.0, 0.0), // LED2, 415nm + listOf(0.0305, 0.2067), // LED3, 555nm + listOf(0.0258, 0.5534) // LED4, 560nm ), ) const val INCUBATION_TIME_MIN = 0 const val INCUBATION_TIME_MAX = 1400 + const val MINIMUM_BATTERY_LEVEL = 0 + val BUFFER_INTENSITY_THRESHOLDS: Map>> = mapOf>>( "HCV-000-3001" to listOf( listOf(20000, 25074), 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 73079ab..a7832c9 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 @@ -11,7 +11,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData import com.google.android.datatransport.runtime.dagger.Provides import javax.inject.Singleton -@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 11, exportSchema = false) +@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 12, exportSchema = false) @TypeConverters(Converters::class) abstract class MyDatabase : RoomDatabase() { abstract fun userDao(): UserDao 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 5b22aee..f1fc78d 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 @@ -43,6 +43,8 @@ data class HemoCubeTestData( var abs2: Double? = null, var abs3: Double? = null, var abs4: Double? = null, + var hb3: Double? = null, + var hb4: Double? = null, var deviceRatio: Double? = null, var calculatedRatio: Double? = null, var predictedDenovixRatio: Double? = null, diff --git a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt index e0034c0..694f154 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt @@ -26,6 +26,7 @@ import android.widget.AutoCompleteTextView import androidx.core.content.ContextCompat.getSystemService import androidx.core.content.getSystemService import androidx.fragment.app.FragmentActivity +import com.example.hpostesting.data.constant.Constants import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel import com.google.firebase.firestore.FirebaseFirestore @@ -196,7 +197,7 @@ class UserListAdapter( // } } userCard.setOnClickListener { - if (batLevel < 40) { + if (batLevel < Constants.MINIMUM_BATTERY_LEVEL) { Toast.makeText( view.context, context?.getString(R.string.low_battery_warning), 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 9dc327e..30db0f0 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 @@ -296,13 +296,15 @@ class HemoCubeFragment : Fragment() { when { stringData.contains("SN") -> { val slData = stringData.split(" ") - if (slData.size > 1) { + if (slData.size > 1 && slData[1].trim().length == 12) { val hardwareId = slData[1].trim() deviceHardwareId = hardwareId with(sharedPreferences.edit()) { putString(Constants.DEVICE_ID, hardwareId) apply() } + } else { + hemoCubeViewModel.messages.postValue("config error") } activity?.runOnUiThread { binding.btnPlacebuffer.visibility = View.VISIBLE @@ -483,6 +485,14 @@ class HemoCubeFragment : Fragment() { constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(3)?.get(1) fittedAbs4 = gradient?.times(led4Average)?.plus(constant!!)!! + val slope3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(0) + val intercept3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(1) + val _hb3 = (led3Average - intercept3!!) / slope3!! + + val slope4 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(0) + val intercept4 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(1) + val _hb4 = (led4Average - intercept4!!) / slope4!! + _predictedDenovixRatio = fittedAbs3.div(fittedAbs1) if (fittedAbs1 <= fittedAbs2) { @@ -530,6 +540,8 @@ class HemoCubeFragment : Fragment() { this.abs2 = fittedAbs2 this.abs3 = fittedAbs3 this.abs4 = fittedAbs4 + this.hb3 = _hb3 + this.hb4 = _hb4 this.deviceRatio = deviceRatio this.calculatedRatio = calculateRatio(deviceRatio) this.predictedDenovixRatio = _predictedDenovixRatio @@ -537,7 +549,7 @@ class HemoCubeFragment : Fragment() { .toString() + ", " + currentDeviceData?.coefficients?.get(1).toString() this.classificationResult = findResult(calculatedRatio) this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio) - hemoCubeViewModel.messages.postValue(this.prdClassification) + hemoCubeViewModel.messages.postValue("Hb3: $_hb3,\n Hb4: $_hb4") this.errorMessages = allErrorMessages this.resultData = deviceLog this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString() 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 b9af079..f711a5a 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 @@ -125,6 +125,8 @@ class HemoCubeViewModel @Inject constructor( testDetails?.abs2 = DataHolder.hemoCubeTestData?.abs2 testDetails?.abs3 = DataHolder.hemoCubeTestData?.abs3 testDetails?.abs4 = DataHolder.hemoCubeTestData?.abs4 + testDetails?.hb3 = DataHolder.hemoCubeTestData?.hb3 + testDetails?.hb4 = DataHolder.hemoCubeTestData?.hb4 testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio From 44d5b4f0bab9ea9ee6813ec905446e88224d75a0 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Wed, 13 Dec 2023 19:03:43 +0530 Subject: [PATCH 2/2] coeffs for hb est --- .../java/com/example/hpostesting/data/constant/Constants.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6f0fc66..78e1020 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 @@ -98,7 +98,7 @@ object Constants { "HCV-000-3001" to listOf( listOf(1.0, 0.0), // LED1, 435nm listOf(1.0, 0.0), // LED2, 415nm - listOf(0.0305, 0.2067), // LED3, 555nm + listOf(42.241, -24.105), // LED3, 555nm listOf(0.0258, 0.5534) // LED4, 560nm ), "HCV-000-3002" to listOf(