Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f922f585b5 | ||
|
|
1742363f1a | ||
|
|
ba9564d867 | ||
|
|
1aaf2ba485 | ||
|
|
85756a7052 | ||
|
|
0141c2791e | ||
|
|
a52538e72d | ||
|
|
78cc79eef8 | ||
|
|
c9d0c440e3 | ||
|
|
99da2fc094 | ||
|
|
20f408230e | ||
|
|
c8d5d41c81 | ||
|
|
210c9fed5d | ||
|
|
e947d083fb | ||
|
|
b68ec45642 | ||
|
|
1e5afa0a5c | ||
|
|
80ab69c772 | ||
|
|
2e1c932e72 | ||
|
|
6474181664 | ||
|
|
a142717ef2 | ||
|
|
0d72a0f6f1 | ||
|
|
63b51b1526 | ||
|
|
95533aab0d | ||
|
|
f7dc879c75 | ||
|
|
e8b5d12db5 | ||
|
|
626dd380ab | ||
|
|
c8677bc2bb | ||
|
|
70b0b93f57 | ||
|
|
5cdc156f33 | ||
|
|
71d298cd69 | ||
|
|
c48c5a1ae3 | ||
|
|
97cc281752 | ||
|
|
4f6d3fa203 | ||
|
|
bb6f4ee859 | ||
|
|
4272e36385 | ||
|
|
eb1c764551 | ||
|
|
cd593bb67b | ||
|
|
69ebb2f343 | ||
|
|
3ddad93a6a | ||
|
|
f0d71b3167 | ||
|
|
ab810e788b | ||
|
|
1bc8b18669 | ||
|
|
ea21c5d862 | ||
|
|
3bad0720e3 | ||
|
|
b1342580ea | ||
|
|
d4c66e5e1a | ||
|
|
14516cad5f | ||
|
|
a384c3e93a | ||
|
|
8910e2978f | ||
|
|
3bab859d0b | ||
|
|
b036ae8377 | ||
|
|
c91657c529 | ||
|
|
e64aa27f8a | ||
|
|
f2d6916aa6 |
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -4,9 +4,8 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
||||
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/build
|
||||
/release
|
||||
/google-services*
|
||||
/idea
|
||||
@@ -19,8 +19,8 @@ android {
|
||||
applicationId "in.sminnovations.hpostesting.dev"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 114
|
||||
versionName "2.1.114"
|
||||
versionCode 120
|
||||
versionName "2.1.120"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -80,16 +80,16 @@ dependencies {
|
||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||
implementation 'com.google.firebase:firebase-storage-ktx'
|
||||
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
|
||||
implementation 'com.google.android.gms:play-services-auth:20.7.0'
|
||||
implementation 'com.google.android.gms:play-services-auth:21.0.0'
|
||||
implementation 'com.google.android.gms:play-services-location:21.1.0'
|
||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
||||
implementation 'com.google.android.things:androidthings:1.0'
|
||||
implementation 'com.google.firebase:firebase-appdistribution:16.0.0-beta11'
|
||||
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta11")
|
||||
implementation 'com.google.firebase:firebase-appdistribution:16.0.0-beta12'
|
||||
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta12")
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||
implementation 'com.google.android.play:core:1.10.3'
|
||||
implementation 'io.nats:jnats:2.11.2'
|
||||
implementation 'io.nats:jnats:2.11.4'
|
||||
|
||||
|
||||
|
||||
@@ -143,8 +143,8 @@ dependencies {
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||
|
||||
// Navigation Component
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.6"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.6"
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.7"
|
||||
|
||||
//Dagger - Hilt
|
||||
implementation "com.google.dagger:hilt-android:2.46"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
<application
|
||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||
android:largeHeap="true"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
@@ -116,18 +117,15 @@
|
||||
android:name="com.example.hpostesting.presentation.testRight.UsbService"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.example.hpostesting.presentation.SplashActivity"
|
||||
android:exported="true"
|
||||
android:noHistory="true"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<!-- <category android:name="android.intent.category.HOME" />-->
|
||||
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||
<!-- <category android:name="android.intent.category.MONKEY"/>-->
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER_APP" />-->
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@@ -164,7 +162,7 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:stateNotNeeded="true"
|
||||
tools:replace="android:screenOrientation" />
|
||||
|
||||
<!-- ${applicationId}-->
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
|
||||
@@ -5,7 +5,7 @@ object Constants {
|
||||
const val HEMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
|
||||
const val BASE_URL = "www.google.com"
|
||||
|
||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val MOLBIO_INTEGRATION = true
|
||||
@@ -67,6 +67,8 @@ object Constants {
|
||||
val STATICID = listOf(
|
||||
"FACTORY",
|
||||
"ADMIN",
|
||||
"PQUSER",
|
||||
"QCUSER",
|
||||
"VIZ-1000-0004",
|
||||
"VIZ-1000-0005",
|
||||
"VIZ-1000-0006",
|
||||
|
||||
@@ -29,4 +29,8 @@ interface HemoCubeDao {
|
||||
|
||||
@Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id")
|
||||
suspend fun updateCSVFieldById(id: String, newValue: Boolean)
|
||||
|
||||
@Query("SELECT * from hemo_cube_test_table WHERE molbioFlag = :status")
|
||||
suspend fun getPendingUser(status: Boolean): List<HemoCubeTestData>
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.example.hpostesting.data.model.patient.UserData
|
||||
|
||||
@Database(
|
||||
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
||||
version = 26,
|
||||
version = 28,
|
||||
exportSchema = false
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.hpostesting.data.encryption
|
||||
|
||||
import android.security.keystore.KeyGenParameterSpec
|
||||
import android.security.keystore.KeyProperties
|
||||
import android.util.Base64
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.KeyGenerator
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
|
||||
object AESCrypt {
|
||||
private const val ALGORITHM = "AES"
|
||||
private const val KEY = "your_secret_key"
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun encrypt(value: String): String {
|
||||
val keySpec = SecretKeySpec(KEY.toByteArray(), ALGORITHM)
|
||||
val cipher = Cipher.getInstance(ALGORITHM)
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec)
|
||||
val encryptedBytes = cipher.doFinal(value.toByteArray())
|
||||
return Base64.encodeToString(encryptedBytes, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun decrypt(encrypted: String?): String {
|
||||
val keySpec = SecretKeySpec(KEY.toByteArray(), ALGORITHM)
|
||||
val cipher = Cipher.getInstance(ALGORITHM)
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec)
|
||||
val encryptedBytes = Base64.decode(encrypted, Base64.DEFAULT)
|
||||
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
||||
return String(decryptedBytes)
|
||||
}
|
||||
|
||||
//generates a secret key for the encryption functions to use
|
||||
//TODO: Generating keys requires a higher API level. ask someone if this is okay.
|
||||
}
|
||||
@@ -26,4 +26,14 @@ data class DeviceData(
|
||||
var natsToken: String = "",
|
||||
@get:PropertyName("natsTokenExpiry") @set:PropertyName("natsTokenExpiry")
|
||||
var natsTokenExpiry: String = "",
|
||||
@get:PropertyName("deviceUpdateAvailable") @set:PropertyName("deviceUpdateAvailable")
|
||||
var deviceUpdateAvailable: Boolean = false,
|
||||
@get:PropertyName("updatePath") @set:PropertyName("updatePath")
|
||||
var updatePath: String = "",
|
||||
@get:PropertyName("deviceVersion") @set:PropertyName("deviceVersion")
|
||||
var deviceVersion: String = "",
|
||||
@get:PropertyName("globalUpdateDone") @set:PropertyName("globalUpdateDone")
|
||||
var globalUpdateDone: Boolean = false,
|
||||
@get:PropertyName("globalUpdateIgnore") @set:PropertyName("globalUpdateIgnore")
|
||||
var globalUpdateIgnore: Boolean = false,
|
||||
)
|
||||
@@ -78,6 +78,7 @@ data class HemoCubeTestData(
|
||||
var prdClassification: String = "",
|
||||
var deviceRatioClass: String = "",
|
||||
var slopeRatioClass: String = "",
|
||||
var borderlineMethod2Class: String = "",
|
||||
var errorMessages: String = "",
|
||||
var batteryLevel: String = "",
|
||||
var batteryCapacity: String = "",
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.example.hpostesting.di
|
||||
|
||||
import android.content.Context
|
||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||
import com.example.hpostesting.data.dao.UserDao
|
||||
import com.example.hpostesting.domain.SaveRawData
|
||||
import com.example.hpostesting.domain.SaveRawDataTest
|
||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.components.ViewModelComponent
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
|
||||
@Module
|
||||
@InstallIn(ViewModelComponent::class)
|
||||
object ViewModelModule {
|
||||
|
||||
@Provides
|
||||
fun provideTestRightViewModel(
|
||||
saveRawData: SaveRawData,
|
||||
saveRawDataTest: SaveRawDataTest,
|
||||
databaseRepository: DatabaseRepository,
|
||||
userDao: UserDao,
|
||||
context: Context
|
||||
): TestRightViewModel {
|
||||
return TestRightViewModel(saveRawData, saveRawDataTest, databaseRepository, userDao, context)
|
||||
}
|
||||
}
|
||||
@@ -109,20 +109,7 @@ class DatabaseRepository @Inject constructor(
|
||||
}
|
||||
|
||||
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
||||
return try {
|
||||
val userdata =
|
||||
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||
if (userdata.documents.isNotEmpty()) {
|
||||
userdata.documents.forEach {
|
||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||
}
|
||||
}
|
||||
db.collection("testData").add(data).await()
|
||||
Response.Success(data._id)
|
||||
} catch (e: Exception) {
|
||||
Firebase.crashlytics.recordException(e)
|
||||
Response.Error(e)
|
||||
}
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||
@@ -247,4 +234,22 @@ class DatabaseRepository @Inject constructor(
|
||||
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
||||
return try {
|
||||
val userdata =
|
||||
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||
if (userdata.documents.isNotEmpty()) {
|
||||
userdata.documents.forEach {
|
||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||
}
|
||||
}
|
||||
db.collection("testData").add(data).await()
|
||||
Response.Success(data._id)
|
||||
} catch (e: Exception) {
|
||||
Firebase.crashlytics.recordException(e)
|
||||
Response.Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import okhttp3.ResponseBody
|
||||
|
||||
interface Repository {
|
||||
suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String>
|
||||
suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String>
|
||||
|
||||
suspend fun addTestToDatabase(data: UserData?): Response<String>
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.example.hpostesting.domain.LogFileManager
|
||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||
import com.example.hpostesting.domain.SaveRawData
|
||||
import com.example.hpostesting.domain.SaveRawDataTest
|
||||
import com.example.hpostesting.presentation.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.UsbServiceListenerImpl
|
||||
import com.example.hpostesting.util.PropertyProviderImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
@@ -179,4 +181,10 @@ object AppModule {
|
||||
fun provideLocalFileDataSource(): LocalFileDataSource {
|
||||
return LocalFileDataSourceImpl()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
||||
return UsbServiceListenerImpl(context)
|
||||
}
|
||||
}
|
||||
@@ -125,13 +125,8 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
|
||||
if (nc?.status == Connection.Status.CONNECTED) {
|
||||
Log.d("NATSCONNECTION", "NATS is successfully connected.")
|
||||
|
||||
val d = nc?.createDispatcher { msg: Message? ->
|
||||
println("Nats dispatcher $msg")
|
||||
}
|
||||
|
||||
nc?.subscribe("device.hpos.${deviceId}.ping")
|
||||
|
||||
// Log.d(TAG, "Nats subscribed with ping-"+d)
|
||||
nc?.publish(
|
||||
"server.hpos.${deviceId}.ping",
|
||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||
@@ -140,7 +135,10 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
"server.hpos.${deviceId}.health",
|
||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||
)
|
||||
|
||||
val d = nc?.createDispatcher { msg: Message? ->
|
||||
println("Nats dispatcher $msg")
|
||||
Log.d(TAG, "Nats dispatcher--$msg")
|
||||
}
|
||||
d?.subscribe("device.hpos.${deviceId}.ping") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response)
|
||||
@@ -172,10 +170,11 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.${deviceId}.checkupdate") { msg ->
|
||||
d?.subscribe("device.hpos.${deviceId}.checkUpdate") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
println("Message received (up to 100 times) on topic checkupdate: $response")
|
||||
Log.d(TAG, "subscribed msg ${msg} on topic checkupdate")
|
||||
}
|
||||
} else {
|
||||
Log.d("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.example.hpostesting.presentation
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
|
||||
class UsbServiceListenerImpl(private val context: Context): UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
if (data != null) {
|
||||
val receivedData = String(data)
|
||||
logData(receivedData)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
showToast("USB Error: ${e?.message}")
|
||||
}
|
||||
|
||||
private fun showToast(message: String) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun logData(data: String) {
|
||||
Log.d("UsbServiceListener", "Received data from USB: $data")
|
||||
}
|
||||
}
|
||||
@@ -162,8 +162,8 @@ class AssuranceControlsFragment : Fragment() {
|
||||
}
|
||||
DataHolder.hemoCubeTestData!!._id = currentUnixTime.toString() + "SMI"
|
||||
DataHolder.hemoCubeTestData!!.solution = binding.spinnerSolutions.selectedItem.toString()
|
||||
DataHolder.hemoCubeTestData!!.name = binding.spinnerConcentration.selectedItem.toString()
|
||||
"${DataHolder.hemoCubeTestData!!.solution} ${DataHolder.hemoCubeTestData!!.concentration} ${DataHolder.hemoCubeTestData!!.volume}"
|
||||
DataHolder.hemoCubeTestData!!.concentration = binding.spinnerConcentration.selectedItem.toString()
|
||||
DataHolder.hemoCubeTestData!!.name = "${DataHolder.hemoCubeTestData!!.solution} ${DataHolder.hemoCubeTestData!!.concentration} ${DataHolder.hemoCubeTestData!!.volume}"
|
||||
|
||||
DataHolder.selectedTest = UserData()
|
||||
DataHolder.selectedTest?._id = DataHolder.hemoCubeTestData!!._id
|
||||
|
||||
@@ -163,10 +163,10 @@ class AutoDacFragment : Fragment() {
|
||||
val slData = stringData.split(" ")
|
||||
if (slData.size > 1) {
|
||||
val hardwareId = slData[1].trim()
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, hardwareId)
|
||||
apply()
|
||||
}
|
||||
// with(sharedPreferences.edit()) {
|
||||
// putString(Constants.DEVICE_ID, hardwareId)
|
||||
// apply()
|
||||
// }
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
binding.btnSubmit.visibility = View.VISIBLE
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
import android.app.DownloadManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -23,6 +23,7 @@ import androidx.navigation.ui.setupWithNavController
|
||||
import com.example.hpostesting.data.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||
import com.example.hpostesting.presentation.NatsManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.jig.JigActivity
|
||||
@@ -30,11 +31,19 @@ import com.google.android.material.navigation.NavigationView
|
||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.google.firebase.firestore.ktx.firestore
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.BuildConfig
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||
import okhttp3.ResponseBody
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.InputStream
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
interface NatsMessageCallback {
|
||||
fun onMessageReceived(topic: String, message: String)
|
||||
@@ -49,6 +58,7 @@ open interface IDataCollector: NatsMessageCallback {
|
||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
|
||||
val TAG = "DashboardActivity"
|
||||
private var isRegistered = false
|
||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||
private lateinit var binding: ActivityDashboardBinding
|
||||
lateinit var sharedPreferences: SharedPreferences
|
||||
@@ -57,7 +67,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
private var downloadId: Long = 0
|
||||
// TODO: Remove hemocube viewmodel
|
||||
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
||||
|
||||
private lateinit var sharedPreference: SharedPreferences
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
@@ -66,13 +76,14 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
|
||||
override fun onMessageReceived(topic: String, message: String) {
|
||||
// Handle incoming messages from NATS
|
||||
|
||||
Log.d(TAG, "Received message on topic $topic: $message")
|
||||
}
|
||||
|
||||
@SuppressLint("SetWorldReadable")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
setContentView(binding.root)
|
||||
@@ -91,15 +102,22 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
// Handle success
|
||||
val apkUrl = result.data
|
||||
// val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0"
|
||||
initiateUpdate(apkUrl.toString())
|
||||
Log.d("ApI", "APK URL: $apkUrl")
|
||||
// Toast.makeText(
|
||||
// this,
|
||||
// "APK UPLOAD ${result.data}",
|
||||
// Toast.LENGTH_SHORT
|
||||
// ).show()
|
||||
val apk = result.data
|
||||
val file = File(getExternalFilesDir("Updates"), "update.apk")
|
||||
file.setReadable(true, false) // Ensure the file is readable
|
||||
apk.byteStream().use { input ->
|
||||
file.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
Log.d("Responsebodyformat", "Responsebodyformat: ")
|
||||
installApk(file)
|
||||
Log.e("ApI", "APK URL: $apk")
|
||||
Toast.makeText(
|
||||
this,
|
||||
"${result.data}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
@@ -117,6 +135,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||
val navView: NavigationView = binding.navView
|
||||
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
||||
@@ -135,6 +154,8 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
menuInflater.inflate(R.menu.dashboard, menu)
|
||||
@@ -146,52 +167,15 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||
}
|
||||
|
||||
private fun initiateUpdate(responseBody: String) {
|
||||
val apkUrl = responseBody
|
||||
if (!isValidHttpUrl(apkUrl)) {
|
||||
return
|
||||
}
|
||||
|
||||
val request = DownloadManager.Request(Uri.parse(apkUrl))
|
||||
request.setTitle("App Update")
|
||||
request.setDescription("Downloading update...")
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
request.setDestinationInExternalFilesDir(this, "Updates", "update.apk")
|
||||
|
||||
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
downloadId = downloadManager.enqueue(request)
|
||||
|
||||
// Register a BroadcastReceiver to receive the download complete event
|
||||
// val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
||||
// registerReceiver(downloadReceiver, filter)
|
||||
}
|
||||
private fun extractApkUrl(responseBody: ResponseBody): String {
|
||||
return responseBody.string()
|
||||
}
|
||||
private fun isValidHttpUrl(url: String): Boolean {
|
||||
return url.startsWith("http://") || url.startsWith("https://")
|
||||
}
|
||||
private val downloadReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||
if (id == downloadId) {
|
||||
installApk()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun installApk() {
|
||||
val file = File(getExternalFilesDir("Updates"), "update.apk")
|
||||
file.setReadable(true, false) // Ensure the file is readable
|
||||
|
||||
private fun installApk(file: File) {
|
||||
val pInfo = baseContext.packageManager.getPackageInfo(baseContext.packageName, 0)
|
||||
val uri: Uri = FileProvider.getUriForFile(
|
||||
this,
|
||||
"${pInfo}.fileprovider",
|
||||
"${BuildConfig.APPLICATION_ID}.fileprovider",
|
||||
file
|
||||
)
|
||||
|
||||
// Create an intent to install the APK
|
||||
val installIntent = Intent(Intent.ACTION_INSTALL_PACKAGE)
|
||||
installIntent.data = uri
|
||||
installIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
@@ -207,8 +191,14 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if(isRegistered) {
|
||||
try {
|
||||
// unregisterReceiver(downloadReceiver)
|
||||
} catch (e: Exception) {
|
||||
Log.d("HomeFragment", e.toString())
|
||||
}
|
||||
}
|
||||
super.onDestroy()
|
||||
// unregisterReceiver(downloadReceiver)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@@ -258,8 +248,16 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
}
|
||||
|
||||
override fun setResponse(response: String) {
|
||||
|
||||
responses = responses+response+"\n"
|
||||
println(responses)
|
||||
// if (response.contains("checkUpdate")) {
|
||||
// hemocubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||
// }
|
||||
}
|
||||
|
||||
private fun createDeviceUpdateRequestData(): DeviceUpdateRequest {
|
||||
return DeviceUpdateRequest(
|
||||
serial_no = sharedPreference.getString(Constants.DEVICE_ID, "")
|
||||
)
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -93,6 +93,7 @@ class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
setupListener()
|
||||
connectUsb(false)
|
||||
|
||||
}
|
||||
|
||||
private fun setupListener() {
|
||||
|
||||
@@ -15,7 +15,6 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.data.encryption.AESCrypt
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.presentation.UsbServiceListener
|
||||
@@ -24,7 +23,6 @@ import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||
|
||||
|
||||
class DeviceProvisionFragment : Fragment() {
|
||||
private var resultData: String = ""
|
||||
private lateinit var binding: FragmentDeviceProvisionBinding
|
||||
@@ -118,16 +116,16 @@ class DeviceProvisionFragment : Fragment() {
|
||||
password = response.data.data?.credentials?.password.toString(),
|
||||
deviceProvisionResponse = response.data.data.toString(),
|
||||
natsToken = response.data.data?.device?.deviceUser?.natsToken.toString(),
|
||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString()
|
||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString(),
|
||||
globalUpdateIgnore = false,
|
||||
globalUpdateDone = false,
|
||||
deviceUpdateAvailable = false
|
||||
)
|
||||
)
|
||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
||||
Log.e("idpass", response.toString())
|
||||
Log.e("idpass", response.data.data?.credentials?.username.toString())
|
||||
Log.e("idpass", deviceProvisionResponse)
|
||||
|
||||
saveDataToLocalFile(response.data.data?.credentials?.username.toString(), response.data.data?.credentials?.password.toString())
|
||||
|
||||
} else {
|
||||
Toast.makeText(
|
||||
activity,
|
||||
@@ -223,18 +221,4 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//saves username and password to a local file after encrypting it.
|
||||
private fun saveDataToLocalFile( username : String, password : String){
|
||||
val deviceID = sharedPreferences.getString(Constants.DEVICE_ID, "").toString();
|
||||
val encryptedUsername = AESCrypt.encrypt(username)
|
||||
val encryptedPassword = AESCrypt.encrypt(password)
|
||||
val encryptedData = deviceID + "\n" + encryptedUsername + "\n" + encryptedPassword
|
||||
|
||||
val fileOutputStream = requireContext().openFileOutput("credentials.txt", Context.MODE_PRIVATE)
|
||||
fileOutputStream.write(encryptedData.toByteArray())
|
||||
fileOutputStream.close()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -90,8 +92,11 @@ class HemoCubeFragment : Fragment() {
|
||||
observeViewModel()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun initViews() {
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
binding.btnSubmit.isEnabled = false
|
||||
binding.btnSubmit.isClickable = false
|
||||
activity?.runOnUiThread {
|
||||
binding.progressBar.visibility = View.VISIBLE
|
||||
binding.btnSubmit.visibility = View.GONE
|
||||
@@ -106,8 +111,6 @@ class HemoCubeFragment : Fragment() {
|
||||
binding.nameEditText.visibility = View.GONE
|
||||
binding.tvTitle.visibility = View.GONE
|
||||
binding.btnGo.visibility = View.GONE
|
||||
// binding.btnSubmit.isEnabled = false
|
||||
// binding.btnSubmit.isClickable = false
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
|
||||
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
||||
@@ -147,6 +150,7 @@ class HemoCubeFragment : Fragment() {
|
||||
hemoCubeViewModel.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) {
|
||||
@@ -159,6 +163,8 @@ class HemoCubeFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
handleReadingFinish()
|
||||
hemoCubeViewModel.uploadLogs()
|
||||
hemoCubeViewModel.downloadClientCertificate()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
@@ -167,10 +173,11 @@ class HemoCubeFragment : Fragment() {
|
||||
it.exception.let { message ->
|
||||
Toast.makeText(
|
||||
activity,
|
||||
"An error occurred: $message",
|
||||
"$message",
|
||||
Toast.LENGTH_LONG
|
||||
)
|
||||
.show()
|
||||
Log.d("resultuploadfail1", message.toString())
|
||||
}
|
||||
handleReadingFinish()
|
||||
}
|
||||
@@ -585,8 +592,7 @@ class HemoCubeFragment : Fragment() {
|
||||
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
led4Gain4 =
|
||||
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||
}
|
||||
|
||||
finishReading()
|
||||
@@ -764,6 +770,7 @@ class HemoCubeFragment : Fragment() {
|
||||
val led3Average = log10(led3BufferForDevice.div(led3SampleForDevice))
|
||||
val led4Average = log10(led4BufferForDevice.div(led4SampleForDevice))
|
||||
val deviceRatio = led2Average / led1Average
|
||||
val borderlineMetric = (led1Average - led2Average) / deviceRatio
|
||||
|
||||
if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)
|
||||
?.get(0)!!
|
||||
@@ -861,7 +868,7 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
var absorbanceLowerLimit = 0.0
|
||||
val absorbanceLowerLimit = 0.0
|
||||
if (led1Average < absorbanceLowerLimit || led2Average < absorbanceLowerLimit || led3Average < absorbanceLowerLimit || led4Average < absorbanceLowerLimit) {
|
||||
validationError = true
|
||||
activity?.runOnUiThread {
|
||||
@@ -908,8 +915,13 @@ class HemoCubeFragment : Fragment() {
|
||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||
this.borderlineMethod2Class = reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioBorderlineThresholds(deviceRatio), led2Average)
|
||||
this.slopeRatioClass = slopeClass
|
||||
this.classificationResult = deviceRatioClass
|
||||
this.classificationResult = findResultWithAdditionalMethods(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
borderlineMetric
|
||||
)
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
"${this.classificationResult} \n Device Ratio: ${
|
||||
"%.3f".format(
|
||||
@@ -950,17 +962,20 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun findResultWithAdditionalMethods(
|
||||
deviceRatio: Double?,
|
||||
deviceRatioClass: String?,
|
||||
slopeRatio: Double?,
|
||||
): String {
|
||||
fun reclassifyWithBorderlineMethod2(deviceRatio: Double?, deviceRatioClass: String?, led2Average: Double?): String {
|
||||
try {
|
||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||
if (deviceRatio != null) {
|
||||
if (slopeRatio != null) {
|
||||
if (deviceRatioClass == "Normal" && slopeRatio > 45.0)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
if (deviceRatio != null && led2Average != null) {
|
||||
if (deviceRatioClass == "Negative Borderline") {
|
||||
return if (led2Average >= 0.15)
|
||||
"Borderline. Normal"
|
||||
else
|
||||
"Borderline. Sickle Cell Trait"
|
||||
}
|
||||
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||
return if (led2Average >= 0.19)
|
||||
"Borderline. Sickle Cell Trait"
|
||||
else
|
||||
"Borderline. Sickle Cell Disease"
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -970,20 +985,74 @@ class HemoCubeFragment : Fragment() {
|
||||
return deviceRatioClass.toString()
|
||||
}
|
||||
|
||||
fun deviceRatioClassification(ratio: Double?): String {
|
||||
fun findResultWithAdditionalMethods(
|
||||
deviceRatio: Double?,
|
||||
deviceRatioClass: String?,
|
||||
borderlineMetric: Double?,
|
||||
): String {
|
||||
try {
|
||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||
if (deviceRatio != null && borderlineMetric != null) {
|
||||
if (deviceRatioClass == "Negative Borderline") {
|
||||
return if (borderlineMetric >= 2.4)
|
||||
"Borderline. Normal"
|
||||
else
|
||||
"Borderline. Sickle Cell Trait"
|
||||
}
|
||||
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||
return if (borderlineMetric >= 1.34)
|
||||
"Borderline. Sickle Cell Trait"
|
||||
else
|
||||
"Borderline. Sickle Cell Disease"
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
handleException(e)
|
||||
return "Error"
|
||||
}
|
||||
return deviceRatioClass.toString()
|
||||
}
|
||||
|
||||
fun deviceRatioBorderlineThresholds(ratio: Double?): String {
|
||||
try {
|
||||
if (ratio != null) {
|
||||
if (ratio in 0.016..0.22) {
|
||||
val roundedRatio = String.format("%.3f", ratio).toDouble()
|
||||
if (roundedRatio >= 0.11 && roundedRatio < 0.237) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in 0.22..0.24)
|
||||
if (roundedRatio in 0.237..0.242)
|
||||
return "Negative Borderline"
|
||||
if (ratio in 0.24..0.32)
|
||||
if (roundedRatio in 0.242..0.318)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.32..0.37)
|
||||
if (roundedRatio >= 0.318 && roundedRatio < 0.356)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
if (ratio in 0.37..0.56)
|
||||
if (roundedRatio in 0.356..0.7)
|
||||
return "Sickle Cell Disease"
|
||||
} else {
|
||||
return "Invalid"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
handleException(e)
|
||||
return "Error"
|
||||
}
|
||||
return "Invalid"
|
||||
}
|
||||
|
||||
fun deviceRatioClassification(ratio: Double?): String {
|
||||
try {
|
||||
if (ratio != null) {
|
||||
if (ratio in 0.16..0.23) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in 0.23..0.25)
|
||||
return "Negative Borderline"
|
||||
if (ratio in 0.25..0.31)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.31..0.36)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
if (ratio in 0.36..0.7)
|
||||
return "Sickle Cell Disease"
|
||||
} else {
|
||||
return "Invalid"
|
||||
|
||||
@@ -37,6 +37,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.google.gson.GsonBuilder
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
@@ -88,6 +89,8 @@ class HemoCubeViewModel @Inject constructor(
|
||||
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val allLocalData = hemoCubeDao.getAll()
|
||||
val allPendingUserToUpload = MutableLiveData<List<HemoCubeTestData>>()
|
||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
|
||||
@@ -137,7 +140,14 @@ class HemoCubeViewModel @Inject constructor(
|
||||
|
||||
fun uploadResult(molbioV2ResultRequest: MolbioV2ResultRequest) = viewModelScope.launch {
|
||||
resultUpload.postValue(Result.Loading())
|
||||
Log.d("API CALL", "UPLOADED RESULT")
|
||||
repository.uploadResults(molbioV2ResultRequest).let {
|
||||
resultUpload.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun uploadResultfornew(molbioV2ResultRequest: MolbioV2ResultRequest) = viewModelScope.launch {
|
||||
resultUpload.postValue(Result.Loading())
|
||||
repository.uploadResults(molbioV2ResultRequest).let {
|
||||
resultUpload.postValue(it)
|
||||
}
|
||||
@@ -187,6 +197,9 @@ class HemoCubeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
fun uploadPendingUser() = viewModelScope.launch {
|
||||
allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(false))
|
||||
}
|
||||
|
||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||
isOnline: Boolean,
|
||||
@@ -291,6 +304,7 @@ class HemoCubeViewModel @Inject constructor(
|
||||
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||
testDetails?.deviceRatioClass = DataHolder.hemoCubeTestData?.deviceRatioClass.toString()
|
||||
testDetails?.slopeRatioClass = DataHolder.hemoCubeTestData?.slopeRatioClass.toString()
|
||||
testDetails?.borderlineMethod2Class = DataHolder.hemoCubeTestData?.borderlineMethod2Class.toString()
|
||||
testDetails?.errorMessages = DataHolder.hemoCubeTestData?.errorMessages.toString()
|
||||
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
||||
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
||||
@@ -321,20 +335,24 @@ class HemoCubeViewModel @Inject constructor(
|
||||
fireBaseUpload.postValue("Success")
|
||||
testDetails.localFlag = true
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
// Sanitize testDetails before using it in the API call
|
||||
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
||||
|
||||
// Now, use sanitizedTestDetails for the API call
|
||||
uploadResult(
|
||||
MolbioV2ResultRequest(
|
||||
mutableListOf(
|
||||
MolbioV2Result(
|
||||
rawData = testDetails,
|
||||
analysisId = testDetails._id,
|
||||
analysisDate = testDetails.testTime,
|
||||
analysisStatus = testDetails.classificationResult,
|
||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[testDetails.deviceId].toString(),
|
||||
interpretation = testDetails.classificationResult,
|
||||
testId = testDetails._id,
|
||||
testTime = testDetails.testTime,
|
||||
collectionTime = testDetails.testTime,
|
||||
expiryTime = testDetails.testTime,
|
||||
rawData = sanitizedTestDetails,
|
||||
analysisId = sanitizedTestDetails._id,
|
||||
analysisDate = sanitizedTestDetails.testTime,
|
||||
analysisStatus = sanitizedTestDetails.classificationResult,
|
||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[sanitizedTestDetails.deviceId]?.toString(),
|
||||
interpretation = sanitizedTestDetails.classificationResult,
|
||||
testId = sanitizedTestDetails._id,
|
||||
testTime = sanitizedTestDetails.testTime,
|
||||
collectionTime = sanitizedTestDetails.testTime,
|
||||
expiryTime = sanitizedTestDetails.testTime,
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -376,6 +394,19 @@ class HemoCubeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
||||
hemoCubeTestData::class.java.declaredFields.forEach { field ->
|
||||
if (field.type == Double::class.javaObjectType || field.type == Double::class.javaPrimitiveType) {
|
||||
field.isAccessible = true
|
||||
val value = field.get(hemoCubeTestData) as Double?
|
||||
if (value != null && (value.isInfinite() || value.isNaN())) {
|
||||
field.set(hemoCubeTestData, 0.0) // Replace with a suitable default value
|
||||
}
|
||||
}
|
||||
}
|
||||
return hemoCubeTestData
|
||||
}
|
||||
|
||||
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.updateFieldById(id = userId, true)
|
||||
}
|
||||
@@ -408,6 +439,8 @@ class HemoCubeViewModel @Inject constructor(
|
||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||
|
||||
@@ -11,12 +11,14 @@ import android.content.ServiceConnection
|
||||
import android.hardware.usb.UsbDevice
|
||||
import android.hardware.usb.UsbDeviceConnection
|
||||
import android.hardware.usb.UsbManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
@@ -43,6 +45,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
private val TAG = "HemoCube"
|
||||
|
||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
|
||||
synchronized(this) {
|
||||
@@ -82,6 +85,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||
@@ -106,6 +110,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
open fun connectUsb(permissionGranted: Boolean) {
|
||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||
@@ -125,6 +130,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
@SuppressLint("MutableImplicitPendingIntent")
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent
|
||||
@@ -142,15 +148,21 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
registerReceiver(broadcastReceiver, filter, RECEIVER_EXPORTED)
|
||||
}else{
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
}
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
|
||||
fun setupService() {
|
||||
val intent = Intent(this, UsbService::class.java)
|
||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
open fun reconnectDevice() {
|
||||
mService.disconnect()
|
||||
unbindService(connection)
|
||||
|
||||
@@ -33,32 +33,53 @@ class UsbService : Service() {
|
||||
var bus: UsbServiceListener? = null
|
||||
|
||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||
mPort.open(connection)
|
||||
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
isUsbConnected = true
|
||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
||||
try {
|
||||
mPort = driver.ports[0]
|
||||
mPort.open(connection)
|
||||
|
||||
val usbIoManager = SerialInputOutputManager(mPort,
|
||||
object : SerialInputOutputManager.Listener {
|
||||
override fun onNewData(data: ByteArray?) {
|
||||
listener?.onUsbRead(data)
|
||||
}
|
||||
if (mPort.device.vendorId == 6790 && mPort.device.productId == 29987)
|
||||
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
else
|
||||
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
|
||||
override fun onRunError(e: Exception?) {
|
||||
Log.e(TAG, "onRunError() called inside eventDrivenWrite()")
|
||||
listener?.onUsbError(e)
|
||||
}
|
||||
isUsbConnected = true
|
||||
Log.d(TAG, "Usb Connected ${mPort.driver}")
|
||||
|
||||
})
|
||||
usbIoManager.start();
|
||||
val usbIoManager = SerialInputOutputManager(mPort,
|
||||
object : SerialInputOutputManager.Listener {
|
||||
override fun onNewData(data: ByteArray?) {
|
||||
listener?.onUsbRead(data)
|
||||
}
|
||||
|
||||
override fun onRunError(e: Exception?) {
|
||||
Log.e(TAG, "onRunError() called")
|
||||
listener?.onUsbError(e)
|
||||
}
|
||||
})
|
||||
|
||||
usbIoManager.start()
|
||||
} catch (ioException: IOException) {
|
||||
Log.e(TAG, "IOException during USB connection: ${ioException.message}", ioException)
|
||||
listener?.onUsbError(ioException)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Error connecting USB: ${e.message}", e)
|
||||
listener?.onUsbError(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnect() {
|
||||
if (isUsbConnected) {
|
||||
mPort.close()
|
||||
isUsbConnected = false;
|
||||
Log.d(TAG, "My Usb disconnected:: ${mPort.driver}")
|
||||
try {
|
||||
if (isUsbConnected) {
|
||||
mPort.close()
|
||||
isUsbConnected = false
|
||||
Log.d(TAG, "USB Port closed successfully:: ${mPort.driver}")
|
||||
} else {
|
||||
Log.d(TAG, "USB Port is not connected")
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Error closing USB Port: ${e.message}", e)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "An unexpected error occurred: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@
|
||||
android:text="no device message"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="11sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||
|
||||
|
||||
@@ -38,10 +38,20 @@
|
||||
android:visibility="gone"
|
||||
android:padding="24dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnLogout1"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:src="@drawable/baseline_logout_24"
|
||||
app:layout_constraintTop_toTopOf="@+id/internetNotAvailableCL"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title_no_internet"
|
||||
style="@style/title1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="24dp"
|
||||
@@ -125,6 +135,27 @@
|
||||
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label1"
|
||||
style="@style/title1_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/new_kit"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btnNewKitoffline"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/btnNewKitoffline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:backgroundTint="@color/primary"
|
||||
android:contentDescription="@string/new_kit"
|
||||
android:src="@drawable/ic_add"
|
||||
app:elevation="1dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
android:icon="@drawable/baseline_settings_24"
|
||||
android:title="@string/menu_settings" />
|
||||
</group>
|
||||
</menu>
|
||||
</menu>
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||
import junit.framework.TestCase
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertNull
|
||||
import org.junit.Before
|
||||
@@ -17,18 +13,9 @@ import org.mockito.MockitoAnnotations
|
||||
|
||||
class HemoCubeFragmentTest {
|
||||
|
||||
@Mock
|
||||
lateinit var mockContext: Context
|
||||
|
||||
@Mock
|
||||
private lateinit var mockSharedPreferences: SharedPreferences
|
||||
|
||||
@Mock
|
||||
private lateinit var mockActivity: HemocubeActivity // Replace with your actual Activity class
|
||||
|
||||
@Mock
|
||||
private lateinit var mockBinding: FragmentHemoCubeReferenceBinding // Replace with your actual Binding class
|
||||
|
||||
private lateinit var hemoCubeFragment: HemoCubeFragment
|
||||
|
||||
@Before
|
||||
@@ -51,7 +38,7 @@ class HemoCubeFragmentTest {
|
||||
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-9000", deviceId)
|
||||
assertEquals("HPP1-9000", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +58,7 @@ class HemoCubeFragmentTest {
|
||||
)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-0001", deviceId)
|
||||
assertEquals("HPP1-0001", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,8 +71,8 @@ class HemoCubeFragmentTest {
|
||||
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals(true, result)
|
||||
TestCase.assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
||||
assertEquals(true, result)
|
||||
assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -316,6 +303,13 @@ class HemoCubeFragmentTest {
|
||||
assertEquals("HPP-000-5001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormalWithStartRange() {
|
||||
val ratio = 0.16
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.22
|
||||
@@ -331,19 +325,33 @@ class HemoCubeFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.25
|
||||
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
||||
val ratio = 0.251
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
||||
val ratio = 0.309
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.37
|
||||
val ratio = 0.359
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
||||
val ratio = 0.361
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||
val ratio = 0.45
|
||||
@@ -359,44 +367,166 @@ class HemoCubeFragmentTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsNegativeBorderlineRepeatTest() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
||||
assertEquals("Borderline. Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.35
|
||||
)
|
||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.33
|
||||
)
|
||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline, Repeat Test", 70.0)
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
"Negative Borderline, Repeat Test",
|
||||
70.0
|
||||
)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 70.0)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||
0.5,
|
||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||
1.35
|
||||
)
|
||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||
val result =
|
||||
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReclassifyWithBorderlineMethod2_NegativeBorderlineToNormal() {
|
||||
// Arrange
|
||||
val deviceRatio = 0.1
|
||||
val deviceRatioClass = "Negative Borderline"
|
||||
val led2Average = 0.2
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
)
|
||||
|
||||
// Assert
|
||||
assertEquals("Borderline. Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReclassifyWithBorderlineMethod2_NegativeBorderlineToSCT() {
|
||||
// Arrange
|
||||
val deviceRatio = 0.1
|
||||
val deviceRatioClass = "Negative Borderline"
|
||||
val led2Average = 0.14
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
)
|
||||
|
||||
// Assert
|
||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReclassifyWithBorderlineMethod2_PositiveSickleCell() {
|
||||
// Arrange
|
||||
val deviceRatio = 0.2
|
||||
val deviceRatioClass = "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
val led2Average = 0.18
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
)
|
||||
|
||||
// Assert
|
||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReclassifyWithBorderlineMethod2_PositiveSickleCellToSCT() {
|
||||
// Arrange
|
||||
val deviceRatio = 0.2
|
||||
val deviceRatioClass = "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
val led2Average = 0.195
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
)
|
||||
|
||||
// Assert
|
||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReclassifyWithBorderlineMethod2_PositiveSickleCellToSCD() {
|
||||
// Arrange
|
||||
val deviceRatio = 0.2
|
||||
val deviceRatioClass = "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
val led2Average = 0.189
|
||||
|
||||
// Act
|
||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||
deviceRatio,
|
||||
deviceRatioClass,
|
||||
led2Average
|
||||
)
|
||||
|
||||
// Assert
|
||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ buildscript {
|
||||
kotlin_version = '1.8.21'
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.1.1'
|
||||
classpath 'com.google.gms:google-services:4.4.0'
|
||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
||||
classpath 'com.google.gms:google-services:4.4.1'
|
||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.1.0'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Mon Jun 12 17:07:47 IST 2023
|
||||
#Mon Mar 04 17:08:24 IST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
BIN
keystore.jks
Normal file
BIN
keystore.jks
Normal file
Binary file not shown.
Reference in New Issue
Block a user