Compare commits
43 Commits
2.1.130_s_
...
dev-server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3435f2182 | ||
|
|
f6cdd64ef6 | ||
|
|
7ad21ea5a9 | ||
|
|
6c89efeb5e | ||
|
|
63eaf1cadc | ||
|
|
c180f7be31 | ||
|
|
c243ec6c8f | ||
|
|
7c9238591b | ||
|
|
5c843ca232 | ||
|
|
736dff2b11 | ||
|
|
20dd1e41eb | ||
|
|
ad6670a1e8 | ||
|
|
e6f8ab69e9 | ||
|
|
ccd2138f66 | ||
|
|
d54436996d | ||
|
|
52a555a63a | ||
|
|
8e80cfe525 | ||
|
|
f26f54e51d | ||
|
|
1d029b8ff8 | ||
|
|
c88efd148b | ||
|
|
cb27983d21 | ||
|
|
0b268dda47 | ||
|
|
d9777edf02 | ||
|
|
238424ad89 | ||
|
|
c1f02c878c | ||
|
|
b344dbcb69 | ||
|
|
af7b426416 | ||
|
|
07abfcce6c | ||
|
|
2c62cc11ba | ||
|
|
312e2da79a | ||
|
|
9768a0a835 | ||
|
|
db7aba4549 | ||
|
|
302239d191 | ||
|
|
cc1ae1ff82 | ||
|
|
d420a42fcc | ||
|
|
21b3960ca9 | ||
|
|
9183216cfe | ||
|
|
a72bd3d59e | ||
|
|
54be3a1037 | ||
|
|
69055b5498 | ||
|
|
7dde6bf976 | ||
|
|
ee0f1d748a | ||
|
|
d32e7b6cbb |
@@ -1,3 +1,5 @@
|
||||
# Latest hpos app version
|
||||
## current version : 2.1.132
|
||||
|
||||
### Release key
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ android {
|
||||
// server -> for server switching for internal test
|
||||
defaultConfig {
|
||||
applicationId "in.sminnovations.hpostesting.server"
|
||||
minSdk 21
|
||||
minSdk 30
|
||||
targetSdk 34
|
||||
versionCode 130
|
||||
versionName "2.1.130"
|
||||
versionCode 134
|
||||
versionName "2.1.131"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
@@ -76,7 +77,6 @@ dependencies {
|
||||
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
||||
implementation("com.google.firebase:firebase-perf-ktx")
|
||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||
implementation("com.google.firebase:firebase-config-ktx")
|
||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||
implementation 'com.google.firebase:firebase-firestore-ktx'
|
||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "650071678820",
|
||||
"project_id": "hpos-af3cc",
|
||||
"storage_bucket": "hpos-af3cc.appspot.com"
|
||||
"project_number": "1012719870714",
|
||||
"project_id": "hpos-prod",
|
||||
"storage_bucket": "hpos-prod.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:650071678820:android:f6fd45e2f6a63aef6c6471",
|
||||
"mobilesdk_app_id": "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
||||
"android_client_info": {
|
||||
"package_name": "in.sminnovations.hpostesting.server"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||
"current_key": "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
android:theme="@style/Theme.HPOSTesting"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.dashboard.UpdateValuesActivity"
|
||||
android:name="com.example.hpostesting.presentation.main_base.UpdateValuesActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity"
|
||||
android:name="com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
@@ -74,7 +74,7 @@
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardActivity"
|
||||
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
||||
@@ -106,7 +106,7 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.hemocube.HemocubeActivity"
|
||||
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity"
|
||||
android:exported="false"
|
||||
android:noHistory="true"
|
||||
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||
@@ -133,7 +133,7 @@
|
||||
android:noHistory="true"
|
||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
||||
android:name="com.example.hpostesting.presentation.main_base.DashboardActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/title_activity_dashboard"
|
||||
android:screenOrientation="portrait"
|
||||
|
||||
@@ -28,8 +28,8 @@ object Constants {
|
||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val MOLBIO_INTEGRATION = false
|
||||
const val FIREBASE_INTEGRATION = true
|
||||
var MOLBIO_INTEGRATION = true
|
||||
var FIREBASE_INTEGRATION = false
|
||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||
const val DEVICE_ID_API = "deviceIDAPI"
|
||||
@@ -108,7 +108,6 @@ object Constants {
|
||||
const val DEVICE_ID = "DEVICE_ID"
|
||||
const val LABNAME = "LAB_NAME"
|
||||
const val CUVETTE_SIZE = "CUVETTE_SIZE"
|
||||
const val LAST_UPDATED = "LAST_UPDATED"
|
||||
const val IS_TOKEN_AVAILABLE = "IS_TOKEN_AVAILABLE"
|
||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||
const val BUFFER_LED_UPPER_BOUND = 23500
|
||||
@@ -1584,26 +1583,31 @@ object Constants {
|
||||
listOf(0.0, 0.0)
|
||||
)
|
||||
)
|
||||
//Hemocube for 10mm
|
||||
const val positiveBoderLine10mm1 = 1.3
|
||||
const val positiveBoderLine10mm2 = 1.66
|
||||
const val negativeBoderLine10mm1 = 2.0
|
||||
const val negativeBoderLine10mm2 = 2.4
|
||||
//Trueheme for 10mm
|
||||
//Before changing below values review before
|
||||
//classification borderline metric
|
||||
const val positiveBoderLineMetricCheck10mmMin = 1.3
|
||||
const val positiveBoderLineMetricCheck10mmMax = 1.66
|
||||
const val negativeBoderLineMetricCheck10mmMin = 2.0
|
||||
const val negativeBoderLineMetricCheck10mmMax = 2.4
|
||||
//classification device ratio
|
||||
const val normalMin10mm = 0.07
|
||||
const val normalMax10mm = 0.23
|
||||
const val negativeBorderlineMin10mm = 0.23
|
||||
const val negativeBorderlineMax10mm = 0.27
|
||||
const val sickleCellTraitMin10mm = 0.27
|
||||
const val sickleCellTraitMax10mm = 0.31
|
||||
const val positiveForSickleCellMin10mm = 0.31
|
||||
const val positiveForSickleCellMax10mm = 0.39
|
||||
const val positiveBoderlineMin10mm = 0.31
|
||||
const val positiveBoderlineMax10mm = 0.39
|
||||
const val sickleCellDiseaseMin10mm = 0.39
|
||||
const val sickleCellDiseaseMax10mm = 0.7
|
||||
//Hemocube for 2mm
|
||||
const val positiveBoderLine2mm1 = 0.8
|
||||
const val positiveBoderLine2mm2 = 1.1
|
||||
const val negativeBoderLine2mm1 = 1.5
|
||||
const val negativeBoderLine2mm2 = 1.9
|
||||
//Trueheme for 2mm
|
||||
//classification borderline metric
|
||||
const val positiveBoderLineMetricCheck2mmMin = 0.8
|
||||
const val positiveBoderLineMetricCheck2mmMax = 1.1
|
||||
const val negativeBoderLineMetricCheck2mmMin = 1.5
|
||||
const val negativeBoderLineMetricCheck2mmMax = 1.9
|
||||
//classification device ratio
|
||||
const val normalMin2mm = 0.1
|
||||
const val normalMax2mm = 0.23
|
||||
const val negativeBorderlineMin2mm = 0.23
|
||||
@@ -1624,6 +1628,7 @@ object Constants {
|
||||
const val min10mmLed2 = 0.05
|
||||
const val max10mmLed2 = 0.41
|
||||
|
||||
//Check used in handling the buffer values on buffer complete
|
||||
const val bufferMinLed1 = 21000.00
|
||||
const val bufferMaxLed1 = 23000.00
|
||||
const val bufferMinLed2 = 17000.00
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
||||
import com.example.hpostesting.firebase.FirebaseManager
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
||||
import com.example.hpostesting.util.NetworkMonitor
|
||||
import com.example.hpostesting.util.PropertyProvider
|
||||
import com.example.hpostesting.util.PropertyProviderImpl
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
@@ -240,8 +241,12 @@ object AppModule {
|
||||
return UsbServiceListenerImpl(context)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideNetworkMonitor(
|
||||
@ApplicationContext context: Context
|
||||
): NetworkMonitor {
|
||||
return NetworkMonitor(context).apply { startMonitoring() }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ package com.example.hpostesting.firebase
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Process
|
||||
import androidx.core.content.edit
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.google.firebase.FirebaseApp
|
||||
import com.google.firebase.FirebaseOptions
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
@@ -27,8 +29,8 @@ import javax.inject.Inject
|
||||
|
||||
class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
|
||||
private val sharedPreferences =
|
||||
context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
||||
private val sharedPreferencesServerConfig = context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
||||
private val sharedPreferencesDev = context.getSharedPreferences("DevMode",Context.MODE_PRIVATE)
|
||||
|
||||
private var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
||||
private var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
||||
@@ -36,7 +38,8 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
|
||||
private val defaultServers = listOf(
|
||||
// i have it in different place look down
|
||||
firebaseConfig1, firebaseConfig2, firebaseConfig3,
|
||||
firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd,
|
||||
configMolbio //not a firebase config
|
||||
)
|
||||
|
||||
init {
|
||||
@@ -44,15 +47,33 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
switchServer(lastSelectedServer)
|
||||
}
|
||||
|
||||
|
||||
fun setDevModeOn(state : Boolean){
|
||||
sharedPreferencesDev.edit {
|
||||
putBoolean( "isDevModeOn",state )
|
||||
}
|
||||
}
|
||||
|
||||
fun getDevMode(): Boolean {
|
||||
return sharedPreferencesDev.getBoolean("isDevModeOn",false)
|
||||
}
|
||||
|
||||
|
||||
fun getCurrentFirestore(): FirebaseFirestore = currentFirestore
|
||||
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
||||
|
||||
fun switchServer(firebaseConfig: FirebaseConfig) {
|
||||
saveSelectedServer(firebaseConfig)
|
||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
||||
updateStatus = true
|
||||
if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){
|
||||
saveSelectedServer(firebaseConfig)
|
||||
makeMolbioAsBackEnd()
|
||||
}else {
|
||||
makeSMIBackEnd()
|
||||
saveSelectedServer(firebaseConfig)
|
||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
||||
updateStatus = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +81,6 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
||||
|
||||
return if (existingApp != null) {
|
||||
|
||||
existingApp
|
||||
} else {
|
||||
|
||||
@@ -73,7 +93,7 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
}
|
||||
|
||||
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
||||
with(sharedPreferences.edit()) {
|
||||
with(sharedPreferencesServerConfig.edit()) {
|
||||
putString("selectedServerName", firebaseConfig.serverName)
|
||||
putString("projectId", firebaseConfig.projectId)
|
||||
putString("appId", firebaseConfig.appId)
|
||||
@@ -93,12 +113,12 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
|
||||
fun getLastSelectedServer(): FirebaseConfig {
|
||||
val selectedServerName =
|
||||
sharedPreferences.getString("selectedServerName", defaultServers.first().serverName)
|
||||
val projectId = sharedPreferences.getString("projectId", defaultServers.first().projectId)
|
||||
val appId = sharedPreferences.getString("appId", defaultServers.first().appId)
|
||||
val apiKey = sharedPreferences.getString("apiKey", defaultServers.first().apiKey)
|
||||
sharedPreferencesServerConfig.getString("selectedServerName", defaultServers.first().serverName)
|
||||
val projectId = sharedPreferencesServerConfig.getString("projectId", defaultServers.first().projectId)
|
||||
val appId = sharedPreferencesServerConfig.getString("appId", defaultServers.first().appId)
|
||||
val apiKey = sharedPreferencesServerConfig.getString("apiKey", defaultServers.first().apiKey)
|
||||
val storageBucket =
|
||||
sharedPreferences.getString("storageBucket", defaultServers.first().storageBucket)
|
||||
sharedPreferencesServerConfig.getString("storageBucket", defaultServers.first().storageBucket)
|
||||
|
||||
return FirebaseConfig(
|
||||
serverName = selectedServerName ?: defaultServers.first().serverName,
|
||||
@@ -112,6 +132,16 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
||||
fun getAvailableServers(): List<FirebaseConfig> {
|
||||
return defaultServers
|
||||
}
|
||||
|
||||
private fun makeMolbioAsBackEnd(){
|
||||
Constants.FIREBASE_INTEGRATION = false
|
||||
Constants.MOLBIO_INTEGRATION = true
|
||||
restartApp()
|
||||
}
|
||||
private fun makeSMIBackEnd(){
|
||||
Constants.FIREBASE_INTEGRATION = true
|
||||
Constants.MOLBIO_INTEGRATION = false
|
||||
}
|
||||
}
|
||||
|
||||
fun restartApp(context: Context) {
|
||||
@@ -128,7 +158,7 @@ fun delayedRestart(context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
private val firebaseConfig1 = FirebaseConfig(
|
||||
private val firebaseConfigDev = FirebaseConfig(
|
||||
serverName = "dev",
|
||||
apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
||||
appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
||||
@@ -136,7 +166,7 @@ private val firebaseConfig1 = FirebaseConfig(
|
||||
storageBucket = "hpos-af3cc.appspot.com"
|
||||
)
|
||||
|
||||
private val firebaseConfig2 = FirebaseConfig(
|
||||
private val firebaseConfigQaQc = FirebaseConfig(
|
||||
serverName = "qc-qa",
|
||||
apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
||||
appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
||||
@@ -144,10 +174,26 @@ private val firebaseConfig2 = FirebaseConfig(
|
||||
storageBucket = "hpos-qa.appspot.com"
|
||||
)
|
||||
|
||||
private val firebaseConfig3 = FirebaseConfig(
|
||||
private val firebaseConfigProd = FirebaseConfig(
|
||||
serverName = "prod",
|
||||
apiKey = "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs",
|
||||
appId = "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
||||
projectId = "hpos-prod",
|
||||
storageBucket = "hpos-prod.appspot.com"
|
||||
)
|
||||
|
||||
private val firebaseConfigPreProd = FirebaseConfig(
|
||||
serverName = "pre prod",
|
||||
apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
||||
appId = "1:121176529204:android:a7bc0842f61e5095bbed61",
|
||||
appId = "1:121176529204:android:e6841fdac57bdc95bbed61",
|
||||
projectId = "hpos-preprod",
|
||||
storageBucket = "hpos-preprod.appspot.com"
|
||||
)
|
||||
|
||||
private val configMolbio = FirebaseConfig(
|
||||
serverName = "molbio",
|
||||
apiKey = "molbio",
|
||||
appId = "molbio",
|
||||
projectId = "molbio",
|
||||
storageBucket = "molbio"
|
||||
)
|
||||
@@ -19,7 +19,6 @@ import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -27,12 +26,10 @@ import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.model.test.TestType
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.journeyapps.barcodescanner.ScanContract
|
||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||
import com.journeyapps.barcodescanner.ScanOptions
|
||||
@@ -50,7 +47,6 @@ import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlin.math.max
|
||||
|
||||
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
private var fromWhere = "Home"
|
||||
@@ -145,19 +141,25 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
||||
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
||||
|
||||
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||
// moveToNext()
|
||||
// }else{
|
||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||
moveToNext()
|
||||
} else {
|
||||
Toast.makeText(this@KitScanActivity, "Limit Reached, Use New KIT for testing", Toast.LENGTH_SHORT).show()
|
||||
DataHolder.sampleReadCounter = 0
|
||||
DataHolder.kitSerial = ""
|
||||
}else{
|
||||
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
||||
moveToNext()
|
||||
} else {
|
||||
Toast.makeText(this@KitScanActivity, "Limit Reached, Use New KIT for testing", Toast.LENGTH_SHORT).show()
|
||||
DataHolder.sampleReadCounter = 0
|
||||
DataHolder.kitSerial = ""
|
||||
|
||||
with(sharedPreference.edit()) {
|
||||
putString(Constants.KIT_NUMBER, "")
|
||||
putString(Constants.BUFFER_VALUE_1, "")
|
||||
putString(Constants.BUFFER_VALUE_2, "")
|
||||
apply()
|
||||
with(sharedPreference.edit()) {
|
||||
putString(Constants.KIT_NUMBER, "")
|
||||
putString(Constants.BUFFER_VALUE_1, "")
|
||||
putString(Constants.BUFFER_VALUE_2, "")
|
||||
apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,7 +376,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
DataHolder.deviceType.observe(this) { deviceType ->
|
||||
when (deviceType) {
|
||||
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
||||
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
||||
startActivity(i)
|
||||
}
|
||||
|
||||
@@ -384,7 +386,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
}
|
||||
|
||||
Constants.DEVICE_TYPE_TRUEHEME -> {
|
||||
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.model.test.TestType
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.google.android.gms.location.FusedLocationProviderClient
|
||||
import com.google.android.gms.location.LocationCallback
|
||||
import com.google.android.gms.location.LocationRequest
|
||||
|
||||
@@ -28,7 +28,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.example.hpostesting.util.MyUtils
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||
|
||||
@@ -29,7 +29,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
@@ -42,7 +42,7 @@ import java.util.Locale
|
||||
|
||||
class UserListAdapter(
|
||||
private val context: Context,
|
||||
private val hemoCubeViewModel: HemoCubeViewModel,
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel,
|
||||
options: FirestoreRecyclerOptions<UserData>,
|
||||
private val view: View,
|
||||
private val batLevel: Int,
|
||||
|
||||
@@ -31,7 +31,7 @@ import androidx.fragment.app.Fragment
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
||||
import java.time.Instant
|
||||
|
||||
@@ -259,7 +259,7 @@ class AssuranceControlsFragment : Fragment() {
|
||||
apply()
|
||||
}
|
||||
|
||||
val i = Intent(requireContext(), HemocubeActivity::class.java)
|
||||
val i = Intent(requireContext(), TrueHemeTestActivity::class.java)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
@@ -44,7 +44,7 @@ import kotlin.math.log10
|
||||
class HemoCubeBufferCheckFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
private var currentDeviceData: DeviceData? = null
|
||||
private var resultData: String = ""
|
||||
@@ -123,13 +123,13 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun observeViewModel() {
|
||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
currentDeviceData = it
|
||||
}
|
||||
|
||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
if (isNetworkAvailable) {
|
||||
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||
trueHemeTestViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||
} else {
|
||||
Toast.makeText(
|
||||
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
||||
@@ -137,7 +137,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
isOnline = isNetworkAvailable
|
||||
}
|
||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||
trueHemeTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||
if (result == "Success") {
|
||||
showToast(R.string.kit_uploaded)
|
||||
}
|
||||
@@ -152,11 +152,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
}
|
||||
|
||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.messages.observe(viewLifecycleOwner) {
|
||||
binding.tvSubtitle4.text = it
|
||||
}
|
||||
|
||||
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||
binding.tvDeviceMessages.text = it
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
|
||||
resultData += stringData
|
||||
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
||||
|
||||
when {
|
||||
stringData.contains("SN") -> {
|
||||
@@ -209,11 +209,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||
}
|
||||
hemoCubeViewModel.messages.postValue("Start")
|
||||
trueHemeTestViewModel.messages.postValue("Start")
|
||||
}
|
||||
|
||||
stringData.contains("#BS") -> {
|
||||
hemoCubeViewModel.messages.postValue("Buffer Started")
|
||||
trueHemeTestViewModel.messages.postValue("Buffer Started")
|
||||
}
|
||||
|
||||
stringData.contains("#BC") -> {
|
||||
@@ -232,7 +232,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
|
||||
stringData.contains("#SC") -> {
|
||||
hemoCubeViewModel.messages.postValue("Sample Completed \nGathering data")
|
||||
trueHemeTestViewModel.messages.postValue("Sample Completed \nGathering data")
|
||||
fetchResult()
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
|
||||
val prdClassification = absorbanceBasedClassification(_predictedDenovixRatio)
|
||||
hemoCubeViewModel.messages.postValue(prdClassification)
|
||||
trueHemeTestViewModel.messages.postValue(prdClassification)
|
||||
|
||||
val bufferData = BufferCheckData(
|
||||
_id = UUID.randomUUID().toString(),
|
||||
@@ -385,15 +385,15 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
testTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time),
|
||||
batteryLevel = hemoCubeViewModel.getBatteryLevel().toString(),
|
||||
batteryCapacity = hemoCubeViewModel.getBatteryCapacity(requireContext()).toString(),
|
||||
batteryMaxCapacity = hemoCubeViewModel.getBatteryMaxCapacity(requireContext())
|
||||
batteryLevel = trueHemeTestViewModel.getBatteryLevel().toString(),
|
||||
batteryCapacity = trueHemeTestViewModel.getBatteryCapacity(requireContext()).toString(),
|
||||
batteryMaxCapacity = trueHemeTestViewModel.getBatteryMaxCapacity(requireContext())
|
||||
.toString(),
|
||||
batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString(),
|
||||
batteryVoltage = hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
||||
batteryTemperature = trueHemeTestViewModel.getBatteryTemperature().toString(),
|
||||
batteryVoltage = trueHemeTestViewModel.getBatteryVoltage(requireContext()).toString()
|
||||
)
|
||||
|
||||
hemoCubeViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(
|
||||
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
||||
@@ -404,7 +404,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
|
||||
private fun findResult(calculatedRatio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
trueHemeTestViewModel.messages.postValue("result classification")
|
||||
if (calculatedRatio != null) {
|
||||
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||
if (calculatedRatio in 0.05..0.155) return "Normal"
|
||||
@@ -426,7 +426,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
|
||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
trueHemeTestViewModel.messages.postValue("result classification")
|
||||
if (predictedDenovixRatio != null) {
|
||||
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
||||
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
||||
@@ -482,20 +482,20 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun getDeviceInfo() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
hemoCubeViewModel.messages.postValue(stringData)
|
||||
trueHemeTestViewModel.messages.postValue(stringData)
|
||||
binding.tvSubtitle4.text = stringData
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.util.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
@@ -47,7 +47,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||
@AndroidEntryPoint
|
||||
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityHemocubeBinding
|
||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||
private var myMenu: Menu? = null
|
||||
|
||||
private lateinit var mDriver: UsbSerialDriver
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.data.model.calibration.CalibrationData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
class AppVersionTapManager {
|
||||
|
||||
private var tapCount = 0
|
||||
private val maxTapCount = 5
|
||||
|
||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
||||
tapCount++
|
||||
if (tapCount >= maxTapCount) {
|
||||
onMaxTapsReached()
|
||||
reset()
|
||||
}
|
||||
}
|
||||
private fun reset() {
|
||||
tapCount = 0
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||
* // Notice: All information contained herein is, and remains
|
||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||
* // if any. The intellectual and technical concepts contained
|
||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||
* // patents in process, and are protected by trade secret or copyright law.
|
||||
* // Dissemination of this information or reproduction of this material
|
||||
* // is strictly forbidden unless prior written permission is obtained
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
interface ItemClickListener {
|
||||
fun onClick(pos: Int)
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||
* // Notice: All information contained herein is, and remains
|
||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||
* // if any. The intellectual and technical concepts contained
|
||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||
* // patents in process, and are protected by trade secret or copyright law.
|
||||
* // Dissemination of this information or reproduction of this material
|
||||
* // is strictly forbidden unless prior written permission is obtained
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard.ui.gallery
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class mGalleryViewModel : ViewModel() {
|
||||
|
||||
private val _text = MutableLiveData<String>().apply {
|
||||
value = "This is gallery Fragment"
|
||||
}
|
||||
val text: LiveData<String> = _text
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||
* // Notice: All information contained herein is, and remains
|
||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||
* // if any. The intellectual and technical concepts contained
|
||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||
* // patents in process, and are protected by trade secret or copyright law.
|
||||
* // Dissemination of this information or reproduction of this material
|
||||
* // is strictly forbidden unless prior written permission is obtained
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard.ui.slideshow
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class SlideshowViewModel : ViewModel() {
|
||||
|
||||
private val _text = MutableLiveData<String>().apply {
|
||||
value = "This is slideshow Fragment"
|
||||
}
|
||||
val text: LiveData<String> = _text
|
||||
}
|
||||
@@ -26,14 +26,14 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
||||
|
||||
class DeviceFragment : Fragment() {
|
||||
private lateinit var binding: FragmentDeviceBinding
|
||||
private val deviceViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val deviceViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
private var deviceId = ""
|
||||
private var startListening = MutableLiveData(false)
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
@@ -34,13 +33,11 @@ import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.encryption.Encryption
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
||||
class DeviceProvisionFragment : Fragment() {
|
||||
private var resultData: String = ""
|
||||
|
||||
@@ -11,29 +11,14 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.BatteryManager
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
private lateinit var binding: FragmentAboutBinding
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.content.Context
|
||||
import android.os.BatteryManager
|
||||
@@ -23,7 +23,7 @@ import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
@@ -32,7 +32,7 @@ import java.util.Locale
|
||||
|
||||
class ActivitiesFragment : Fragment() {
|
||||
private lateinit var binding: FragmentActivitiesBinding
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var adapter: OfflineUserListAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
@@ -46,12 +46,12 @@ class ActivitiesFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
hemoCubeViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
||||
trueHemeTestViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
||||
|
||||
if (userData.isNotEmpty()) {
|
||||
userData.forEach { user ->
|
||||
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0 ) && user.testStatus == false){
|
||||
hemoCubeViewModel.deleteByStatus()
|
||||
trueHemeTestViewModel.deleteByStatus()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
||||
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
||||
|
||||
class AppVersionTapManager {
|
||||
|
||||
private var tapCount = 0
|
||||
private val maxTapCount = 5
|
||||
val shouldEnable = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
||||
val notEnable = MOLBIO_INTEGRATION && !FIREBASE_INTEGRATION
|
||||
|
||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
||||
tapCount++
|
||||
if (tapCount >= maxTapCount && shouldEnable) {
|
||||
onMaxTapsReached()
|
||||
reset()
|
||||
}
|
||||
}
|
||||
private fun reset() {
|
||||
tapCount = 0
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
@@ -30,8 +30,6 @@ import android.net.Uri
|
||||
import android.os.BatteryManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.ContactsContract.Data
|
||||
import android.provider.Settings
|
||||
import android.util.Base64
|
||||
import android.util.Log
|
||||
@@ -45,7 +43,6 @@ import androidx.core.content.FileProvider
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
@@ -62,7 +59,7 @@ import com.example.hpostesting.presentation.KitScanActivity
|
||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
@@ -103,12 +100,12 @@ class HomeFragment : Fragment() {
|
||||
private var downloadId: Long = 0
|
||||
private lateinit var binding: FragmentHomeBinding
|
||||
private val viewModel: TestRightViewModel by activityViewModels()
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var rvAdapter: UserListAdapter
|
||||
private var batLevel: Int =
|
||||
0 // Initialize with a default value, or obtain the actual battery level
|
||||
private lateinit var adapter: OfflineUserListAdapter
|
||||
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val homeViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private var isTokenAvailable by Delegates.notNull<Boolean>()
|
||||
private var natsToken: String = ""
|
||||
private var deviceId: String = ""
|
||||
@@ -142,7 +139,7 @@ class HomeFragment : Fragment() {
|
||||
deleteIncompleteRegistrations(userData)
|
||||
}
|
||||
// getLocationIP()
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||
deleteHemoCubeIncompleteRegistrations(userData)
|
||||
if (userData.isNotEmpty()) {
|
||||
val userList = mutableListOf<HemoCubeTestData>()
|
||||
@@ -173,12 +170,12 @@ class HomeFragment : Fragment() {
|
||||
// }
|
||||
|
||||
|
||||
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||
trueHemeTestViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||
if (result == "Success") {
|
||||
Toast.makeText(
|
||||
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||
).show()
|
||||
hemoCubeViewModel.fireBaseBulkUpload.postValue("Done")
|
||||
trueHemeTestViewModel.fireBaseBulkUpload.postValue("Done")
|
||||
}
|
||||
if (result == "Error") {
|
||||
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
||||
@@ -196,7 +193,7 @@ class HomeFragment : Fragment() {
|
||||
// binding.uploadData.setOnClickListener {
|
||||
//// showUploadDialog(requireContext())
|
||||
// }
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||
//
|
||||
// }else{
|
||||
@@ -291,7 +288,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
private fun checkNetworkStatus() {
|
||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||
// Toast.makeText(requireContext(),"connected"+isConnected+wasConnected, Toast.LENGTH_SHORT).show()
|
||||
if(isConnected){
|
||||
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
||||
@@ -381,10 +378,10 @@ class HomeFragment : Fragment() {
|
||||
|
||||
}*/
|
||||
if(Constants.MOLBIO_INTEGRATION){
|
||||
hemoCubeViewModel.sendDataToMolbio()
|
||||
trueHemeTestViewModel.sendDataToMolbio()
|
||||
}
|
||||
if(Constants.FIREBASE_INTEGRATION) {
|
||||
hemoCubeViewModel.sendDataToFirebase()
|
||||
trueHemeTestViewModel.sendDataToFirebase()
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -437,7 +434,7 @@ class HomeFragment : Fragment() {
|
||||
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
}else{
|
||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
}
|
||||
//isTokenAvailable = true
|
||||
// hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
@@ -463,7 +460,7 @@ class HomeFragment : Fragment() {
|
||||
callLogin(userID, password)
|
||||
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
}else{
|
||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -474,7 +471,7 @@ class HomeFragment : Fragment() {
|
||||
).show()
|
||||
}
|
||||
|
||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||
trueHemeTestViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
updateTokens(response)
|
||||
@@ -505,14 +502,14 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
|
||||
Log.d("success,", "uploded")
|
||||
it.data.data?.forEach { id ->
|
||||
id.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
trueHemeTestViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
)
|
||||
}
|
||||
@@ -539,7 +536,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||
trueHemeTestViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
// Toast.makeText(
|
||||
@@ -569,7 +566,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||
trueHemeTestViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
val updatedversion = response.data.data?.version.toString()
|
||||
@@ -595,7 +592,7 @@ class HomeFragment : Fragment() {
|
||||
Log.d("versionnow", currentversion.toString())
|
||||
Log.d("versionnow", updatedversion.toString())
|
||||
if (updatedversion > currentversion.toString()) {
|
||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||
trueHemeTestViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||
Toast.makeText(
|
||||
activity,
|
||||
"new version ${response.data.data?.version} Available",
|
||||
@@ -631,7 +628,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
||||
trueHemeTestViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
val url = response.data
|
||||
@@ -818,7 +815,7 @@ class HomeFragment : Fragment() {
|
||||
lifecycleScope.launch {
|
||||
// Add user first, ensuring it's done before fetching the user
|
||||
withContext(Dispatchers.IO) {
|
||||
hemoCubeViewModel.addUser(
|
||||
trueHemeTestViewModel.addUser(
|
||||
HemoCubeTestData(
|
||||
_id = userId,
|
||||
age = age,
|
||||
@@ -832,7 +829,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
// Now fetch the user after the addUser operation is complete
|
||||
val user = withContext(Dispatchers.IO) {
|
||||
hemoCubeViewModel.hemoCubeDao.getUserByID(userId)
|
||||
trueHemeTestViewModel.hemoCubeDao.getUserByID(userId)
|
||||
}
|
||||
|
||||
user?.let {
|
||||
@@ -954,7 +951,7 @@ class HomeFragment : Fragment() {
|
||||
rvAdapter = view?.let {
|
||||
UserListAdapter(
|
||||
requireContext(),
|
||||
hemoCubeViewModel,
|
||||
trueHemeTestViewModel,
|
||||
recyclerViewOptions,
|
||||
it,
|
||||
batLevel,
|
||||
@@ -1023,7 +1020,7 @@ class HomeFragment : Fragment() {
|
||||
rvAdapter = view?.let {
|
||||
UserListAdapter(
|
||||
requireContext(),
|
||||
hemoCubeViewModel,
|
||||
trueHemeTestViewModel,
|
||||
recyclerViewOptions,
|
||||
it,
|
||||
batLevel,
|
||||
@@ -1099,7 +1096,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkUnprocessedCSVData() {
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||
val downloadDataVisibility =
|
||||
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||
@@ -1220,7 +1217,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||
var csvDownloaded = false
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
|
||||
//
|
||||
// userDataList.forEach { userData ->
|
||||
@@ -1259,7 +1256,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
if (downloadList.isNotEmpty()) {
|
||||
// Call ViewModel function to create CSV with filtered data
|
||||
hemoCubeViewModel.createCSV(downloadList, requireContext())
|
||||
trueHemeTestViewModel.createCSV(downloadList, requireContext())
|
||||
csvDownloaded = true
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
@@ -1291,19 +1288,19 @@ class HomeFragment : Fragment() {
|
||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||
userDataList.forEach { userData ->
|
||||
if (userData._id.isEmpty()) {
|
||||
hemoCubeViewModel.deleteById(userData._id)
|
||||
trueHemeTestViewModel.deleteById(userData._id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
hemoCubeViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
||||
hemoCubeViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
||||
hemoCubeViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
||||
hemoCubeViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
||||
hemoCubeViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
||||
hemoCubeViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
||||
trueHemeTestViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
||||
}
|
||||
|
||||
private fun downloadCsv() {
|
||||
@@ -1679,10 +1676,10 @@ class HomeFragment : Fragment() {
|
||||
apply()
|
||||
}
|
||||
}
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
||||
}
|
||||
}else{
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
||||
}
|
||||
}
|
||||
private fun timeDifference(createdAt: String): Long {
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
@@ -23,7 +23,6 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
@@ -38,14 +37,10 @@ import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||
import com.example.hpostesting.firebase.FirebaseManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.presentation.jig.JigActivity
|
||||
import com.example.hpostesting.presentation.utils.NatsManager
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
||||
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
||||
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.BuildConfig
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
@@ -67,7 +62,6 @@ open interface IDataCollector: NatsMessageCallback {
|
||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
@Inject
|
||||
lateinit var databaseRepository: DatabaseRepository
|
||||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
||||
val TAG = "DashboardActivity"
|
||||
private var isRegistered = false
|
||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||
@@ -78,7 +72,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
|
||||
private var downloadId: Long = 0
|
||||
// TODO: Remove hemocube viewmodel
|
||||
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
||||
private val hemocubeViewModel: TrueHemeTestViewModel by viewModels()
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
@@ -122,90 +116,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
nats.sub("server.hpos.${deviceId}.ping")
|
||||
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
||||
|
||||
val configSettings = remoteConfigSettings {
|
||||
minimumFetchIntervalInSeconds = 3600
|
||||
}
|
||||
remoteConfig.setConfigSettingsAsync(configSettings)
|
||||
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
||||
|
||||
remoteConfig.fetchAndActivate()
|
||||
.addOnCompleteListener(this) { task ->
|
||||
if (task.isSuccessful) {
|
||||
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
||||
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
||||
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
||||
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
||||
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
||||
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
||||
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
||||
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
||||
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
||||
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
||||
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
||||
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
||||
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
||||
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
||||
|
||||
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
||||
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
||||
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
||||
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
||||
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
||||
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
||||
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
||||
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
||||
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
||||
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
||||
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
||||
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
||||
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
||||
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
||||
|
||||
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
||||
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
||||
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
||||
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
||||
with(sharedPreferences.edit()) {
|
||||
putString("bufferMinLed1", bufferMinLed1.toString())
|
||||
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
||||
putString("bufferMinLed2", bufferMinLed2.toString())
|
||||
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
||||
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
||||
putString("normalMax2mm", normalMax2mm.toString())
|
||||
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
||||
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
||||
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
||||
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
||||
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
||||
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
||||
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
||||
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
||||
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
||||
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
||||
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
||||
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
||||
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
||||
putString("normalMax10mm", normalMax10mm.toString())
|
||||
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
||||
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
||||
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
||||
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
||||
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
||||
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
||||
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
||||
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
||||
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
||||
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
||||
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
||||
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
||||
apply()
|
||||
}
|
||||
Log.d(TAG, "Config params updated")
|
||||
} else {
|
||||
Log.d(TAG, "Config params Fetch failed")
|
||||
}
|
||||
}
|
||||
|
||||
hemocubeViewModel.deviceUpdate.observe(this) {
|
||||
Log.d("DashboardLogs",it.toString())
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ComponentName
|
||||
@@ -28,16 +28,16 @@ import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
||||
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
||||
import com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity
|
||||
import com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
||||
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
||||
|
||||
|
||||
class GalleryFragment : Fragment() {
|
||||
class PanelFragment : Fragment() {
|
||||
|
||||
private var _binding: FragmentGalleryBinding? = null
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
@@ -49,7 +49,7 @@ class GalleryFragment : Fragment() {
|
||||
|
||||
private lateinit var sharedPreference: SharedPreferences
|
||||
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreateView(
|
||||
@@ -11,9 +11,8 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
@@ -29,15 +28,18 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||
import com.example.hpostesting.firebase.FirebaseConfig
|
||||
import com.example.hpostesting.firebase.FirebaseManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||
|
||||
|
||||
private var isLanguageChanged = false
|
||||
|
||||
class SlideshowFragment : Fragment() {
|
||||
@@ -58,10 +60,7 @@ class SlideshowFragment : Fragment() {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME, ""))
|
||||
|
||||
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE, "10mm").toString()
|
||||
val time = sharedPreferences.getString(Constants.LAST_UPDATED, "NA").toString()
|
||||
binding.lastUpdated.text = "Last updated config: $time"
|
||||
binding.btnGo.setOnClickListener {
|
||||
var labname = binding.nameEditText.text.toString()
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -99,6 +98,7 @@ class SlideshowFragment : Fragment() {
|
||||
// Do nothing here
|
||||
}
|
||||
}
|
||||
|
||||
binding.spinnerCuvette.setSelection(pos)
|
||||
binding.btnAddSize.setOnClickListener {
|
||||
with(sharedPreferences.edit()) {
|
||||
@@ -115,24 +115,25 @@ class SlideshowFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
class PrefsFragment : PreferenceFragmentCompat(){
|
||||
class PrefsFragment : PreferenceFragmentCompat() {
|
||||
private lateinit var tapManager: AppVersionTapManager
|
||||
private var isServerSelectionVisible = false
|
||||
private lateinit var serverPreference: Preference
|
||||
private lateinit var currentServerPreference: Preference
|
||||
lateinit var firebaseManager: FirebaseManager
|
||||
private var topDevMode = false
|
||||
lateinit var databaseRepository: DatabaseRepository
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
firebaseManager = FirebaseManager(requireContext())
|
||||
firebaseManager = FirebaseManager(requireContext())
|
||||
databaseRepository = (activity as DashboardActivity).databaseRepository
|
||||
|
||||
tapManager = AppVersionTapManager()
|
||||
topDevMode = firebaseManager.getDevMode()
|
||||
val sharedPreference =
|
||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||
|
||||
|
||||
// Language Preference
|
||||
val languagePreference = ListPreference(requireContext()).apply {
|
||||
key = "language_preference"
|
||||
@@ -142,52 +143,100 @@ class PrefsFragment : PreferenceFragmentCompat(){
|
||||
entryValues = arrayOf("en", "kn", "hi")
|
||||
setDefaultValue("en")
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
||||
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
val languageCode = newValue as String
|
||||
updateLanguage(requireContext(), languageCode)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val servers = firebaseManager.getAvailableServers()
|
||||
val serverNames = servers.map { it.serverName }.toTypedArray()
|
||||
|
||||
val serverSelectorPreference = CustomDialogPreference(requireContext()).apply {
|
||||
key = "server_preference"
|
||||
title = "Select the Server"
|
||||
summary = "Current server: $currentServer"
|
||||
setEntries(serverNames)
|
||||
setEntryValues(serverNames)
|
||||
setValue(currentServer)
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
||||
setOnPreferenceChangeListener { newValue ->
|
||||
val preferenceConfig = servers.find { it.serverName == newValue }
|
||||
switchFirebaseServer(preferenceConfig!!)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
// Add preferences to screen
|
||||
preferenceScreen.addPreference(languagePreference)
|
||||
preferenceScreen.addPreference(languagePreference)
|
||||
|
||||
|
||||
val developerToggle = SwitchPreferenceCompat(requireContext()).apply {
|
||||
title = "Developer Options"
|
||||
summary = "Enable or disable developer options"
|
||||
icon =
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.baseline_developer_mode_24)
|
||||
key = "developer_options" // Unique key for SharedPreferences
|
||||
|
||||
// Load toggle state from SharedPreferences
|
||||
isChecked = firebaseManager.getDevMode()
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val isEnabled = newValue as Boolean
|
||||
firebaseManager.setDevModeOn(isEnabled)
|
||||
|
||||
if (!isEnabled) {
|
||||
preferenceScreen.removePreference(this)
|
||||
preferenceScreen.removePreference(serverSelectorPreference)
|
||||
}
|
||||
if (!firebaseManager.getDevMode() && currentServer != "prod"){
|
||||
val prodConfig = servers.find { it.serverName == "prod" }
|
||||
switchFirebaseServer(prodConfig!!)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
val appVersionPreference = Preference(requireContext()).apply {
|
||||
title = "App Version"
|
||||
summary =
|
||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) +"->"+currentServer+"]"
|
||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + "->" + currentServer + "]"
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
||||
|
||||
setOnPreferenceClickListener {
|
||||
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
||||
tapManager.registerTap {
|
||||
if (!isServerSelectionVisible) {
|
||||
showServerSelection()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tapManager.registerTap {
|
||||
firebaseManager.setDevModeOn(true)
|
||||
|
||||
|
||||
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
||||
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
||||
preferenceScreen.addPreference(developerToggle)
|
||||
}
|
||||
if (preferenceScreen.findPreference<ListPreference>("server_preference") == null) {
|
||||
preferenceScreen.addPreference(serverSelectorPreference)
|
||||
}
|
||||
|
||||
developerToggle.isChecked = true
|
||||
updateServerPreference(currentServer)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preferenceScreen.addPreference(appVersionPreference)
|
||||
|
||||
|
||||
currentServerPreference = Preference(requireContext()).apply {
|
||||
key = "current_server_preference"
|
||||
title = "Current Server"
|
||||
summary = "No server selected"
|
||||
isVisible = false
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_done_24)
|
||||
|
||||
setOnPreferenceClickListener {
|
||||
// (activity as? DashboardActivity)?.sendData("hello test data")
|
||||
// Toast.makeText(context, "data sent", Toast.LENGTH_SHORT).show() this was used to send the basic data as test data
|
||||
true
|
||||
}
|
||||
if (firebaseManager.getDevMode()) {
|
||||
developerToggle.isChecked = true // Ensure it's checked
|
||||
preferenceScreen.addPreference(developerToggle)
|
||||
preferenceScreen.addPreference(serverSelectorPreference)
|
||||
}
|
||||
preferenceScreen.addPreference(currentServerPreference)
|
||||
|
||||
setPreferenceScreen(preferenceScreen)
|
||||
|
||||
if (isLanguageChanged) {
|
||||
@@ -196,58 +245,23 @@ class PrefsFragment : PreferenceFragmentCompat(){
|
||||
}
|
||||
|
||||
|
||||
private fun showServerSelection() {
|
||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||
serverPreference = Preference(requireContext()).apply {
|
||||
title = "Select Server"
|
||||
summary = "Choose your server"
|
||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
||||
setOnPreferenceClickListener {
|
||||
showServerSelectionDialog()
|
||||
true
|
||||
}
|
||||
private fun updateServerPreference(newServer: String) {
|
||||
(findPreference<CustomDialogPreference>("server_preference"))?.let { pref ->
|
||||
pref.setValue(newServer)
|
||||
pref.summary = "Current server: $newServer"
|
||||
}
|
||||
|
||||
|
||||
|
||||
preferenceScreen.addPreference(serverPreference)
|
||||
currentServerPreference.isVisible = true
|
||||
currentServerPreference.summary = "Current Server: $currentServer"
|
||||
|
||||
Toast.makeText(requireContext(), "Server selection now available", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun showServerSelectionDialog() {
|
||||
val servers = firebaseManager.getAvailableServers()
|
||||
|
||||
val serverNames = servers.map { it.serverName }.toTypedArray()
|
||||
val builder = AlertDialog.Builder(requireContext())
|
||||
builder.setTitle("Select Server")
|
||||
.setItems(serverNames) { _, which ->
|
||||
val selectedServer = servers[which]
|
||||
|
||||
switchFirebaseServer(selectedServer)
|
||||
}
|
||||
.setNegativeButton("Cancel", null)
|
||||
.show()
|
||||
}
|
||||
|
||||
|
||||
private fun switchFirebaseServer(firebaseConfig: FirebaseConfig) {
|
||||
firebaseManager.switchServer(firebaseConfig)
|
||||
Toast.makeText(requireContext(), "Switched to ${firebaseConfig.serverName}, Please wait for few seconds", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT).show()
|
||||
firebaseManager.restartApp()
|
||||
currentServerPreference.summary = "Current Server: ${firebaseConfig.serverName}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun switchCurrentServer(serverCode: String) {
|
||||
Toast.makeText(requireContext(), "Switched to server: $serverCode", Toast.LENGTH_SHORT)
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Switched to ${firebaseConfig.serverName}, Please wait for few seconds",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
currentServerPreference.summary = "Current Server: $serverCode"
|
||||
|
||||
firebaseManager.restartApp()
|
||||
}
|
||||
|
||||
private fun updateLanguage(context: Context, languageCode: String) {
|
||||
@@ -277,3 +291,47 @@ class PrefsFragment : PreferenceFragmentCompat(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CustomDialogPreference.kt
|
||||
class CustomDialogPreference(context: Context) : Preference(context) {
|
||||
private var entries: Array<String> = arrayOf()
|
||||
private var entryValues: Array<String> = arrayOf()
|
||||
private var currentValue: String = ""
|
||||
private var onValueChangeListener: ((String) -> Boolean)? = null
|
||||
|
||||
fun setEntries(entries: Array<String>) {
|
||||
this.entries = entries
|
||||
}
|
||||
|
||||
fun setEntryValues(values: Array<String>) {
|
||||
this.entryValues = values
|
||||
}
|
||||
|
||||
fun setValue(value: String) {
|
||||
currentValue = value
|
||||
persistString(value)
|
||||
}
|
||||
|
||||
fun setOnPreferenceChangeListener(listener: (String) -> Boolean) {
|
||||
onValueChangeListener = listener
|
||||
}
|
||||
|
||||
override fun onClick() {
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
builder.setTitle(title)
|
||||
|
||||
builder.setSingleChoiceItems(entries, entries.indexOf(currentValue)) { dialog, which ->
|
||||
val newValue = entryValues[which]
|
||||
if (onValueChangeListener?.invoke(newValue) == true) {
|
||||
setValue(newValue)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
builder.show()
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,13 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
package com.example.hpostesting.presentation.main_base
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityUpdateValuesBinding
|
||||
|
||||
class UpdateValuesActivity : AppCompatActivity() {
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.dashboard.ui
|
||||
package com.example.hpostesting.presentation.main_base.ui
|
||||
|
||||
import com.example.hpostesting.util.SecureStorage
|
||||
import android.accounts.Account
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.hpostesting.presentation.dashboard.ui
|
||||
package com.example.hpostesting.presentation.main_base.ui
|
||||
|
||||
import com.example.hpostesting.util.SecureStorage
|
||||
import android.os.Bundle
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.example.hpostesting.presentation.testRight
|
||||
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
|
||||
@@ -19,7 +19,6 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.dao.UserDao
|
||||
import com.example.hpostesting.data.model.CalculationVariableForTest
|
||||
@@ -36,6 +35,7 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
||||
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
||||
import com.example.hpostesting.domain.TestRightResultCalculation
|
||||
import com.example.hpostesting.util.MyUtils
|
||||
import com.example.hpostesting.util.NetworkMonitor
|
||||
import com.google.firebase.storage.FirebaseStorage
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -55,10 +55,10 @@ class TestRightViewModel @Inject constructor(
|
||||
private val saveRawDataTest: SaveRawDataTest,
|
||||
private val repository: DatabaseRepository,
|
||||
private val userDao: UserDao,
|
||||
networkMonitor: NetworkMonitor,
|
||||
context: Context?
|
||||
) : ViewModel() {
|
||||
|
||||
|
||||
var isServiceConnected = false
|
||||
val progressBar = MutableLiveData(false)
|
||||
|
||||
@@ -69,9 +69,8 @@ class TestRightViewModel @Inject constructor(
|
||||
|
||||
var testDetails = DataHolder.selectedTest
|
||||
|
||||
private val _networkStatusLiveData = context?.let { NetworkStatusLiveData(it) }
|
||||
val networkStatusLiveData: NetworkStatusLiveData?
|
||||
get() = _networkStatusLiveData
|
||||
private var _networkStatusLiveData = networkMonitor.isConnected
|
||||
val networkStatusLiveData = _networkStatusLiveData
|
||||
|
||||
val allUserData = userDao.getAll()
|
||||
|
||||
@@ -82,6 +81,11 @@ class TestRightViewModel @Inject constructor(
|
||||
|
||||
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
||||
|
||||
init {
|
||||
networkMonitor.startMonitoring()
|
||||
_networkStatusLiveData = networkMonitor.isConnected
|
||||
}
|
||||
|
||||
fun mapDeviceConstants(string: String) {
|
||||
if (string.isNotEmpty()) {
|
||||
val listOfStrings = string.split(",")
|
||||
|
||||
@@ -36,8 +36,8 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.util.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
@@ -48,7 +48,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||
@AndroidEntryPoint
|
||||
class TrueHemeActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityHemocubeBinding
|
||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||
private var myMenu: Menu? = null
|
||||
|
||||
private lateinit var mDriver: UsbSerialDriver
|
||||
@@ -177,14 +177,14 @@ class TrueHemeActivity : AppCompatActivity() {
|
||||
private fun moveToNext() {
|
||||
if (supportFragmentManager.isDestroyed) return
|
||||
|
||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
|
||||
override fun onBackPressed() {
|
||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||
if (fragment is HemoCubeFragment) {
|
||||
if (fragment is TrueHemeTestFragment) {
|
||||
fragment.handleBackButtonPress()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
|
||||
@@ -36,8 +36,8 @@ import com.example.hpostesting.data.model.TestState
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||
import com.example.hpostesting.presentation.utils.UIUtils
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
@@ -336,7 +336,7 @@ class TrueHemeFragment : Fragment() {
|
||||
startListening.postValue(true)
|
||||
|
||||
try {
|
||||
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||
(activity as TrueHemeTestActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
@@ -357,7 +357,7 @@ class TrueHemeFragment : Fragment() {
|
||||
|
||||
private fun getDeviceInfo() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
@@ -1067,7 +1067,7 @@ class TrueHemeFragment : Fragment() {
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
}
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.START_BUFFER_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1081,7 +1081,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun startSampleProcess() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.START_SAMPLE,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1095,7 +1095,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun sendFirstGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1109,7 +1109,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun sendSecondGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1123,7 +1123,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun sendThirdGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1137,7 +1137,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun sendForthGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1151,7 +1151,7 @@ class TrueHemeFragment : Fragment() {
|
||||
private fun fetchResult() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.PRINT_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -1170,7 +1170,7 @@ class TrueHemeFragment : Fragment() {
|
||||
|
||||
private fun reconnect() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
(activity as HemocubeActivity).reconnectDevice()
|
||||
(activity as TrueHemeTestActivity).reconnectDevice()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,8 @@ import androidx.lifecycle.viewModelScope
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.example.hpostesting.util.CsvWriter
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||
import com.example.hpostesting.util.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||
@@ -46,10 +43,12 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||
import com.example.hpostesting.domain.LogFileManager
|
||||
import com.example.hpostesting.util.CsvWriter
|
||||
import com.example.hpostesting.util.NetworkMonitor
|
||||
import com.example.hpostesting.util.Result
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
@@ -70,20 +69,22 @@ class TrueHemeViewModel @Inject constructor(
|
||||
private val repository: Repository,
|
||||
private val logFileManager: LogFileManager,
|
||||
private val localFileDataSource: LocalFileDataSource,
|
||||
networkMonitor: NetworkMonitor,
|
||||
context: Context,
|
||||
) : ViewModel() {
|
||||
var isServiceConnected = false
|
||||
val progressBar = MutableLiveData(false)
|
||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
val messages = MutableLiveData<String>()
|
||||
private val sharedPreference =
|
||||
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
private val sharedPreference = context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
|
||||
private val workManager = WorkManager.getInstance(context)
|
||||
|
||||
// init {
|
||||
// startPeriodicCheckUpdate()
|
||||
// }
|
||||
// init {
|
||||
// startPeriodicCheckUpdate()
|
||||
// }
|
||||
init {
|
||||
networkMonitor.startMonitoring()
|
||||
}
|
||||
|
||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||
|
||||
@@ -97,7 +98,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
|
||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
private val _networkStatusLiveData = networkMonitor.isConnected
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
@@ -181,7 +182,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
val logFile = logFileManager.createLogFile().let { file ->
|
||||
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||
val multipartFile =
|
||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file.name, it) }
|
||||
multipartFile?.let { partFile ->
|
||||
repository.uploadLogs(partFile).let { result ->
|
||||
uploadLogs.postValue(result)
|
||||
@@ -193,37 +194,35 @@ class TrueHemeViewModel @Inject constructor(
|
||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||
isOnline: Boolean,
|
||||
bufferCheckData: BufferCheckData,
|
||||
) =
|
||||
viewModelScope.launch {
|
||||
if (isOnline) {
|
||||
try {
|
||||
when (val response =
|
||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
is Response.Success -> {
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
bufferCheckData.localFlag = true
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||
fireBaseUpload.postValue("Error")
|
||||
bufferCheckData.localFlag = true
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
) = viewModelScope.launch {
|
||||
if (isOnline) {
|
||||
try {
|
||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
is Response.Success -> {
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
bufferCheckData.localFlag = true
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
|
||||
is Response.Error -> {
|
||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||
fireBaseUpload.postValue("Error")
|
||||
bufferCheckData.localFlag = true
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
} else {
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
fireBaseUpload.postValue("Local")
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
} else {
|
||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||
fireBaseUpload.postValue("Local")
|
||||
}
|
||||
}
|
||||
|
||||
fun bulkAddResultKitTestToDb(bufferCheckData: BufferCheckData) {
|
||||
viewModelScope.launch {
|
||||
@@ -396,8 +395,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
|
||||
when (val response =
|
||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
is Response.Success -> {
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
@@ -415,10 +413,9 @@ class TrueHemeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateBufferLocalFlag(bufferId: String) =
|
||||
viewModelScope.launch {
|
||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||
}
|
||||
private fun updateBufferLocalFlag(bufferId: String) = viewModelScope.launch {
|
||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||
}
|
||||
|
||||
fun getLocalUserDataForCsv(context: Context): Boolean {
|
||||
val localUserDataLiveData: LiveData<List<HemoCubeTestData>> = hemoCubeDao.getAll()
|
||||
@@ -455,16 +452,12 @@ class TrueHemeViewModel @Inject constructor(
|
||||
|
||||
fun getBatteryLevel(): Float? {
|
||||
val batteryPct: Float? = batteryStatus?.let { intent ->
|
||||
val level: Int =
|
||||
intent.getIntExtra(
|
||||
BatteryManager.EXTRA_LEVEL,
|
||||
-1
|
||||
)
|
||||
val scale: Int =
|
||||
intent.getIntExtra(
|
||||
BatteryManager.EXTRA_SCALE,
|
||||
-1
|
||||
)
|
||||
val level: Int = intent.getIntExtra(
|
||||
BatteryManager.EXTRA_LEVEL, -1
|
||||
)
|
||||
val scale: Int = intent.getIntExtra(
|
||||
BatteryManager.EXTRA_SCALE, -1
|
||||
)
|
||||
level * 100 / scale.toFloat()
|
||||
}
|
||||
|
||||
@@ -474,8 +467,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
fun getBatteryTemperature(): Float? {
|
||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||
val temperature = intent.getIntExtra(
|
||||
BatteryManager.EXTRA_TEMPERATURE,
|
||||
0
|
||||
BatteryManager.EXTRA_TEMPERATURE, 0
|
||||
)
|
||||
temperature.toFloat() / 10
|
||||
}
|
||||
@@ -484,14 +476,11 @@ class TrueHemeViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun getBatteryVoltage(context: Context): Float {
|
||||
val batteryIntent =
|
||||
context.registerReceiver(
|
||||
null,
|
||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||
)
|
||||
val batteryIntent = context.registerReceiver(
|
||||
null, IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||
)
|
||||
val voltage = batteryIntent?.getIntExtra(
|
||||
BatteryManager.EXTRA_VOLTAGE,
|
||||
0
|
||||
BatteryManager.EXTRA_VOLTAGE, 0
|
||||
) ?: 0
|
||||
|
||||
// milli-volts to volts
|
||||
@@ -500,8 +489,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
|
||||
|
||||
fun getBatteryCapacity(context: Context): Int {
|
||||
val batteryManager =
|
||||
context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val currentCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
|
||||
@@ -510,8 +498,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
|
||||
fun getBatteryMaxCapacity(context: Context): Float {
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val designCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||
val currentCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
|
||||
@@ -528,8 +515,7 @@ class TrueHemeViewModel @Inject constructor(
|
||||
hemoCubeTestData.forEach { data ->
|
||||
data.localFlag = true
|
||||
hemoCubeDao.updateCSVFieldById(
|
||||
data._id,
|
||||
true
|
||||
data._id, true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
package com.example.hpostesting.presentation.trueheme_test
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
package com.example.hpostesting.presentation.trueheme_test
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
@@ -33,7 +33,7 @@ import java.util.Locale
|
||||
|
||||
class DigitalCardFragment : Fragment() {
|
||||
private lateinit var binding: FragmentDigitalCardBinding
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
package com.example.hpostesting.presentation.trueheme_test
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PendingIntent
|
||||
@@ -25,7 +25,6 @@ import android.content.SharedPreferences
|
||||
import android.hardware.usb.UsbDevice
|
||||
import android.hardware.usb.UsbDeviceConnection
|
||||
import android.hardware.usb.UsbManager
|
||||
import android.icu.text.SimpleDateFormat
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
@@ -37,27 +36,20 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.util.UsbService
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
||||
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
||||
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
@AndroidEntryPoint
|
||||
open class HemocubeActivity : AppCompatActivity() {
|
||||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
||||
open class TrueHemeTestActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityHemocubeBinding
|
||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
||||
private var myMenu: Menu? = null
|
||||
lateinit var sharedPreferences: SharedPreferences
|
||||
private lateinit var mDriver: UsbSerialDriver
|
||||
@@ -117,95 +109,6 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
setupListener()
|
||||
connectUsb(false)
|
||||
val configSettings = remoteConfigSettings {
|
||||
minimumFetchIntervalInSeconds = 10//3600
|
||||
}
|
||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
remoteConfig.setConfigSettingsAsync(configSettings)
|
||||
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
||||
|
||||
remoteConfig.fetchAndActivate()
|
||||
.addOnCompleteListener(this) { task ->
|
||||
if (task.isSuccessful) {
|
||||
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
||||
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
||||
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
||||
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
||||
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
||||
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
||||
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
||||
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
||||
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
||||
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
||||
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
||||
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
||||
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
||||
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
||||
|
||||
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
||||
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
||||
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
||||
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
||||
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
||||
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
||||
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
||||
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
||||
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
||||
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
||||
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
||||
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
||||
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
||||
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
||||
|
||||
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
||||
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
||||
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
||||
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
||||
val time = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time).toString()
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.LAST_UPDATED, time)
|
||||
putString("bufferMinLed1", bufferMinLed1.toString())
|
||||
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
||||
putString("bufferMinLed2", bufferMinLed2.toString())
|
||||
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
||||
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
||||
putString("normalMax2mm", normalMax2mm.toString())
|
||||
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
||||
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
||||
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
||||
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
||||
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
||||
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
||||
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
||||
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
||||
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
||||
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
||||
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
||||
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
||||
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
||||
putString("normalMax10mm", normalMax10mm.toString())
|
||||
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
||||
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
||||
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
||||
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
||||
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
||||
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
||||
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
||||
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
||||
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
||||
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
||||
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
||||
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
||||
apply()
|
||||
}
|
||||
Toast.makeText(this@HemocubeActivity, "Config params updated", Toast.LENGTH_SHORT).show()
|
||||
Log.d(TAG, "Config params updated")
|
||||
} else {
|
||||
Log.d(TAG, "Config params Fetch failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupListener() {
|
||||
@@ -289,7 +192,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
private fun moveToNext() {
|
||||
if (supportFragmentManager.isDestroyed) return
|
||||
|
||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
@@ -304,7 +207,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
// }
|
||||
override fun onBackPressed() {
|
||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||
if (fragment is HemoCubeFragment) {
|
||||
if (fragment is TrueHemeTestFragment) {
|
||||
if (fragment.handleBackButtonPress()) {
|
||||
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
||||
return
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
package com.example.hpostesting.presentation.trueheme_test
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
@@ -38,8 +38,7 @@ import com.example.hpostesting.data.model.TestState
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||
import com.example.hpostesting.presentation.utils.UIUtils
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
@@ -49,28 +48,29 @@ import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBindi
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.log10
|
||||
import kotlin.random.Random
|
||||
|
||||
//This is TrueHemeTestFragment, where actual tests are done first buffer check and then sample check
|
||||
//and finally on submit test data to database if online or store in offline database
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
class HemoCubeFragment : Fragment() {
|
||||
private var positiveBoderLine10mm1=Constants.positiveBoderLine10mm1
|
||||
private var positiveBoderLine10mm2=Constants.positiveBoderLine10mm2
|
||||
private var negativeBoderLine10mm1=Constants.negativeBoderLine10mm1
|
||||
private var negativeBoderLine10mm2=Constants.negativeBoderLine10mm2
|
||||
class TrueHemeTestFragment : Fragment() {
|
||||
private var positiveBoderLine10mm1=Constants.positiveBoderLineMetricCheck10mmMin
|
||||
private var positiveBoderLine10mm2=Constants.positiveBoderLineMetricCheck10mmMax
|
||||
private var negativeBoderLine10mm1=Constants.negativeBoderLineMetricCheck10mmMin
|
||||
private var negativeBoderLine10mm2=Constants.negativeBoderLineMetricCheck10mmMax
|
||||
private var normalMin10mm=Constants.normalMin10mm
|
||||
private var normalMax10mm=Constants.normalMax10mm
|
||||
private var negativeBorderlineMin10mm=Constants.negativeBorderlineMin10mm
|
||||
private var negativeBorderlineMax10mm=Constants.negativeBorderlineMax10mm
|
||||
private var sickleCellTraitMin10mm=Constants.sickleCellTraitMin10mm
|
||||
private var sickleCellTraitMax10mm=Constants.sickleCellTraitMax10mm
|
||||
private var positiveForSickleCellMin10mm=Constants.positiveForSickleCellMin10mm
|
||||
private var positiveForSickleCellMax10mm=Constants.positiveForSickleCellMax10mm
|
||||
private var positiveForSickleCellMin10mm=Constants.positiveBoderlineMin10mm
|
||||
private var positiveForSickleCellMax10mm=Constants.positiveBoderlineMax10mm
|
||||
private var sickleCellDiseaseMin10mm=Constants.sickleCellDiseaseMin10mm
|
||||
private var sickleCellDiseaseMax10mm=Constants.sickleCellDiseaseMax10mm
|
||||
|
||||
private var positiveBoderLine2mm1=Constants.positiveBoderLine2mm1
|
||||
private var positiveBoderLine2mm2=Constants.positiveBoderLine2mm2
|
||||
private var negativeBoderLine2mm1=Constants.negativeBoderLine2mm1
|
||||
private var negativeBoderLine2mm2=Constants.negativeBoderLine2mm2
|
||||
private var positiveBoderLine2mm1=Constants.positiveBoderLineMetricCheck2mmMin
|
||||
private var positiveBoderLine2mm2=Constants.positiveBoderLineMetricCheck2mmMax
|
||||
private var negativeBoderLine2mm1=Constants.negativeBoderLineMetricCheck2mmMin
|
||||
private var negativeBoderLine2mm2=Constants.negativeBoderLineMetricCheck2mmMax
|
||||
private var normalMin2mm=Constants.normalMin2mm
|
||||
private var normalMax2mm=Constants.normalMax2mm
|
||||
private var negativeBorderlineMin2mm=Constants.negativeBorderlineMin2mm
|
||||
@@ -83,7 +83,7 @@ class HemoCubeFragment : Fragment() {
|
||||
private var sickleCellDiseaseMax2mm=Constants.sickleCellDiseaseMax2mm
|
||||
|
||||
private var temperature=""
|
||||
private var cuvetteSize = "10mm"
|
||||
private var cuvetteSizeSP = "10mm"
|
||||
private var checkCuvette = false
|
||||
private var checkRefreshCuvette = false
|
||||
private var checkCuvetteSam = false
|
||||
@@ -92,7 +92,7 @@ class HemoCubeFragment : Fragment() {
|
||||
private var sampleClick = false
|
||||
private var refreshClick = false
|
||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
private var isOnline = false
|
||||
@@ -133,36 +133,7 @@ class HemoCubeFragment : Fragment() {
|
||||
sharedPreferences =
|
||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
|
||||
cuvetteSize = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
||||
positiveBoderLine10mm1 = sharedPreferences.getString("positiveBoderLine10mm1", Constants.positiveBoderLine10mm1.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine10mm1
|
||||
positiveBoderLine10mm2 = sharedPreferences.getString("positiveBoderLine10mm2", Constants.positiveBoderLine10mm2.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine10mm2
|
||||
negativeBoderLine10mm1 = sharedPreferences.getString("negativeBoderLine10mm1", Constants.negativeBoderLine10mm1.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine10mm1
|
||||
negativeBoderLine10mm2 = sharedPreferences.getString("negativeBoderLine10mm2", Constants.negativeBoderLine10mm2.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine10mm2
|
||||
normalMin10mm = sharedPreferences.getString("normalMin10mm", Constants.normalMin10mm.toString())?.toDoubleOrNull() ?: Constants.normalMin10mm
|
||||
normalMax10mm = sharedPreferences.getString("normalMax10mm", Constants.normalMax10mm.toString())?.toDoubleOrNull() ?: Constants.normalMax10mm
|
||||
negativeBorderlineMin10mm = sharedPreferences.getString("negativeBorderlineMin10mm", Constants.negativeBorderlineMin10mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMin10mm
|
||||
negativeBorderlineMax10mm = sharedPreferences.getString("negativeBorderlineMax10mm", Constants.negativeBorderlineMax10mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMax10mm
|
||||
sickleCellTraitMin10mm = sharedPreferences.getString("sickleCellTraitMin10mm", Constants.sickleCellTraitMin10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMin10mm
|
||||
sickleCellTraitMax10mm = sharedPreferences.getString("sickleCellTraitMax10mm", Constants.sickleCellTraitMax10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMax10mm
|
||||
positiveForSickleCellMin10mm = sharedPreferences.getString("positiveForSickleCellMin10mm", Constants.positiveForSickleCellMin10mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMin10mm
|
||||
positiveForSickleCellMax10mm = sharedPreferences.getString("positiveForSickleCellMax10mm", Constants.positiveForSickleCellMax10mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMax10mm
|
||||
sickleCellDiseaseMin10mm = sharedPreferences.getString("sickleCellDiseaseMin10mm", Constants.sickleCellDiseaseMin10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMin10mm
|
||||
sickleCellDiseaseMax10mm = sharedPreferences.getString("sickleCellDiseaseMax10mm", Constants.sickleCellDiseaseMax10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMax10mm
|
||||
|
||||
positiveBoderLine2mm1 = sharedPreferences.getString("positiveBoderLine2mm1", Constants.positiveBoderLine2mm1.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine2mm1
|
||||
positiveBoderLine2mm2 = sharedPreferences.getString("positiveBoderLine2mm2", Constants.positiveBoderLine2mm2.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine2mm2
|
||||
negativeBoderLine2mm1 = sharedPreferences.getString("negativeBoderLine2mm1", Constants.negativeBoderLine2mm1.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine2mm1
|
||||
negativeBoderLine2mm2 = sharedPreferences.getString("negativeBoderLine2mm2", Constants.negativeBoderLine2mm2.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine2mm2
|
||||
normalMin2mm = sharedPreferences.getString("normalMin2mm", Constants.normalMin2mm.toString())?.toDoubleOrNull() ?: Constants.normalMin2mm
|
||||
normalMax2mm = sharedPreferences.getString("normalMax2mm", Constants.normalMax2mm.toString())?.toDoubleOrNull() ?: Constants.normalMax2mm
|
||||
negativeBorderlineMin2mm = sharedPreferences.getString("negativeBorderlineMin2mm", Constants.negativeBorderlineMin2mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMin2mm
|
||||
negativeBorderlineMax2mm = sharedPreferences.getString("negativeBorderlineMax2mm", Constants.negativeBorderlineMax2mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMax2mm
|
||||
sickleCellTraitMin2mm = sharedPreferences.getString("sickleCellTraitMin2mm", Constants.sickleCellTraitMin2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMin2mm
|
||||
sickleCellTraitMax2mm = sharedPreferences.getString("sickleCellTraitMax2mm", Constants.sickleCellTraitMax2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMax2mm
|
||||
positiveForSickleCellMin2mm = sharedPreferences.getString("positiveForSickleCellMin2mm", Constants.positiveForSickleCellMin2mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMin2mm
|
||||
positiveForSickleCellMax2mm = sharedPreferences.getString("positiveForSickleCellMax2mm", Constants.positiveForSickleCellMax2mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMax2mm
|
||||
sickleCellDiseaseMin2mm = sharedPreferences.getString("sickleCellDiseaseMin2mm", Constants.sickleCellDiseaseMin2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMin2mm
|
||||
sickleCellDiseaseMax2mm = sharedPreferences.getString("sickleCellDiseaseMax2mm", Constants.sickleCellDiseaseMax2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMax2mm
|
||||
cuvetteSizeSP = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
||||
|
||||
testState = TestState(
|
||||
testDetails = DataHolder.selectedTest?.toHemoCubeTestData(),
|
||||
@@ -214,7 +185,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
binding.btnSubmit.visibility = View.GONE
|
||||
}
|
||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),quickCapture
|
||||
)
|
||||
}else{
|
||||
@@ -236,7 +207,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.tvSubtitle4.text = "Config"
|
||||
|
||||
if (isBufferValueAvailable()){
|
||||
hemoCubeViewModel.messages.postValue("Ready to test")
|
||||
trueHemeTestViewModel.messages.postValue("Ready to test")
|
||||
isUsingExistingBuffer = true
|
||||
binding.btnPlaceRefreshbuffer.visibility = View.VISIBLE
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
@@ -247,7 +218,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.btnSamplestart.isClickable = true
|
||||
binding.btnSamplestart.isEnabled = true
|
||||
}else{
|
||||
hemoCubeViewModel.messages.postValue("Fresh Kit - Please take Buffer Blank reading")
|
||||
trueHemeTestViewModel.messages.postValue("Fresh Kit - Please take Buffer Blank reading")
|
||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||
binding.btnPlacebuffer.apply {
|
||||
@@ -331,24 +302,24 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun observeViewModel() {
|
||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||
trueHemeTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||
if (result == "Success") {
|
||||
uploadedToCloud = true
|
||||
var accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||
showToast(R.string.test_upload)
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
uploadedToMolbio = true
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
trueHemeTestViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
)
|
||||
}
|
||||
handleReadingFinish()
|
||||
hemoCubeViewModel.uploadLogs()
|
||||
hemoCubeViewModel.downloadClientCertificate()
|
||||
trueHemeTestViewModel.uploadLogs()
|
||||
trueHemeTestViewModel.downloadClientCertificate()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
@@ -385,13 +356,13 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
}
|
||||
|
||||
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||
trueHemeTestViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||
|
||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
currentDeviceData = it
|
||||
}
|
||||
|
||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
apply {
|
||||
DataHolder.hemoCubeTestData?.let {
|
||||
currentDeviceData?.coefficients?.let { coefficients ->
|
||||
@@ -404,11 +375,11 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.messages.observe(viewLifecycleOwner) {
|
||||
binding.tvSubtitle4.text = it
|
||||
}
|
||||
|
||||
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||
trueHemeTestViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||
binding.tvDeviceMessages.text = it
|
||||
}
|
||||
}
|
||||
@@ -416,7 +387,7 @@ class HemoCubeFragment : Fragment() {
|
||||
private fun handleReadingFinish() {
|
||||
if (allReadingsComplete(repeatReadingCount, readingsPerSample) && uploadedToCloud) {
|
||||
if (validationError) {
|
||||
hemoCubeViewModel.messages.postValue("Error")
|
||||
trueHemeTestViewModel.messages.postValue("Error")
|
||||
return
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
@@ -427,7 +398,7 @@ class HemoCubeFragment : Fragment() {
|
||||
startActivity(i)
|
||||
}
|
||||
} else {
|
||||
hemoCubeViewModel.messages.postValue("Reading $repeatReadingCount completed")
|
||||
trueHemeTestViewModel.messages.postValue("Reading $repeatReadingCount completed")
|
||||
resetTest()
|
||||
startSampleProcess()
|
||||
}
|
||||
@@ -509,13 +480,13 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
private fun listenToHemoCube() {
|
||||
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
val fullReadOutput = StringBuilder()
|
||||
startListening.postValue(true)
|
||||
|
||||
try {
|
||||
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||
(activity as TrueHemeTestActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
@@ -525,7 +496,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
@@ -535,34 +506,34 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun getDeviceInfo() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
hemoCubeViewModel.messages.postValue(stringData)
|
||||
trueHemeTestViewModel.messages.postValue(stringData)
|
||||
binding.tvSubtitle4.text = stringData
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadDACValues() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -574,7 +545,7 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
resultData += stringData
|
||||
currentResultData += stringData
|
||||
hemoCubeViewModel.deviceMessages.postValue(currentResultData)
|
||||
trueHemeTestViewModel.deviceMessages.postValue(currentResultData)
|
||||
Log.e("testStatus",this.testStatusCode.toString())
|
||||
when {
|
||||
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
||||
@@ -589,13 +560,13 @@ class HemoCubeFragment : Fragment() {
|
||||
(resultData.contains("#LS") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code) -> {
|
||||
// air reading 1
|
||||
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code
|
||||
hemoCubeViewModel.messages.postValue("Air reading started")
|
||||
trueHemeTestViewModel.messages.postValue("Air reading started")
|
||||
}
|
||||
|
||||
(resultData.contains("#LC") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code) -> {
|
||||
// air reading 1, send command to print
|
||||
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("Air reading completed")
|
||||
trueHemeTestViewModel.messages.postValue("Air reading completed")
|
||||
fetchResult()
|
||||
}
|
||||
//#EC for v0 and v1 and #RC for v2
|
||||
@@ -621,7 +592,7 @@ class HemoCubeFragment : Fragment() {
|
||||
//hemoCubeViewModel.messages.postValue("Ready to test \n Temperature : $temperature")
|
||||
}
|
||||
resultData.contains("#CIN") && sampleClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTS.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTS.code
|
||||
activity?.runOnUiThread {
|
||||
checkCuvetteSam = true
|
||||
@@ -633,7 +604,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
resultData.contains("#AIN") && sampleClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTS.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTS.code
|
||||
activity?.runOnUiThread {
|
||||
binding.testing.visibility = View.GONE
|
||||
@@ -641,7 +612,7 @@ class HemoCubeFragment : Fragment() {
|
||||
showRetryButtonForCuvette()
|
||||
}
|
||||
resultData.contains("#CIN") && refreshClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTR.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTR.code
|
||||
activity?.runOnUiThread {
|
||||
checkRefreshCuvette = true
|
||||
@@ -655,7 +626,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
resultData.contains("#AIN") && refreshClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTR.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTR.code
|
||||
activity?.runOnUiThread {
|
||||
binding.testing.visibility = View.GONE
|
||||
@@ -665,7 +636,7 @@ class HemoCubeFragment : Fragment() {
|
||||
showRetryButtonForCuvette()
|
||||
}
|
||||
resultData.contains("#CIN") && this.testStatusCode < TestStatus.CUVETTE_PRESENT.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||
this.testStatusCode = TestStatus.CUVETTE_PRESENT.code
|
||||
activity?.runOnUiThread {
|
||||
checkCuvette = true
|
||||
@@ -678,7 +649,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
resultData.contains("#AIN") && this.testStatusCode <= TestStatus.CUVETTE_ABSENT.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||
this.testStatusCode = TestStatus.CUVETTE_ABSENT.code
|
||||
activity?.runOnUiThread {
|
||||
binding.testing.visibility = View.GONE
|
||||
@@ -688,14 +659,14 @@ class HemoCubeFragment : Fragment() {
|
||||
showRetryButtonForCuvette()
|
||||
}
|
||||
resultData.contains("#CIN") && this.submitClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTT.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTT.code
|
||||
activity?.runOnUiThread {
|
||||
binding.testing.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
resultData.contains("#AIN") && this.submitClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTT.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTT.code
|
||||
activity?.runOnUiThread {
|
||||
checkSubmit = true
|
||||
@@ -704,7 +675,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
||||
activity?.runOnUiThread {
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
@@ -738,7 +709,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
resultData.contains("REND") && this.testStatusCode < TestStatus.BUFFER_PRINT_COMPLETED.code -> {
|
||||
resultData = resultData.replace("REND","Buffer print complete"+ generateTwoDigitRandomNumber())
|
||||
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
||||
if(handleBufferCompleted()){
|
||||
this.testStatusCode = TestStatus.TEMPERATURE_CHECK.code
|
||||
activity?.runOnUiThread {
|
||||
@@ -780,7 +751,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.testing.visibility = View.GONE
|
||||
binding.btnSamplestart.visibility = View.GONE
|
||||
}
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
trueHemeTestViewModel.messages.postValue(
|
||||
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
||||
)
|
||||
currentResultData = ""
|
||||
@@ -791,60 +762,60 @@ class HemoCubeFragment : Fragment() {
|
||||
activity?.runOnUiThread {
|
||||
binding.testing.visibility = View.GONE
|
||||
}
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
trueHemeTestViewModel.messages.postValue(
|
||||
getString(R.string.power_bank)
|
||||
)
|
||||
}
|
||||
|
||||
currentResultData.contains("#SS2") && this.testStatusCode < TestStatus.FIRST_GAIN_STARTED.code -> {
|
||||
this.testStatusCode = TestStatus.FIRST_GAIN_STARTED.code
|
||||
hemoCubeViewModel.messages.postValue("1.3X Gain Started")
|
||||
trueHemeTestViewModel.messages.postValue("1.3X Gain Started")
|
||||
}
|
||||
|
||||
currentResultData.contains("#SC2") && this.testStatusCode < TestStatus.FIRST_GAIN_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.FIRST_GAIN_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("1.3X Gain Completed")
|
||||
trueHemeTestViewModel.messages.postValue("1.3X Gain Completed")
|
||||
fetchResult()
|
||||
}
|
||||
|
||||
currentResultData.contains("#SS3") && this.testStatusCode < TestStatus.SECOND_GAIN_STARTED.code -> {
|
||||
this.testStatusCode = TestStatus.SECOND_GAIN_STARTED.code
|
||||
hemoCubeViewModel.messages.postValue("2X Gain Started")
|
||||
trueHemeTestViewModel.messages.postValue("2X Gain Started")
|
||||
}
|
||||
|
||||
currentResultData.contains("#SC3") && this.testStatusCode < TestStatus.SECOND_GAIN_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.SECOND_GAIN_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("2X Gain Completed")
|
||||
trueHemeTestViewModel.messages.postValue("2X Gain Completed")
|
||||
fetchResult()
|
||||
}
|
||||
|
||||
currentResultData.contains("#SS5") && this.testStatusCode < TestStatus.FORTH_GAIN_STARTED.code -> {
|
||||
this.testStatusCode = TestStatus.FORTH_GAIN_STARTED.code
|
||||
hemoCubeViewModel.messages.postValue("7.6X Gain Started")
|
||||
trueHemeTestViewModel.messages.postValue("7.6X Gain Started")
|
||||
}
|
||||
|
||||
currentResultData.contains("#SC5") && this.testStatusCode < TestStatus.FORTH_GAIN_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.FORTH_GAIN_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("7.6X Gain Completed")
|
||||
trueHemeTestViewModel.messages.postValue("7.6X Gain Completed")
|
||||
fetchResult()
|
||||
}
|
||||
|
||||
(resultData.contains("#LS") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code) -> {
|
||||
// air reading 2
|
||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code
|
||||
hemoCubeViewModel.messages.postValue("Air reading started")
|
||||
trueHemeTestViewModel.messages.postValue("Air reading started")
|
||||
}
|
||||
|
||||
(resultData.contains("#LC") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code) -> {
|
||||
// air reading 2, print values
|
||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("Air reading completed")
|
||||
trueHemeTestViewModel.messages.postValue("Air reading completed")
|
||||
fetchResult()
|
||||
}
|
||||
|
||||
resultData.contains("REND") && this.testStatusCode < TestStatus.SAMPLE_PRINT_COMPLETED.code -> {
|
||||
resultData = resultData.replace("REND","Sample print complete"+ generateTwoDigitRandomNumber())
|
||||
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
||||
handleSampleCompleted()
|
||||
}
|
||||
|
||||
@@ -852,7 +823,7 @@ class HemoCubeFragment : Fragment() {
|
||||
&& this.testStatusCode >= TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
||||
&& this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_PRINT_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("First air reading completed")
|
||||
trueHemeTestViewModel.messages.postValue("First air reading completed")
|
||||
|
||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -870,7 +841,7 @@ class HemoCubeFragment : Fragment() {
|
||||
&& this.testStatusCode >= TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
||||
&& this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("Second air reading completed")
|
||||
trueHemeTestViewModel.messages.postValue("Second air reading completed")
|
||||
|
||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -888,7 +859,7 @@ class HemoCubeFragment : Fragment() {
|
||||
&& this.testStatusCode >= TestStatus.FIRST_GAIN_COMPLETED.code
|
||||
&& this.testStatusCode < TestStatus.FIRST_GAIN_PRINT_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("1.3X gain data gathered")
|
||||
trueHemeTestViewModel.messages.postValue("1.3X gain data gathered")
|
||||
|
||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -907,7 +878,7 @@ class HemoCubeFragment : Fragment() {
|
||||
&& this.testStatusCode >= TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||
&& this.testStatusCode < TestStatus.SECOND_GAIN_PRINT_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("2X gain data gathered")
|
||||
trueHemeTestViewModel.messages.postValue("2X gain data gathered")
|
||||
|
||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -926,7 +897,7 @@ class HemoCubeFragment : Fragment() {
|
||||
&& this.testStatusCode >= TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
||||
&& this.testStatusCode < TestStatus.FORTH_GAIN_PRINT_COMPLETED.code -> {
|
||||
this.testStatusCode = TestStatus.FORTH_GAIN_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue("7.6X gain data gathered")
|
||||
trueHemeTestViewModel.messages.postValue("7.6X gain data gathered")
|
||||
|
||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
@@ -952,16 +923,16 @@ class HemoCubeFragment : Fragment() {
|
||||
val lb2Value = lb2Match!!.groupValues[1].toFloat()
|
||||
|
||||
// val led1Min = sharedPreferences.getString("bufferMinLed1", "21000.00")?.toDouble()
|
||||
val led1Min = sharedPreferences.getString("bufferMinLed1", Constants.bufferMinLed1.toString())?.toDoubleOrNull() ?: Constants.bufferMinLed1
|
||||
val led1Max = sharedPreferences.getString("bufferMaxLed1", Constants.bufferMaxLed1.toString())?.toDoubleOrNull() ?: Constants.bufferMaxLed1
|
||||
val led1Min = Constants.bufferMinLed1
|
||||
val led1Max = Constants.bufferMaxLed1
|
||||
|
||||
val led2Min = sharedPreferences.getString("bufferMinLed2", Constants.bufferMinLed2.toString())?.toDoubleOrNull() ?: Constants.bufferMinLed2
|
||||
val led2Max = sharedPreferences.getString("bufferMaxLed2", Constants.bufferMaxLed2.toString())?.toDoubleOrNull() ?: Constants.bufferMaxLed2
|
||||
val led2Min = Constants.bufferMinLed2
|
||||
val led2Max = Constants.bufferMaxLed2
|
||||
|
||||
val isLb1InRange = lb1Value in led1Min..led1Max
|
||||
val isLb2InRange = lb2Value in led2Min..led2Max
|
||||
if(!isLb1InRange || !isLb2InRange){
|
||||
hemoCubeViewModel.messages.postValue("Buffer Reading Out of Range - Please Take Buffer/Blank Reading. If problem persists, Calibrate device")
|
||||
trueHemeTestViewModel.messages.postValue("Buffer Reading Out of Range - Please Take Buffer/Blank Reading. If problem persists, Calibrate device")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -993,7 +964,7 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.ivCheck.visibility = View.VISIBLE
|
||||
}
|
||||
} else {
|
||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),false
|
||||
)
|
||||
}
|
||||
@@ -1002,7 +973,7 @@ class HemoCubeFragment : Fragment() {
|
||||
fun handleSampleCompleted() {
|
||||
|
||||
this.testStatusCode = TestStatus.SAMPLE_PRINT_COMPLETED.code
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
trueHemeTestViewModel.messages.postValue(
|
||||
getString(R.string.data_collected_processing_data)
|
||||
)
|
||||
|
||||
@@ -1047,7 +1018,7 @@ class HemoCubeFragment : Fragment() {
|
||||
if (!hardwareId.isNullOrBlank()) {
|
||||
updateDeviceId(hardwareId)
|
||||
} else {
|
||||
hemoCubeViewModel.messages.postValue("Config error")
|
||||
trueHemeTestViewModel.messages.postValue("Config error")
|
||||
}
|
||||
|
||||
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
||||
@@ -1094,7 +1065,7 @@ class HemoCubeFragment : Fragment() {
|
||||
// }
|
||||
// hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
||||
} else {
|
||||
hemoCubeViewModel.messages.postValue("Config error")
|
||||
trueHemeTestViewModel.messages.postValue("Config error")
|
||||
}
|
||||
|
||||
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
||||
@@ -1144,7 +1115,7 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
private fun processResult() {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
||||
trueHemeTestViewModel.messages.postValue(getString(R.string.processing_result))
|
||||
val deviceLog = resultData
|
||||
|
||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
@@ -1163,7 +1134,7 @@ class HemoCubeFragment : Fragment() {
|
||||
// Toast.makeText(requireContext(),"count: ${DataHolder.sampleReadCounter}",Toast.LENGTH_LONG).show()
|
||||
// }
|
||||
if(led1Average < 0 || led2Average < 0){
|
||||
hemoCubeViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||
trueHemeTestViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||
binding.testing.visibility = View.GONE
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
@@ -1187,7 +1158,7 @@ class HemoCubeFragment : Fragment() {
|
||||
val min10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMLL, Constants.min10mmLed2)
|
||||
val max10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMUL, Constants.max10mmLed2)
|
||||
if(led1Average < 0 || led2Average < 0){
|
||||
hemoCubeViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||
trueHemeTestViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||
binding.testing.visibility = View.GONE
|
||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||
@@ -1197,11 +1168,11 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.btnSamplestart.isEnabled = true
|
||||
return
|
||||
}else{
|
||||
if(cuvetteSize == "10mm"){
|
||||
if(cuvetteSizeSP == "10mm"){
|
||||
inRange10mmLed1 = led1Average in min10mmLed1..max10mmLed1
|
||||
inRange10mmLed2 = led2Average in min10mmLed2..max10mmLed2
|
||||
if(!inRange10mmLed1 || !inRange10mmLed2){
|
||||
hemoCubeViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||
trueHemeTestViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||
binding.testing.visibility = View.GONE
|
||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||
@@ -1211,11 +1182,11 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.btnSamplestart.isEnabled = true
|
||||
return
|
||||
}
|
||||
}else if(cuvetteSize == "2mm"){
|
||||
}else if(cuvetteSizeSP == "2mm"){
|
||||
inRange2mmLed1 = led1Average in min2mmLed1..max2mmLed1
|
||||
inRange2mmLed2 = led2Average in min2mmLed2..max2mmLed2
|
||||
if(!inRange2mmLed1 || !inRange2mmLed2){
|
||||
hemoCubeViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||
trueHemeTestViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||
binding.testing.visibility = View.GONE
|
||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||
@@ -1375,16 +1346,17 @@ class HemoCubeFragment : Fragment() {
|
||||
this.coefficients = currentDeviceData?.coefficients?.get(0)
|
||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||
this.deviceRatioClass = deviceRatioClassification(cuvetteSizeSP,deviceRatio)
|
||||
this.borderlineMethod2Class = reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioBorderlineThresholds(deviceRatio), led2Average)
|
||||
this.slopeRatioClass = slopeClass
|
||||
this.classificationResult = findResultWithAdditionalMethods(
|
||||
cuvetteSizeSP,
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
borderlineMetric
|
||||
)
|
||||
Log.d("HemoCubeFragment",this.classificationResult)
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
trueHemeTestViewModel.messages.postValue(
|
||||
"${this.classificationResult} \n Device Ratio: ${
|
||||
"%.3f".format(
|
||||
this.deviceRatio
|
||||
@@ -1396,17 +1368,17 @@ class HemoCubeFragment : Fragment() {
|
||||
}"
|
||||
)
|
||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||
trueHemeTestViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||
this.errorMessages = testState.allErrorMessages
|
||||
this.resultData = deviceLog
|
||||
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()
|
||||
this.batteryLevel = trueHemeTestViewModel.getBatteryLevel().toString()
|
||||
this.batteryCapacity =
|
||||
hemoCubeViewModel.getBatteryCapacity(requireContext()).toString()
|
||||
trueHemeTestViewModel.getBatteryCapacity(requireContext()).toString()
|
||||
this.batteryMaxCapacity =
|
||||
hemoCubeViewModel.getBatteryMaxCapacity(requireContext()).toString()
|
||||
this.batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString()
|
||||
trueHemeTestViewModel.getBatteryMaxCapacity(requireContext()).toString()
|
||||
this.batteryTemperature = trueHemeTestViewModel.getBatteryTemperature().toString()
|
||||
this.batteryVoltage =
|
||||
hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
||||
trueHemeTestViewModel.getBatteryVoltage(requireContext()).toString()
|
||||
}
|
||||
|
||||
if (!isUsingExistingBuffer) {
|
||||
@@ -1418,6 +1390,7 @@ class HemoCubeFragment : Fragment() {
|
||||
apply()
|
||||
}
|
||||
}
|
||||
trueHemeTestViewModel.updateLocalData()
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
@@ -1459,6 +1432,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
fun findResultWithAdditionalMethods(
|
||||
cuvetteSizeSP: String,
|
||||
deviceRatio: Double?,
|
||||
deviceRatioClass: String?,
|
||||
borderlineMetric: Double?,
|
||||
@@ -1466,26 +1440,26 @@ class HemoCubeFragment : Fragment() {
|
||||
try {
|
||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||
if (deviceRatio != null && borderlineMetric != null) {
|
||||
if(cuvetteSize == "10mm"){
|
||||
if(cuvetteSizeSP == "10mm"){
|
||||
if (deviceRatioClass == "Negative Borderline") {
|
||||
if (borderlineMetric < negativeBoderLine10mm1){//1.34
|
||||
if (borderlineMetric < negativeBoderLine10mm1){//2.0
|
||||
return "Sickle Cell Trait"
|
||||
}else if(borderlineMetric > negativeBoderLine10mm2){
|
||||
}else if(borderlineMetric > negativeBoderLine10mm1){
|
||||
return "Normal"
|
||||
}else if(borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2){
|
||||
return "Negative borderline. Confirm with HPLC"
|
||||
}else if(borderlineMetric == negativeBoderLine10mm1){//borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2
|
||||
return "Sickle Cell Trait"//"Negative borderline. Confirm with HPLC"
|
||||
}
|
||||
}
|
||||
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||
if (borderlineMetric < positiveBoderLine10mm1){//1.34
|
||||
if (borderlineMetric < positiveBoderLine10mm1){//1.3
|
||||
return "Sickle Cell Disease"
|
||||
}else if(borderlineMetric > positiveBoderLine10mm2){
|
||||
}else if(borderlineMetric > positiveBoderLine10mm1){
|
||||
return "Sickle Cell Trait"
|
||||
}else if(borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2){
|
||||
return "Positive for Sickle Cell. Confirm with HPLC"
|
||||
}else if(borderlineMetric == positiveBoderLine10mm1){//borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2
|
||||
return "Sickle Cell Disease"//"Positive for Sickle Cell. Confirm with HPLC"
|
||||
}
|
||||
}
|
||||
}else if(cuvetteSize == "2mm"){
|
||||
}else if(cuvetteSizeSP == "2mm"){
|
||||
if (deviceRatioClass == "Negative Borderline") {
|
||||
if (borderlineMetric < negativeBoderLine2mm1){//1.34
|
||||
return "Sickle Cell Trait"
|
||||
@@ -1539,12 +1513,11 @@ class HemoCubeFragment : Fragment() {
|
||||
return "Invalid"
|
||||
}
|
||||
|
||||
fun deviceRatioClassification(ratio: Double?): String {
|
||||
fun deviceRatioClassification(cuvetteSize : String,ratio: Double?): String {
|
||||
try {
|
||||
if (ratio != null) {
|
||||
if(cuvetteSize == "10mm"){
|
||||
if (ratio in normalMin10mm..normalMax10mm) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in negativeBorderlineMin10mm..negativeBorderlineMax10mm){
|
||||
@@ -1561,7 +1534,6 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}else if(cuvetteSize == "2mm"){
|
||||
if (ratio in normalMin2mm..normalMax2mm) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in negativeBorderlineMin2mm..negativeBorderlineMax2mm){
|
||||
@@ -1602,7 +1574,7 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
fun slopeRatioClassification(ratio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
trueHemeTestViewModel.messages.postValue("result classification")
|
||||
if (ratio != null) {
|
||||
if (ratio in 0.0..30.0)
|
||||
return getString(R.string.normal)
|
||||
@@ -1627,7 +1599,7 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
trueHemeTestViewModel.messages.postValue("result classification")
|
||||
if (predictedDenovixRatio != null) {
|
||||
if (predictedDenovixRatio in 0.0..0.16) {
|
||||
// activity?.runOnUiThread {
|
||||
@@ -1670,118 +1642,118 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.btnRetryCheckCuvette.visibility = View.GONE
|
||||
}
|
||||
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun startBufferProcess() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
// activity?.runOnUiThread {
|
||||
// binding.btnPlacebuffer.visibility = View.GONE
|
||||
// }
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun startSampleProcess() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun sendFirstGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun sendSecondGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun sendThirdGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun sendForthGainCommand() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun getTemp() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun fetchResult() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
trueHemeTestViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
trueHemeTestViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
package com.example.hpostesting.presentation.trueheme_test
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -27,7 +27,6 @@ import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.example.hpostesting.util.CsvWriter
|
||||
import com.example.hpostesting.data.constant.DataHolder
|
||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||
import com.example.hpostesting.util.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||
@@ -50,6 +49,7 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||
import com.example.hpostesting.domain.LogFileManager
|
||||
import com.example.hpostesting.util.NetworkMonitor
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -66,12 +66,13 @@ import javax.inject.Inject
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@HiltViewModel
|
||||
class HemoCubeViewModel @Inject constructor(
|
||||
class TrueHemeTestViewModel @Inject constructor(
|
||||
val hemoCubeDao: HemoCubeDao,
|
||||
private val hemoCubeBufferDao: HemoCubeBufferDao,
|
||||
private val repository: Repository,
|
||||
private val logFileManager: LogFileManager,
|
||||
private val localFileDataSource: LocalFileDataSource,
|
||||
networkMonitor: NetworkMonitor,
|
||||
context: Context,
|
||||
) : ViewModel() {
|
||||
private var testUpload: Boolean = false
|
||||
@@ -87,6 +88,9 @@ class HemoCubeViewModel @Inject constructor(
|
||||
// init {
|
||||
// startPeriodicCheckUpdate()
|
||||
// }
|
||||
init {
|
||||
networkMonitor.startMonitoring()
|
||||
}
|
||||
|
||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||
|
||||
@@ -103,7 +107,7 @@ class HemoCubeViewModel @Inject constructor(
|
||||
|
||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
private val _networkStatusLiveData =networkMonitor.isConnected
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val allLocalData = hemoCubeDao.getAll()
|
||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
||||
@@ -496,7 +500,6 @@ class HemoCubeViewModel @Inject constructor(
|
||||
testDetails?.centerName = sharedPreference.getString(Constants.CENTER_NAME, "").toString()
|
||||
testDetails?.district = sharedPreference.getString(Constants.DISTRICT, "").toString()
|
||||
testDetails?.ipAddress = sharedPreference.getString(Constants.IP_ADDRESS, "").toString()
|
||||
testDetails?.configUpdatedRecent = sharedPreference.getString(Constants.LAST_UPDATED, "NA").toString()
|
||||
}
|
||||
|
||||
private fun addResultTestToDb(quickCapture: Boolean) {
|
||||
@@ -792,4 +795,11 @@ class HemoCubeViewModel @Inject constructor(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
}
|
||||
fun updateLocalData() {
|
||||
viewModelScope.launch {
|
||||
parseData()
|
||||
hemoCubeDao.updateTest(testDetails!!)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||
import io.nats.client.AuthHandler
|
||||
import io.nats.client.Connection
|
||||
import io.nats.client.Message
|
||||
|
||||
117
app/src/main/java/com/example/hpostesting/util/NetworkChecker.kt
Normal file
117
app/src/main/java/com/example/hpostesting/util/NetworkChecker.kt
Normal file
@@ -0,0 +1,117 @@
|
||||
package com.example.hpostesting.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.net.NetworkRequest
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
@Singleton
|
||||
class NetworkMonitor @Inject constructor(
|
||||
@ApplicationContext private val context: Context
|
||||
) {
|
||||
private var isMonitoringStarted = false
|
||||
private val connectivityManager =
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
private val _isConnected = MutableLiveData(false)
|
||||
val isConnected: LiveData<Boolean> get() = _isConnected
|
||||
|
||||
private val networkScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onAvailable(network: Network) {
|
||||
performPingCheck()
|
||||
}
|
||||
|
||||
override fun onLost(network: Network) {
|
||||
_isConnected.postValue(false)
|
||||
}
|
||||
|
||||
override fun onCapabilitiesChanged(
|
||||
network: Network, networkCapabilities: NetworkCapabilities
|
||||
) {
|
||||
// Recheck connectivity when capabilities change (e.g., network becomes validated)
|
||||
performPingCheck()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun startMonitoring() {
|
||||
if (isMonitoringStarted) return // Already started, do nothing.
|
||||
isMonitoringStarted = true
|
||||
// Check initial connectivity status
|
||||
val network = connectivityManager.activeNetwork
|
||||
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
||||
val isInitiallyConnected = capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
|
||||
|
||||
if (isInitiallyConnected) {
|
||||
performPingCheck()
|
||||
} else {
|
||||
_isConnected.postValue(false)
|
||||
}
|
||||
|
||||
val networkRequest =
|
||||
NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
.build()
|
||||
|
||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||
// Start periodic checks:
|
||||
startPeriodicPingCheck()
|
||||
}
|
||||
|
||||
fun stopMonitoring() { // never needed to call
|
||||
try {
|
||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||
} catch (_: IllegalArgumentException) {
|
||||
// Ignore if callback was not registered
|
||||
}
|
||||
networkScope.cancel()
|
||||
}
|
||||
|
||||
private fun performPingCheck() {
|
||||
networkScope.launch {
|
||||
try {
|
||||
val url = URL("https://www.google.com")
|
||||
val connection = url.openConnection() as HttpURLConnection
|
||||
connection.connectTimeout = 2000
|
||||
connection.readTimeout = 2000
|
||||
connection.setRequestProperty("Connection", "close")
|
||||
connection.connect()
|
||||
|
||||
// Consider any 2xx response as successful
|
||||
val isReachable = connection.responseCode in 200..299
|
||||
_isConnected.postValue(isReachable)
|
||||
connection.disconnect()
|
||||
} catch (e: Exception) {
|
||||
_isConnected.postValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startPeriodicPingCheck(intervalMillis: Long = 1 * 60_000L) {
|
||||
networkScope.launch {
|
||||
while (isActive) {
|
||||
performPingCheck()
|
||||
delay(intervalMillis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||
* // Notice: All information contained herein is, and remains
|
||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||
* // if any. The intellectual and technical concepts contained
|
||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||
* // patents in process, and are protected by trade secret or copyright law.
|
||||
* // Dissemination of this information or reproduction of this material
|
||||
* // is strictly forbidden unless prior written permission is obtained
|
||||
* // from ShanMukha Innovations Pvt. Ltd.
|
||||
*/
|
||||
|
||||
package com.example.hpostesting.util
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.net.NetworkCapabilities
|
||||
import android.net.NetworkRequest
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.LiveData
|
||||
|
||||
class NetworkStatusLiveData(context: Context) : LiveData<Boolean>() {
|
||||
|
||||
private val connectivityManager: ConnectivityManager =
|
||||
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
|
||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||
override fun onAvailable(network: Network) {
|
||||
postValue(true)
|
||||
}
|
||||
|
||||
override fun onLost(network: Network) {
|
||||
postValue(false)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onActive() {
|
||||
super.onActive()
|
||||
postValue(isNetworkAvailable())
|
||||
registerNetworkCallback()
|
||||
}
|
||||
|
||||
override fun onInactive() {
|
||||
super.onInactive()
|
||||
unregisterNetworkCallback()
|
||||
}
|
||||
|
||||
private fun registerNetworkCallback() {
|
||||
val networkRequest = NetworkRequest.Builder()
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||
.build()
|
||||
|
||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||
}
|
||||
|
||||
private fun unregisterNetworkCallback() {
|
||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun isNetworkAvailable(): Boolean {
|
||||
val network = connectivityManager.activeNetwork
|
||||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
||||
return networkCapabilities != null &&
|
||||
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||
}
|
||||
}
|
||||
5
app/src/main/res/drawable/baseline_developer_mode_24.xml
Normal file
5
app/src/main/res/drawable/baseline_developer_mode_24.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7,5h10v2h2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1c-1.1,0 -2,0.9 -2,2v4h2L7,5zM15.41,16.59L20,12l-4.59,-4.59L14,8.83 17.17,12 14,15.17l1.41,1.42zM10,15.17L6.83,12 10,8.83 8.59,7.41 4,12l4.59,4.59L10,15.17zM17,19L7,19v-2L5,17v4c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-4h-2v2z"/>
|
||||
|
||||
</vector>
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.hpostesting.presentation.hemocube.DigitalCardFragment">
|
||||
tools:context="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/userCard"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
||||
tools:context="com.example.hpostesting.presentation.main_base.PanelFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_subtitle4"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.hpostesting.presentation.hemocube.HemoCubeFragment">
|
||||
tools:context="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_parent"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context="com.example.hpostesting.presentation.dashboard.ui.LoginFragment">
|
||||
tools:context="com.example.hpostesting.presentation.main_base.ui.LoginFragment">
|
||||
|
||||
|
||||
<ScrollView
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
||||
tools:context="com.example.hpostesting.presentation.main_base.SlideshowFragment">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_parent"
|
||||
android:layout_width="match_parent"
|
||||
@@ -88,24 +88,12 @@
|
||||
app:layout_constraintBottom_toBottomOf="@id/spinnerCuvette"
|
||||
app:layout_constraintStart_toEndOf="@id/spinnerCuvette"
|
||||
app:layout_constraintTop_toTopOf="@id/spinnerCuvette" />
|
||||
<TextView
|
||||
android:id="@+id/last_updated"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="Last"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="17sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_add_size"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="30dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/last_updated"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btn_add_size"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- RadioGroup to select servers -->
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroupServers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Radio Buttons for each server option -->
|
||||
<RadioButton
|
||||
android:id="@+id/radioButtonInternal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Internal" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radioButtonClinical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Clinical" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radioButtonCustomer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Customer" />
|
||||
|
||||
</RadioGroup>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_home"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.HomeFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.HomeFragment"
|
||||
android:label="@string/menu_home"
|
||||
app:popUpToInclusive="true"
|
||||
app:popUpTo="@id/nav_home"
|
||||
@@ -36,23 +36,23 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_profile"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.GalleryFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.PanelFragment"
|
||||
android:label="@string/profile"
|
||||
tools:layout="@layout/fragment_gallery" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_settings"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.SlideshowFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.SlideshowFragment"
|
||||
android:label="@string/action_settings"
|
||||
tools:layout="@layout/fragment_slideshow" />
|
||||
<fragment
|
||||
android:id="@+id/nav_about"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.AboutFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.AboutFragment"
|
||||
android:label="@string/action_about"
|
||||
tools:layout="@layout/fragment_about" />
|
||||
<fragment
|
||||
android:id="@+id/nav_activity"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.ActivitiesFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.ActivitiesFragment"
|
||||
android:label="@string/action_activity"
|
||||
tools:layout="@layout/fragment_activities" />
|
||||
<activity
|
||||
@@ -61,7 +61,7 @@
|
||||
android:label="MainActivity" />
|
||||
<fragment
|
||||
android:id="@+id/loginFragment"
|
||||
android:name="com.example.hpostesting.presentation.dashboard.ui.LoginFragment"
|
||||
android:name="com.example.hpostesting.presentation.main_base.ui.LoginFragment"
|
||||
android:label="@string/login"
|
||||
tools:layout="@layout/fragment_login" >
|
||||
<action
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/hemoCubeFragment"
|
||||
android:name="com.example.hpostesting.presentation.hemocube.HemoCubeFragment"
|
||||
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment"
|
||||
android:label="fragment_hemo_cube_reference"
|
||||
tools:layout="@layout/fragment_hemo_cube_reference" >
|
||||
<action
|
||||
@@ -29,7 +29,7 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/digitalCardFragment"
|
||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardFragment"
|
||||
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment"
|
||||
android:label="fragment_digital_card"
|
||||
tools:layout="@layout/fragment_digital_card" />
|
||||
</navigation>
|
||||
@@ -25,6 +25,7 @@
|
||||
<item>ka</item>
|
||||
<!-- Use language codes (e.g., en, kn) as values -->
|
||||
</string-array>
|
||||
|
||||
<string-array name="district">
|
||||
<item>Mysuru</item>
|
||||
<item>Kodagu</item>
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||
~ // Notice: All information contained herein is, and remains
|
||||
~ // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||
~ // if any. The intellectual and technical concepts contained
|
||||
~ // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||
~ // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||
~ // patents in process, and are protected by trade secret or copyright law.
|
||||
~ // Dissemination of this information or reproduction of this material
|
||||
~ // is strictly forbidden unless prior written permission is obtained
|
||||
~ // from ShanMukha Innovations Pvt. Ltd.
|
||||
-->
|
||||
<defaultsMap>
|
||||
<entry>
|
||||
<key>BUFFER_FLAGS_ENABLED</key>
|
||||
<value>true</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveBoderLine10mm1</key>
|
||||
<value>1.3</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveBoderLine10mm2</key>
|
||||
<value>1.66</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBoderLine10mm1</key>
|
||||
<value>2.0</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBoderLine10mm2</key>
|
||||
<value>2.4</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>normalMin10mm</key>
|
||||
<value>0.1</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>normalMax10mm</key>
|
||||
<value>0.23</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBorderlineMin10mm</key>
|
||||
<value>0.23</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBorderlineMax10mm</key>
|
||||
<value>0.25</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellTraitMin10mm</key>
|
||||
<value>0.25</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellTraitMax10mm</key>
|
||||
<value>0.31</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveForSickleCellMin10mm</key>
|
||||
<value>0.31</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveForSickleCellMax10mm</key>
|
||||
<value>0.43</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellDiseaseMin10mm</key>
|
||||
<value>0.43</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellDiseaseMax10mm</key>
|
||||
<value>0.7</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveBoderLine2mm1</key>
|
||||
<value>0.8</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveBoderLine2mm2</key>
|
||||
<value>1.1</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBoderLine2mm1</key>
|
||||
<value>1.5</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBoderLine2mm2</key>
|
||||
<value>1.9</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>normalMin2mm</key>
|
||||
<value>0.1</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>normalMax2mm</key>
|
||||
<value>0.23</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBorderlineMin2mm</key>
|
||||
<value>0.23</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>negativeBorderlineMax2mm</key>
|
||||
<value>0.25</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellTraitMin2mm</key>
|
||||
<value>0.25</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellTraitMax2mm</key>
|
||||
<value>0.31</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveForSickleCellMin2mm</key>
|
||||
<value>0.31</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>positiveForSickleCellMax2mm</key>
|
||||
<value>0.45</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellDiseaseMin2mm</key>
|
||||
<value>0.45</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>sickleCellDiseaseMax2mm</key>
|
||||
<value>0.7</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>bufferMinLed1</key>
|
||||
<value>21000.00</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>bufferMaxLed1</key>
|
||||
<value>23000.00</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>bufferMinLed2</key>
|
||||
<value>17000.00</value>
|
||||
</entry>
|
||||
<entry>
|
||||
<key>bufferMaxLed2</key>
|
||||
<value>19000.00</value>
|
||||
</entry>
|
||||
</defaultsMap>
|
||||
@@ -16,12 +16,12 @@ package com.example.hpostesting
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.model.Response
|
||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
||||
import com.example.hpostesting.util.NetworkMonitor
|
||||
import io.mockk.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -43,7 +43,7 @@ class AutoDacViewModelTest {
|
||||
private val repository = mockk<Repository>()
|
||||
private val context = mockk<Context>()
|
||||
private val sharedPreferences = mockk<SharedPreferences>()
|
||||
private val networkStatusLiveData = mockk<NetworkStatusLiveData>()
|
||||
private val networkStatusLiveData = mockk<NetworkMonitor>()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
@@ -54,7 +54,7 @@ class AutoDacViewModelTest {
|
||||
every { context.getSystemService(any()) } returns networkStatusLiveData
|
||||
|
||||
// Mocking the NetworkStatusLiveData
|
||||
every { networkStatusLiveData.observe(any(), any()) } just Runs
|
||||
every { networkStatusLiveData.startMonitoring() } just Runs
|
||||
|
||||
every { hemoCubeDao.getAll() } returns mockk()
|
||||
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.example.hpostesting.util.Result
|
||||
import com.example.hpostesting.data.model.login.LoginResponse
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.domain.LogFileManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
||||
import com.example.hpostesting.util.TestCoroutineRule
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
@@ -59,7 +59,7 @@ class HemocubeViewModelTest {
|
||||
@MockK(relaxed = true)
|
||||
lateinit var observer: Observer<Result<LoginResponse>>
|
||||
|
||||
private lateinit var viewModel: HemoCubeViewModel
|
||||
private lateinit var viewModel: TrueHemeTestViewModel
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertNull
|
||||
import org.junit.Before
|
||||
@@ -24,17 +24,17 @@ import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class HemoCubeFragmentTest {
|
||||
class TrueHemeTestFragmentTest {
|
||||
|
||||
@Mock
|
||||
private lateinit var mockSharedPreferences: SharedPreferences
|
||||
|
||||
private lateinit var hemoCubeFragment: HemoCubeFragment
|
||||
private lateinit var trueHemeTestFragment: TrueHemeTestFragment
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
hemoCubeFragment = HemoCubeFragment()
|
||||
trueHemeTestFragment = TrueHemeTestFragment()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ class HemoCubeFragmentTest {
|
||||
).thenReturn("dummy_value")
|
||||
|
||||
// Act
|
||||
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||
val deviceId = trueHemeTestFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||
|
||||
// Assert
|
||||
assertEquals("HPP1-9000", deviceId)
|
||||
@@ -81,11 +81,11 @@ class HemoCubeFragmentTest {
|
||||
val readingsPerSample = 1
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||
val result = trueHemeTestFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||
|
||||
// Assert
|
||||
assertEquals(true, result)
|
||||
assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
||||
assertEquals(trueHemeTestFragment.allReadingsComplete(0, 1), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +94,7 @@ class HemoCubeFragmentTest {
|
||||
val input = "Some text SN ABC123 some more text"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("ABC123", result)
|
||||
@@ -106,7 +106,7 @@ class HemoCubeFragmentTest {
|
||||
val input = "Some text without SN"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertNull(result)
|
||||
@@ -118,7 +118,7 @@ class HemoCubeFragmentTest {
|
||||
val input = ""
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertNull(result)
|
||||
@@ -130,7 +130,7 @@ class HemoCubeFragmentTest {
|
||||
val input: String? = null
|
||||
|
||||
// Act
|
||||
val result = input?.let { hemoCubeFragment.extractV1HardwareId(it) }
|
||||
val result = input?.let { trueHemeTestFragment.extractV1HardwareId(it) }
|
||||
|
||||
// Assert
|
||||
assertNull(result)
|
||||
@@ -158,7 +158,7 @@ class HemoCubeFragmentTest {
|
||||
""".trimIndent()
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HCV-000-3001", result)
|
||||
@@ -170,7 +170,7 @@ class HemoCubeFragmentTest {
|
||||
val input = "SNS ABC123 SNE"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("ABC123", result)
|
||||
@@ -182,7 +182,7 @@ class HemoCubeFragmentTest {
|
||||
val input = "No hardware ID in this input"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertNull(result)
|
||||
@@ -194,7 +194,7 @@ class HemoCubeFragmentTest {
|
||||
val input = "SNS XYZ789 SNE"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("XYZ789", result)
|
||||
@@ -218,7 +218,7 @@ class HemoCubeFragmentTest {
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HCV-000-3013", result)
|
||||
@@ -241,7 +241,7 @@ class HemoCubeFragmentTest {
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HPP1-4001", result)
|
||||
@@ -264,7 +264,7 @@ class HemoCubeFragmentTest {
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HPP1-000-4001", result)
|
||||
@@ -287,7 +287,7 @@ class HemoCubeFragmentTest {
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HPP-000-4001", result)
|
||||
@@ -310,7 +310,7 @@ class HemoCubeFragmentTest {
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
assertEquals("HPP-000-5001", result)
|
||||
@@ -318,111 +318,123 @@ class HemoCubeFragmentTest {
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormalWithStartRange() {
|
||||
val ratio = 0.16
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val ratio = 0.08
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.22
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||
val ratio = 0.235
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Negative Borderline", result)
|
||||
}
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderlineUpperBound() {
|
||||
val ratio = 0.265
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Negative Borderline", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
||||
val ratio = 0.251
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Negative Borderline", result)
|
||||
val ratio = 0.271
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
||||
val ratio = 0.309
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.312
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCellUpperBound() {
|
||||
val ratio = 0.39
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
||||
val ratio = 0.391
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||
val ratio = 0.45
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val ratio = 0.691
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationInvalid() {
|
||||
val ratio: Double? = null
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
||||
assertEquals("Invalid", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.5)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
||||
assertEquals("Negative borderline. Confirm with HPLC", result)
|
||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.2)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||
"10mm",0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.4
|
||||
)
|
||||
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||
"10mm",0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.33
|
||||
)
|
||||
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Normal", 30.0)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||
"10mm",0.5,
|
||||
"Negative Borderline, Repeat Test",
|
||||
70.0
|
||||
)
|
||||
@@ -432,14 +444,14 @@ class HemoCubeFragmentTest {
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Trait", 70.0)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
||||
"10mm",0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.67
|
||||
)
|
||||
@@ -449,7 +461,7 @@ class HemoCubeFragmentTest {
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Disease", 70.0)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@@ -461,7 +473,7 @@ class HemoCubeFragmentTest {
|
||||
val led2Average = 0.2
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
@@ -479,7 +491,7 @@ class HemoCubeFragmentTest {
|
||||
val led2Average = 0.14
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
@@ -497,7 +509,7 @@ class HemoCubeFragmentTest {
|
||||
val led2Average = 0.18
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
@@ -515,7 +527,7 @@ class HemoCubeFragmentTest {
|
||||
val led2Average = 0.195
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
@@ -533,7 +545,7 @@ class HemoCubeFragmentTest {
|
||||
val led2Average = 0.189
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
Reference in New Issue
Block a user