Compare commits
27 Commits
Test_work_
...
preprod-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c2b4aa9c7 | ||
|
|
ae42c96256 | ||
|
|
d362a7fa86 | ||
|
|
e8b380a4c4 | ||
|
|
4b205185d3 | ||
|
|
00a3124fbf | ||
|
|
0faf4adbd7 | ||
|
|
d1b5ca32bf | ||
|
|
3e690345c2 | ||
|
|
4f7aa74314 | ||
|
|
590abb5c73 | ||
|
|
7fe8202968 | ||
|
|
11d4c99e02 | ||
|
|
2e700601fe | ||
|
|
41798aa37b | ||
|
|
e7600dafec | ||
|
|
d6b3df25f8 | ||
|
|
0d7e8b0cd0 | ||
|
|
3c8570c46b | ||
|
|
96f9d4d6da | ||
|
|
e7505077ce | ||
|
|
41e30cf178 | ||
|
|
a34c095fde | ||
|
|
a3a5c0d6fb | ||
|
|
fb5e6f3b49 | ||
|
|
8a22b44496 | ||
|
|
10d822c5d6 |
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -5,7 +5,6 @@
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="modules">
|
||||
@@ -14,6 +13,7 @@
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -14,13 +14,13 @@ android {
|
||||
compileSdk 34
|
||||
namespace 'in.sminnovations.hpostesting'
|
||||
|
||||
// prod - production, preprod - preproduction, quality - qc,
|
||||
// prod - production, preprod - preproduction, quality - qc
|
||||
defaultConfig {
|
||||
applicationId "in.sminnovations.hpostesting"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 44
|
||||
versionName "2.1.44"
|
||||
versionCode 56
|
||||
versionName "2.1.56"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -60,7 +60,7 @@ dependencies {
|
||||
|
||||
implementation 'androidx.core:core-ktx:1.12.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.10.0'
|
||||
implementation 'com.google.android.material:material:1.11.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.6.2'
|
||||
@@ -82,6 +82,9 @@ dependencies {
|
||||
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta11")
|
||||
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'
|
||||
|
||||
|
||||
|
||||
|
||||
// Testing
|
||||
@@ -97,13 +100,13 @@ dependencies {
|
||||
|
||||
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
|
||||
implementation 'com.opencsv:opencsv:4.6'
|
||||
implementation 'com.opencsv:opencsv:5.5'
|
||||
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
||||
|
||||
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||
|
||||
// CSV read, write
|
||||
implementation 'com.opencsv:opencsv:4.6'
|
||||
implementation 'com.opencsv:opencsv:5.5'
|
||||
|
||||
// Barcode scanner
|
||||
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
||||
@@ -112,17 +115,17 @@ dependencies {
|
||||
implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
|
||||
|
||||
//Room
|
||||
implementation "androidx.room:room-ktx:2.6.0"
|
||||
implementation "androidx.room:room-runtime:2.6.0"
|
||||
kapt ("androidx.room:room-compiler:2.6.0")
|
||||
implementation "androidx.room:room-ktx:2.6.1"
|
||||
implementation "androidx.room:room-runtime:2.6.1"
|
||||
kapt ("androidx.room:room-compiler:2.6.1")
|
||||
|
||||
//image
|
||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||
|
||||
// Navigation Component
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.5"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.5"
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.6"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.6"
|
||||
|
||||
//Dagger - Hilt
|
||||
implementation "com.google.dagger:hilt-android:2.46"
|
||||
@@ -132,5 +135,12 @@ dependencies {
|
||||
// Retrofit + GSON
|
||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.3")
|
||||
|
||||
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||
implementation 'io.nats:jnats:2.11.2'
|
||||
|
||||
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
||||
|
||||
implementation("io.nats:jnats:2.11.2")
|
||||
}
|
||||
1
app/src/main/assets/app.properties
Normal file
1
app/src/main/assets/app.properties
Normal file
@@ -0,0 +1 @@
|
||||
BASE_URL= https://datacollection.micropcr.com/api/
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.example.hpostesting.data
|
||||
|
||||
import android.util.Log
|
||||
import com.example.hpostesting.data.model.Response
|
||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||
import com.example.hpostesting.util.MyUtils
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class FileUploader {
|
||||
|
||||
private val TAG = "FileUploader"
|
||||
val repository = DatabaseRepository()
|
||||
|
||||
suspend fun start() {
|
||||
|
||||
val listOfFiles = repository.getAllFromPendingQueue()
|
||||
|
||||
for (each in listOfFiles){
|
||||
// Checking internet connectivity & mobile as same or not
|
||||
if (MyUtils.isInternetConnected() && each.mobileId == DataHolder.mobileUniqueId) {
|
||||
|
||||
Log.d(TAG, "uploading file ${each.pendingId}")
|
||||
GlobalScope.launch {
|
||||
val response = repository.uploadFileToStorage(each.patientId, each.filePath)
|
||||
|
||||
when (response) {
|
||||
is Response.Success -> {
|
||||
Log.d(TAG, "File Uploaded ${each.pendingId}")
|
||||
repository.removeFromPendingQueue(each.pendingId)
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
Log.d(TAG, response.exception.toString())
|
||||
}
|
||||
}
|
||||
}.join()
|
||||
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
7
app/src/main/java/com/example/hpostesting/data/Result.kt
Normal file
7
app/src/main/java/com/example/hpostesting/data/Result.kt
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.example.hpostesting.data
|
||||
|
||||
sealed class Result<out T : Any> {
|
||||
data class Success<out T : Any>(val data: T) : Result<T>()
|
||||
data class Error(val exception: Exception) : Result<Nothing>()
|
||||
class Loading<T : Any> : Result<T>()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.hpostesting.data.api
|
||||
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||
import com.example.hpostesting.data.model.login.LoginRequest
|
||||
import com.example.hpostesting.data.model.login.LoginResponse
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface MolbioAuthApi {
|
||||
|
||||
@POST("deviceManagement/device/provision")
|
||||
suspend fun deviceProvision(
|
||||
@Body deviceProvisionRequest: DeviceProvisionRequest
|
||||
): DeviceProvisionResponse
|
||||
|
||||
@POST("deviceService/device/login")
|
||||
suspend fun login(
|
||||
@Body loginRequest: LoginRequest
|
||||
): LoginResponse
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.example.hpostesting.data.api
|
||||
|
||||
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||
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 okhttp3.MultipartBody
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.Multipart
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.PUT
|
||||
import retrofit2.http.Part
|
||||
|
||||
interface MolbioResultApi {
|
||||
|
||||
@PUT("deviceService/results/HPOS")
|
||||
suspend fun uploadResults(
|
||||
@Body molbioV2ResultRequest: MolbioV2ResultRequest
|
||||
): MolbioV2ResultResponse
|
||||
|
||||
@POST("deviceService/device/checkUpdate")
|
||||
suspend fun checkUpdate(
|
||||
@Body checkUpdateRequest: CheckUpdateRequest
|
||||
): CheckUpdateResponse
|
||||
|
||||
@POST("deviceService/device/getUpdate")
|
||||
suspend fun deviceUpdate(
|
||||
@Body deviceUpdateRequest: DeviceUpdateRequest
|
||||
): ResponseBody
|
||||
|
||||
@Multipart
|
||||
@POST("deviceService/device/uploadLogs")
|
||||
suspend fun uploadLogs(
|
||||
@Part logFile: MultipartBody.Part
|
||||
): UploadLogsResponse
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.hpostesting.data.api
|
||||
|
||||
interface PropertyProvider {
|
||||
|
||||
fun getProperty(key: String): String
|
||||
}
|
||||
@@ -4,8 +4,22 @@ object Constants {
|
||||
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
||||
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
|
||||
const val BASE_URL = "www.google.com"
|
||||
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val serialNumber = "NKH5555AH"
|
||||
const val deviceTypeName = "HPOS"
|
||||
const val uid = "NKH5555AH"
|
||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||
const val deviceID = "HCV-000-3001"
|
||||
const val devicePassword = "810516d8f4c7"
|
||||
|
||||
const val ACCESS_TOKEN = "accessToken"
|
||||
const val NATS_TOKEN = "natsToken"
|
||||
const val NATS_TOKEN_EXPIRE_DATE = "natsTokenExpireDate"
|
||||
|
||||
const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
||||
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
||||
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
||||
@@ -29,6 +43,8 @@ object Constants {
|
||||
const val DEVICE_VENDOR_ID = 1027
|
||||
const val HOMO_CUBE_ID = 29987
|
||||
const val VENDOR_ID = 6790
|
||||
const val HEMO_CUBE_V2_PRODUCT_ID = 24577
|
||||
const val HEMO_CUBE_V2_VENDOR_ID = 1027
|
||||
|
||||
const val ERROR_NORMAL = 400
|
||||
const val ERROR_CRITICAL = 401
|
||||
@@ -38,6 +54,7 @@ object Constants {
|
||||
const val USER_ID = "usernameId"
|
||||
|
||||
val STATICID = listOf(
|
||||
"ADMIN",
|
||||
"VIZ-1000-0004",
|
||||
"VIZ-1000-0005",
|
||||
"VIZ-1000-0006",
|
||||
@@ -63,6 +80,14 @@ object Constants {
|
||||
"HC-V1-020",
|
||||
"HCV-000-3001",
|
||||
"HCV-000-3002",
|
||||
"HCV-000-3003",
|
||||
"HCV-000-3004",
|
||||
"HCV-000-3005",
|
||||
"HCV-000-3006",
|
||||
"HCV-000-3007",
|
||||
"HCV-000-3008",
|
||||
"HCV-000-3009",
|
||||
"HCV-000-3010"
|
||||
)
|
||||
|
||||
const val password = "SMI@12345"
|
||||
@@ -78,6 +103,19 @@ object Constants {
|
||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||
const val BUFFER_LED_UPPER_BOUND = 24500
|
||||
|
||||
const val TEST_STATUS_CODE_TEST_STARTED = 1.0
|
||||
const val TEST_STATUS_CODE_CONFIG_STARTED = 2.0
|
||||
const val TEST_STATUS_CODE_CONFIG_COMPLETED = 3.0
|
||||
const val TEST_STATUS_CODE_BUFFER_STARTED = 4.0
|
||||
const val TEST_STATUS_CODE_BUFFER_COMPLETED = 5.0
|
||||
const val TEST_STATUS_CODE_BUFFER_PRINT_STARTED = 6.0
|
||||
const val TEST_STATUS_CODE_BUFFER_PRINT_COMPLETED = 7.0
|
||||
const val TEST_STATUS_CODE_SAMPLE_STARTED = 8.0
|
||||
const val TEST_STATUS_CODE_SAMPLE_COMPLETED = 9.0
|
||||
const val TEST_STATUS_CODE_SAMPLE_PRINT_STARTED = 10.0
|
||||
const val TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED = 11.0
|
||||
const val TEST_STATUS_CODE_TEST_COMPLETED = 12.0
|
||||
|
||||
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
||||
"HCV-000-3001" to listOf(
|
||||
listOf(1.313, -0.89), // LED1, 435nm
|
||||
@@ -91,10 +129,59 @@ object Constants {
|
||||
listOf(0.1964, 0.011565), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3003" to listOf(
|
||||
listOf(0.723142, -0.09135), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.1964, 0.011565), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3004" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3005" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3006" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3007" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3008" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3009" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
"HCV-000-3010" to listOf(
|
||||
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||
listOf(1.0, 0.0) // LED4
|
||||
),
|
||||
)
|
||||
|
||||
const val INCUBATION_TIME_MIN = 0
|
||||
const val INCUBATION_TIME_MAX = 1400
|
||||
const val BATTERY_LEVEL_MIN = 0
|
||||
|
||||
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
||||
"HCV-000-3001" to listOf(
|
||||
@@ -108,15 +195,54 @@ object Constants {
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3003" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3004" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3005" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3006" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3007" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3008" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3009" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
),
|
||||
"HCV-000-3010" to listOf(
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
listOf(24500, 26250),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
val COEFFICIENTS: Map<String, List<List<Double>>> = mapOf(
|
||||
"HC-V1-005" to listOf(
|
||||
listOf(1.5,0.0),
|
||||
listOf(0.0,0.0)
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.example.hpostesting.data.constant
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import java.util.Locale
|
||||
|
||||
object LanguageManager {
|
||||
private const val LANGUAGE_PREF_KEY = "language_pref"
|
||||
|
||||
fun setLocale(context: Context, languageCode: String) {
|
||||
val locale = Locale(languageCode)
|
||||
Locale.setDefault(locale)
|
||||
|
||||
val resources = context.resources
|
||||
val configuration = resources.configuration
|
||||
configuration.setLocale(locale)
|
||||
|
||||
context.createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
fun persistLanguagePreference(context: Context, languageCode: String) {
|
||||
val prefs: SharedPreferences = context.getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
||||
prefs.edit().putString(LANGUAGE_PREF_KEY, languageCode).apply()
|
||||
}
|
||||
|
||||
fun getSavedLanguage(context: Context): String {
|
||||
val prefs: SharedPreferences = context.getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
||||
return prefs.getString(LANGUAGE_PREF_KEY, "en") ?: "en"
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,7 @@ interface HemoCubeDao {
|
||||
|
||||
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
||||
suspend fun updateFieldById(id: String, newValue: Boolean)
|
||||
|
||||
@Query("UPDATE hemo_cube_test_table SET molbioFlag = :newValue WHERE _id = :id")
|
||||
suspend fun updateMolbioFlag(id: String, newValue: Boolean)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.google.android.datatransport.runtime.dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 11, exportSchema = false)
|
||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 15, exportSchema = false)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class MyDatabase : RoomDatabase() {
|
||||
abstract fun userDao(): UserDao
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class Credentials(
|
||||
val password: String? = "",
|
||||
val username: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class Device(
|
||||
val assigned: Boolean? = false,
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val deviceType: DeviceType? = DeviceType(),
|
||||
val deviceTypeId: Int? = 0,
|
||||
val deviceUser: DeviceUser? = DeviceUser(),
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val name: String? = "",
|
||||
val serialNumber: String? = "",
|
||||
val uid: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class DeviceProvisionData(
|
||||
val credentials: Credentials? = Credentials(),
|
||||
val device: Device? = Device()
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class DeviceProvisionRequest(
|
||||
val deviceTypeName: String? = "",
|
||||
val email: String? = "",
|
||||
val password: String? = "",
|
||||
val serialNumber: String? = "",
|
||||
val uid: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class DeviceProvisionResponse(
|
||||
@SerializedName("Data")
|
||||
val data: DeviceProvisionData? = DeviceProvisionData(),
|
||||
@SerializedName("Message")
|
||||
val message: String? = "",
|
||||
@SerializedName("Result")
|
||||
val result: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class DeviceType(
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val description: String? = "",
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val name: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.hpostesting.data.model.deviceprovision
|
||||
|
||||
data class DeviceUser(
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val deviceId: Int? = 0,
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val lastLogin: Any? = Any(),
|
||||
val natsToken: String? = "",
|
||||
val natsTokenExpiry: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0,
|
||||
val username: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.hpostesting.data.model.log
|
||||
|
||||
data class UploadLogsData(
|
||||
val filename: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.log
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class UploadLogsResponse(
|
||||
@SerializedName("Data")
|
||||
val data: UploadLogsData? = UploadLogsData(),
|
||||
@SerializedName("Message")
|
||||
val message: String? = "",
|
||||
@SerializedName("Result")
|
||||
val result: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
data class Device(
|
||||
val assigned: Boolean? = false,
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val deviceType: DeviceType? = DeviceType(),
|
||||
val deviceTypeId: Int? = 0,
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val name: String? = "",
|
||||
val serialNumber: String? = "",
|
||||
val uid: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
data class DeviceType(
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val description: String? = "",
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val name: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
data class DeviceUser(
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val device: Device? = Device(),
|
||||
val deviceId: Int? = 0,
|
||||
val enabled: Boolean? = false,
|
||||
val id: Int? = 0,
|
||||
val lastLogin: String? = "",
|
||||
val natsToken: String? = "",
|
||||
val natsTokenExpiry: String? = "",
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0,
|
||||
val username: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
data class LoginData(
|
||||
val accessToken: String? = "",
|
||||
val deviceUser: DeviceUser? = DeviceUser()
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
data class LoginRequest(
|
||||
val lab: String? = "",
|
||||
val latitude: String? = "",
|
||||
val location: String? = "",
|
||||
val longitude: String? = "",
|
||||
val mode: String? = "",
|
||||
val password: String? = "",
|
||||
val serialNumber: String? = "",
|
||||
val username: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.login
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class LoginResponse(
|
||||
@SerializedName("Data")
|
||||
val data: LoginData? = LoginData(),
|
||||
@SerializedName("Message")
|
||||
val message: String? = "",
|
||||
@SerializedName("Result")
|
||||
val result: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.example.hpostesting.data.model.molbioresult
|
||||
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
|
||||
data class MolbioV2Result(
|
||||
val age: Int? = 31,
|
||||
val analysisDate: String? = "",
|
||||
val analysisId: String? = "",
|
||||
val analysisStatus: String? = "",
|
||||
val analysisType: String? = "HPOS",
|
||||
val analysisTypeMethod: String? = "",
|
||||
val bloodGroup: String? = "",
|
||||
val coefficients: List<Int>? = listOf(22, 22),
|
||||
val collectionLocation: List<Any>? = listOf(),
|
||||
val collectionTime: String? = "",
|
||||
val collector: String? = "",
|
||||
val curveFitting: String? = "Linear",
|
||||
val deviceName: String? = "HPOS",
|
||||
val expiryTime: String? = "",
|
||||
val gender: String? = "",
|
||||
val interpretation: String? = "",
|
||||
val `operator`: String? = "",
|
||||
val patientId: Int? = 4545,
|
||||
val pregnancy: Boolean? = false,
|
||||
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
||||
val recommendation: String? = "NA",
|
||||
val sampleId: String? = "",
|
||||
val sampleType: String? = "",
|
||||
val sickleCellHistory: Boolean? = false,
|
||||
val testId: String? = "",
|
||||
val testResult: String? = "",
|
||||
val testStatus: String? = "",
|
||||
val testTime: String? = "",
|
||||
val testType: String? = "",
|
||||
val thresholds: String? = "",
|
||||
val underMedication: Boolean? = false,
|
||||
val volume: Int? = 2
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.example.hpostesting.data.model.molbioresult
|
||||
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
|
||||
data class MolbioV2ResultData(
|
||||
val age: Int? = 0,
|
||||
val analysisDate: String? = "",
|
||||
val analysisStatus: String? = "",
|
||||
val analysisType: String? = "",
|
||||
val analysisTypeMethod: String? = "",
|
||||
val bloodGroup: String? = "",
|
||||
val coefficients: List<Int>? = listOf(),
|
||||
val collectionLocation: List<Any>? = listOf(),
|
||||
val collectionTime: String? = "",
|
||||
val collector: String? = "",
|
||||
val createdAt: String? = "",
|
||||
val createdBy: Int? = 0,
|
||||
val curveFitting: String? = "",
|
||||
val deviceId: Int? = 0,
|
||||
val expiryTime: String? = "",
|
||||
val gender: String? = "",
|
||||
val id: Int? = 0,
|
||||
val interpretation: String? = "",
|
||||
val `operator`: String? = "",
|
||||
val patientId: Int? = 0,
|
||||
val pregnancy: Boolean? = false,
|
||||
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
||||
val recommendation: String? = "",
|
||||
val sampleId: String? = "",
|
||||
val sampleType: String? = "",
|
||||
val sickleCellHistory: Boolean? = false,
|
||||
val testId: String? = "",
|
||||
val testResult: String? = "",
|
||||
val testStatus: String? = "",
|
||||
val testTime: String? = "",
|
||||
val testType: String? = "",
|
||||
val thresholds: String? = "",
|
||||
val underMedication: Boolean? = false,
|
||||
val updatedAt: String? = "",
|
||||
val updatedBy: Int? = 0,
|
||||
val volume: Int? = 0
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.hpostesting.data.model.molbioresult
|
||||
|
||||
data class MolbioV2ResultRequest(
|
||||
val results: List<MolbioV2Result>? = listOf()
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.molbioresult
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class MolbioV2ResultResponse(
|
||||
@SerializedName("Data")
|
||||
val data: List<MolbioV2ResultData>? = listOf(),
|
||||
@SerializedName("Message")
|
||||
val message: String? = "",
|
||||
@SerializedName("Result")
|
||||
val result: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.example.hpostesting.data.model.molbioresult
|
||||
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
|
||||
data class RawData(
|
||||
var _id: String = "",
|
||||
var name: String = "",
|
||||
var incubationTime: String = "",
|
||||
var bloodGroup: String = "",
|
||||
var birthYear: String = "",
|
||||
var state: String = "",
|
||||
var abhaId: String = "",
|
||||
var userImageURL: String = "",
|
||||
var location: UserData.Location? = null,
|
||||
var reportUploadTime: String? = "",
|
||||
var testType: String? = "HEMOCUBE",
|
||||
var testTime: String? = "",
|
||||
var testStatus: Boolean? = false,
|
||||
var gender: String = "",
|
||||
var localFlag: Boolean = false,
|
||||
var deviceId: String? = "",
|
||||
var appVersion:String? = "",
|
||||
var deviceSerialNumber: String = "",
|
||||
var deviceType: String = "HEMOCUBE",
|
||||
var kitSerial: String = "",
|
||||
var resultData: String = "",
|
||||
var led1Buffer: Double? = null,
|
||||
var led2Buffer: Double? = null,
|
||||
var led3Buffer: Double? = null,
|
||||
var led4Buffer: Double? = null,
|
||||
var led1Sample: Double? = null,
|
||||
var led2Sample: Double? = null,
|
||||
var led3Sample: Double? = null,
|
||||
var led4Sample: Double? = null,
|
||||
var led1Average: Double? = null,
|
||||
var led2Average: Double? = null,
|
||||
var led3Average: Double? = null,
|
||||
var led4Average: Double? = null,
|
||||
var abs1: Double? = null,
|
||||
var abs2: Double? = null,
|
||||
var abs3: Double? = null,
|
||||
var abs4: Double? = null,
|
||||
var deviceRatio: Double? = null,
|
||||
var calculatedRatio: Double? = null,
|
||||
var predictedDenovixRatio: Double? = null,
|
||||
var coefficients: String? = "",
|
||||
var classificationResult: String = "",
|
||||
var prdClassification: String = "",
|
||||
var errorMessages: String = "",
|
||||
var batteryLevel: String = "",
|
||||
var batteryCapacity: String = "",
|
||||
var batteryMaxCapacity: String = "",
|
||||
var batteryTemperature: String = "",
|
||||
var batteryVoltage: String = "",
|
||||
)
|
||||
@@ -55,4 +55,5 @@ data class HemoCubeTestData(
|
||||
var batteryMaxCapacity: String = "",
|
||||
var batteryTemperature: String = "",
|
||||
var batteryVoltage: String = "",
|
||||
var molbioFlag: Boolean = false
|
||||
)
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.example.hpostesting.data.model.test
|
||||
|
||||
import com.example.hpostesting.data.model.Location
|
||||
import java.util.Date
|
||||
|
||||
data class TestDetails(
|
||||
val testID: String,
|
||||
var testStatus: Status,
|
||||
val patientID: String,
|
||||
val patientName: String,
|
||||
val patientAge: Int?,
|
||||
|
||||
var resultRatio: Double?,
|
||||
var result: TestRightResultType?,
|
||||
|
||||
val reportPath: String?,
|
||||
val csvPath: String?,
|
||||
val logPath: String?,
|
||||
|
||||
// Meta Data
|
||||
var deviceId: String?,
|
||||
val mobileId: String,
|
||||
var kitSerial: String?,
|
||||
val location: Location?,
|
||||
val appVersion: String,
|
||||
|
||||
val registeredTime: Date?,
|
||||
var uploadTime: Date?
|
||||
) {
|
||||
constructor() : this(
|
||||
"",
|
||||
Status.PENDING,
|
||||
"",
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
enum class Status {
|
||||
COMPLETED,
|
||||
PENDING,
|
||||
INPROGRESS
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.hpostesting.data.model.test
|
||||
|
||||
data class TestInfo(
|
||||
val value: String,
|
||||
val number1: String,
|
||||
val number2: String,
|
||||
val result: String,
|
||||
val resultConfirmatory: String,
|
||||
val directoryPath: String,
|
||||
val fullPath: String
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.hpostesting.data.model.updates
|
||||
|
||||
data class CheckUpdateData(
|
||||
val version: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.hpostesting.data.model.updates
|
||||
|
||||
data class CheckUpdateRequest(
|
||||
val currentVersion: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.hpostesting.data.model.updates
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class CheckUpdateResponse(
|
||||
@SerializedName("Data")
|
||||
val data: CheckUpdateData? = CheckUpdateData(),
|
||||
@SerializedName("Message")
|
||||
val message: String? = "",
|
||||
@SerializedName("Result")
|
||||
val result: String? = ""
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.hpostesting.data.model.updates
|
||||
|
||||
data class DeviceUpdateRequest(
|
||||
val serial_no: String? = ""
|
||||
)
|
||||
@@ -1,37 +1,97 @@
|
||||
package com.example.hpostesting.data.repository
|
||||
|
||||
import android.net.Uri
|
||||
import com.example.hpostesting.data.Result
|
||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||
import com.example.hpostesting.data.api.MolbioResultApi
|
||||
import com.example.hpostesting.data.model.PendingUploads
|
||||
import com.example.hpostesting.data.model.Response
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||
import com.example.hpostesting.data.model.login.LoginRequest
|
||||
import com.example.hpostesting.data.model.login.LoginResponse
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
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.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
import com.google.firebase.firestore.ktx.firestore
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.google.firebase.storage.ktx.storage
|
||||
import kotlinx.coroutines.tasks.await
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.ResponseBody
|
||||
import java.io.File
|
||||
import java.net.ConnectException
|
||||
import java.net.SocketTimeoutException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class DatabaseRepository @Inject constructor() : Repository {
|
||||
class NetworkException(message: String, cause: Throwable) : Exception(message, cause)
|
||||
class DatabaseRepository @Inject constructor(
|
||||
@Named("Auth")private val molbioAuthApi: MolbioAuthApi,
|
||||
private val molbioResultApi: MolbioResultApi
|
||||
) : Repository {
|
||||
|
||||
private val db: FirebaseFirestore = Firebase.firestore
|
||||
private val storage = Firebase.storage
|
||||
|
||||
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
||||
return try {
|
||||
val response = apiCall.invoke()
|
||||
Result.Success(response)
|
||||
} catch (e: SocketTimeoutException) {
|
||||
Result.Error(NetworkException("Network timeout", e))
|
||||
} catch (e: ConnectException) {
|
||||
Result.Error(NetworkException("Network connection failed", e))
|
||||
} catch (e: Exception) {
|
||||
Result.Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest): Result<DeviceProvisionResponse> {
|
||||
return safeApiCall { molbioAuthApi.deviceProvision(deviceProvisionRequest) }
|
||||
}
|
||||
|
||||
suspend fun login(loginRequest: LoginRequest): Result<LoginResponse> {
|
||||
return safeApiCall { molbioAuthApi.login(loginRequest) }
|
||||
}
|
||||
|
||||
suspend fun uploadResults(molbioV2ResultRequest: MolbioV2ResultRequest): Result<MolbioV2ResultResponse> {
|
||||
return safeApiCall { molbioResultApi.uploadResults(molbioV2ResultRequest) }
|
||||
}
|
||||
|
||||
suspend fun checkUpdate(checkUpdateRequest: CheckUpdateRequest): Result<CheckUpdateResponse> {
|
||||
return safeApiCall { molbioResultApi.checkUpdate(checkUpdateRequest) }
|
||||
}
|
||||
|
||||
suspend fun deviceUpdate(deviceUpdateRequest: DeviceUpdateRequest): Result<ResponseBody> {
|
||||
return safeApiCall { molbioResultApi.deviceUpdate(deviceUpdateRequest) }
|
||||
}
|
||||
|
||||
suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse> {
|
||||
return safeApiCall { molbioResultApi.uploadLogs(logFile) }
|
||||
}
|
||||
|
||||
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||
return try {
|
||||
val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||
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)
|
||||
db.collection("testData").add(data).await()
|
||||
Response.Success(data._id)
|
||||
} catch (e: Exception) {
|
||||
Response.Error(e)
|
||||
}
|
||||
@@ -39,14 +99,15 @@ class DatabaseRepository @Inject constructor() : Repository {
|
||||
|
||||
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
||||
return try {
|
||||
val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||
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)
|
||||
db.collection("testData").add(data).await()
|
||||
Response.Success(data._id)
|
||||
} catch (e: Exception) {
|
||||
Firebase.crashlytics.recordException(e)
|
||||
Response.Error(e)
|
||||
@@ -56,7 +117,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||
return try {
|
||||
db.collection("buffers").add(data!!).await()
|
||||
Response.Success(data!!.kitno)
|
||||
Response.Success(data.kitno)
|
||||
} catch (e: Exception) {
|
||||
Firebase.crashlytics.recordException(e)
|
||||
Response.Error(e)
|
||||
@@ -66,14 +127,16 @@ class DatabaseRepository @Inject constructor() : Repository {
|
||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||
return try {
|
||||
db.collection("diagnostics").add(data!!).await()
|
||||
Response.Success(data!!.deviceId)
|
||||
Response.Success(data.deviceId)
|
||||
} catch (e: Exception) {
|
||||
Firebase.crashlytics.recordException(e)
|
||||
Response.Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> {
|
||||
override suspend fun uploadFileToStorage(
|
||||
patientID: String, filePath: String
|
||||
): Response<Boolean> {
|
||||
try {
|
||||
|
||||
val file = Uri.fromFile(File(filePath))
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.hpostesting.domain
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
|
||||
class AuthInterceptor(private val sharedPreferences: SharedPreferences) : Interceptor {
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
var request = chain.request()
|
||||
|
||||
val token = sharedPreferences.getString(Constants.ACCESS_TOKEN, null)
|
||||
|
||||
if (token != null) {
|
||||
request = request.newBuilder()
|
||||
.addHeader("Authorization", "Bearer $token")
|
||||
.build()
|
||||
}
|
||||
|
||||
return chain.proceed(request)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.hpostesting.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class CheckUpdateWorker(
|
||||
context: Context,
|
||||
workerParams: WorkerParameters
|
||||
) : CoroutineWorker(context, workerParams) {
|
||||
|
||||
override suspend fun doWork(): Result = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
for (i in 1..900){
|
||||
delay(1000)
|
||||
Log.d("Work for every second", "doWork: Running")
|
||||
}
|
||||
|
||||
Result.success()
|
||||
} catch (e: Exception) {
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.example.hpostesting.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
|
||||
class LogFileManager(private val context: Context) {
|
||||
|
||||
fun createLogFile(): File? {
|
||||
val unixTime = System.currentTimeMillis() / 1000L
|
||||
val logFileName = "hpos_$unixTime.log"
|
||||
|
||||
return try {
|
||||
val process = Runtime.getRuntime().exec("logcat -d -v threadtime")
|
||||
val logBuilder = StringBuilder()
|
||||
val input = process.inputStream
|
||||
val bufferedReader = input.bufferedReader()
|
||||
|
||||
bufferedReader.forEachLine { line ->
|
||||
logBuilder.append(line).append("\n")
|
||||
}
|
||||
|
||||
val logContent = logBuilder.toString()
|
||||
|
||||
val file = File(context.filesDir, logFileName)
|
||||
val fileOutputStream = FileOutputStream(file)
|
||||
fileOutputStream.write(logContent.toByteArray())
|
||||
fileOutputStream.close()
|
||||
|
||||
file
|
||||
} catch (e: IOException) {
|
||||
Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,12 @@ package com.example.hpostesting.domain.di
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.AssetManager
|
||||
import androidx.room.Room
|
||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||
import com.example.hpostesting.data.api.MolbioResultApi
|
||||
import com.example.hpostesting.data.api.PropertyProvider
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.dao.MyDatabase
|
||||
import com.example.hpostesting.data.dao.UserDao
|
||||
@@ -10,13 +15,21 @@ import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||
import com.example.hpostesting.data.repository.LocalFileRepository
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.domain.AuthInterceptor
|
||||
import com.example.hpostesting.domain.LogFileManager
|
||||
import com.example.hpostesting.domain.SaveRawData
|
||||
import com.example.hpostesting.domain.SaveRawDataTest
|
||||
import com.example.hpostesting.util.PropertyProviderImpl
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import okhttp3.OkHttpClient
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Named
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@@ -28,9 +41,7 @@ object AppModule {
|
||||
fun provideMyDatabase(@ApplicationContext context: Context): MyDatabase {
|
||||
return Room.databaseBuilder(
|
||||
context, MyDatabase::class.java, "my_database"
|
||||
)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
).fallbackToDestructiveMigration().build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -67,13 +78,89 @@ object AppModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideDatabaseRepository(): DatabaseRepository {
|
||||
return DatabaseRepository()
|
||||
fun provideDatabaseRepository(
|
||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||
molbioResultApi: MolbioResultApi
|
||||
): DatabaseRepository {
|
||||
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideRepository(): Repository {
|
||||
return DatabaseRepository()
|
||||
fun provideRepository(
|
||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||
molbioResultApi: MolbioResultApi
|
||||
): Repository {
|
||||
return DatabaseRepository(molbioAuthApi, molbioResultApi)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAssetManager(@ApplicationContext context: Context): AssetManager {
|
||||
return context.assets
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providePropertyProvider(assetManager: AssetManager): PropertyProvider {
|
||||
return PropertyProviderImpl(assetManager)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences {
|
||||
return context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAuthInterceptor(sharedPreferences: SharedPreferences): AuthInterceptor {
|
||||
return AuthInterceptor(sharedPreferences)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("Auth")
|
||||
fun provideAuthOkHttpClient(authInterceptor: AuthInterceptor): OkHttpClient {
|
||||
return OkHttpClient.Builder().addInterceptor(authInterceptor)
|
||||
.connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideOkHttpClient(): OkHttpClient =
|
||||
OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS).build()
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideRetrofit(
|
||||
propertyProvider: PropertyProvider,@Named("Auth") client: OkHttpClient
|
||||
): Retrofit {
|
||||
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
||||
.addConverterFactory(GsonConverterFactory.create()).build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("Auth")
|
||||
fun provideAuthRetrofit(propertyProvider: PropertyProvider, client: OkHttpClient): Retrofit {
|
||||
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
||||
.addConverterFactory(GsonConverterFactory.create()).build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("Auth")
|
||||
fun provideAuthApi(@Named("Auth") retrofit: Retrofit): MolbioAuthApi =
|
||||
retrofit.create(MolbioAuthApi::class.java)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideResultApi(retrofit: Retrofit): MolbioResultApi =
|
||||
retrofit.create(MolbioResultApi::class.java)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideLogFileManager(context: Context): LogFileManager = LogFileManager(context)
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
|
||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||
@@ -44,6 +45,12 @@ class KitScanActivity : AppCompatActivity() {
|
||||
binding.nameEditText.setText(contents)
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
import com.example.hpostesting.data.model.test.TestType
|
||||
import com.google.android.gms.location.*
|
||||
@@ -44,6 +45,12 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
@@ -97,6 +104,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val deviceType = when {
|
||||
availableDrivers.isNotEmpty() -> {
|
||||
val device = availableDrivers[0].device
|
||||
Toast.makeText(this, R.string.device, Toast.LENGTH_SHORT).show()
|
||||
when {
|
||||
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||
binding.cvItem1.visibility = View.VISIBLE
|
||||
@@ -107,6 +115,15 @@ class MainActivity : AppCompatActivity() {
|
||||
Constants.DEVICE_TYPE_HOMOCUBE
|
||||
}
|
||||
|
||||
device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID -> {
|
||||
binding.cvItem1.visibility = View.VISIBLE
|
||||
binding.cvItem3.visibility = View.VISIBLE
|
||||
binding.cvItem2.visibility = View.GONE
|
||||
binding.cvItem4.visibility = View.GONE
|
||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HOMOCUBE)
|
||||
Constants.DEVICE_TYPE_HOMOCUBE
|
||||
}
|
||||
|
||||
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
||||
Log.d(
|
||||
TAG,
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.example.hpostesting.presentation
|
||||
|
||||
import android.util.Log
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import io.nats.client.AuthHandler
|
||||
import io.nats.client.Connection
|
||||
import io.nats.client.Message
|
||||
import io.nats.client.NKey
|
||||
import io.nats.client.Nats
|
||||
import io.nats.client.Options
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.security.GeneralSecurityException
|
||||
|
||||
|
||||
class NatsManager(datacollector: DashboardActivity) {
|
||||
|
||||
val TAG = "Nats Service"
|
||||
var nc: Connection? = null
|
||||
val datacollector = datacollector
|
||||
var connect = false
|
||||
|
||||
fun connect() {
|
||||
Log.d(TAG, "TRY TO CONNECT")
|
||||
Thread {
|
||||
|
||||
val seedString = "SUAK5IDCMHY4T2WA2LHNXGICGHKR3TPJFNSP6AUQP523RLANO4PSR6IEYA"
|
||||
val seedBytes = seedString.toCharArray()
|
||||
|
||||
val theNKey = NKey.fromSeed(seedBytes) // really should load from somewhere
|
||||
|
||||
val options = Options.Builder()
|
||||
.server("nats://192.168.10.117:4222")
|
||||
.authHandler(object : AuthHandler {
|
||||
override fun getID(): CharArray? {
|
||||
return try {
|
||||
theNKey?.publicKey
|
||||
} catch (ex: GeneralSecurityException) {
|
||||
null
|
||||
} catch (ex: IOException) {
|
||||
null
|
||||
} catch (ex: NullPointerException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun sign(nonce: ByteArray): ByteArray? {
|
||||
return try {
|
||||
theNKey?.sign(nonce)
|
||||
} catch (ex: GeneralSecurityException) {
|
||||
null
|
||||
} catch (ex: IOException) {
|
||||
null
|
||||
} catch (ex: NullPointerException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun getJWT(): CharArray? {
|
||||
return null
|
||||
}
|
||||
})
|
||||
.build()
|
||||
|
||||
try {
|
||||
nc = Nats.connect(options)
|
||||
Log.d(TAG, "Connected to Nats server ${options.servers.first()}")
|
||||
connect = true
|
||||
datacollector.setConnect(true)
|
||||
|
||||
|
||||
nc?.publish(
|
||||
"server.hpos.HCV-000-3001.ping",
|
||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||
)
|
||||
nc?.publish(
|
||||
"server.hpos.HCV-000-3001.health",
|
||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||
)
|
||||
Log.d(TAG, "Published msg server.hpos.HCV-000-3001.ping on topic Testing")
|
||||
val d = nc?.createDispatcher { msg: Message? ->
|
||||
println("PRITIMOI SARKAR $msg")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.update") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector. setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.uploadlogs") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response + "uPLOAD")
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.disable") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.updatecustomer") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.checkupdate") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector.setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
} catch (exp: Exception) {
|
||||
println(exp.printStackTrace())
|
||||
connect = false
|
||||
datacollector.setConnect(true)
|
||||
}
|
||||
}.start()
|
||||
|
||||
}
|
||||
|
||||
fun pub(topic: String, msg: String) {
|
||||
nc?.publish(topic, msg.toByteArray(StandardCharsets.UTF_8))
|
||||
Log.d(TAG, "Published msg ${msg} on topic ${topic}")
|
||||
}
|
||||
|
||||
fun close() {
|
||||
nc?.close()
|
||||
Log.d(TAG, "Nats connection close")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.example.hpostesting.presentation
|
||||
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
@@ -14,6 +15,7 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.util.MyUtils
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||
@@ -32,6 +34,12 @@ class SplashActivity : AppCompatActivity() {
|
||||
|
||||
private var allPermissionsGranted = false
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySplashBinding.inflate(layoutInflater)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.example.hpostesting.presentation.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -28,9 +26,7 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
||||
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
||||
|
||||
inner class OfflineUserListViewHolder(val binding: OfflineUserListViewBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
}
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
||||
override fun areItemsTheSame(
|
||||
@@ -58,58 +54,61 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
||||
return differ.currentList.size
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
||||
val userList = differ.currentList[position]
|
||||
holder.binding.apply {
|
||||
userID.text = "User ID: ${userList._id}"
|
||||
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
||||
time.text = "Time: ${isBetween15And30Minutes(userList.incubationTime)} \n Started at: ${
|
||||
SimpleDateFormat("HH:mm:ss").format(
|
||||
SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).parse(userList.incubationTime)!!
|
||||
)
|
||||
}"
|
||||
|
||||
if (userList.testStatus!!) {
|
||||
teststatus.text = view.context.getString(R.string.test_concluded)
|
||||
|
||||
} else {
|
||||
teststatus.text = view.context.getString(R.string.test_pending)
|
||||
}
|
||||
|
||||
time.text = "Time: ${userList.incubationTime}"
|
||||
userCard.setOnClickListener {
|
||||
if (batLevel < 40) {
|
||||
showWarningToast(R.string.low_battery_warning)
|
||||
} else {
|
||||
if (userList.testStatus != null) {
|
||||
if (userList.testStatus!!) {
|
||||
showWarningToast(R.string.test_already_conducted)
|
||||
} else {
|
||||
if (userList.incubationTime != "") {
|
||||
val incubationTimeDiff = isBetween15And30Minutes(userList.incubationTime)
|
||||
if (incubationTimeDiff < 15) {
|
||||
showWarningToast(R.string.incubation_not_completed)
|
||||
} else if (incubationTimeDiff > 30) {
|
||||
showWarningToast(R.string.incubation_crossed_30_minutes)
|
||||
} else {
|
||||
DataHolder.selectedTest = UserData(
|
||||
_id = userList._id,
|
||||
bloodGroup = userList.bloodGroup,
|
||||
incubationTime = userList.incubationTime
|
||||
)
|
||||
view.findNavController()
|
||||
.navigate(R.id.action_nav_home_to_mainActivity)
|
||||
}
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.low_battery_warning),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (userList.testStatus != null) {
|
||||
if (userList.testStatus!!) {
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.test_already_conducted),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
if (userList.incubationTime != "") {
|
||||
if (isBetween15And30Minutes(userList.incubationTime) < Constants.INCUBATION_TIME_MIN) {
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.incubation_not_completed),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else if (isBetween15And30Minutes(userList.incubationTime) > Constants.INCUBATION_TIME_MAX) {
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.incubation_crossed_30_minutes),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
showWarningToast(R.string.incubation_not_started)
|
||||
DataHolder.selectedTest = UserData(
|
||||
_id = userList._id,
|
||||
bloodGroup = userList.bloodGroup,
|
||||
incubationTime = userList.incubationTime
|
||||
)
|
||||
view.findNavController()
|
||||
.navigate(R.id.action_nav_home_to_mainActivity)
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.incubation_not_started),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,25 +122,4 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
||||
|
||||
return diffMillis / (60 * 1000)
|
||||
}
|
||||
|
||||
|
||||
private fun showWarningToast(resId: Int) {
|
||||
val contextToUse = view.context ?: return
|
||||
|
||||
val message = try {
|
||||
contextToUse.getString(resId)
|
||||
} catch (e: Resources.NotFoundException) {
|
||||
"Resource not found for ID: $resId"
|
||||
}
|
||||
|
||||
Toast.makeText(
|
||||
contextToUse,
|
||||
message,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import android.widget.AutoCompleteTextView
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.google.firebase.firestore.FirebaseFirestore
|
||||
|
||||
@@ -94,13 +95,13 @@ class UserListAdapter(
|
||||
|
||||
val builder = AlertDialog.Builder(context)
|
||||
.setView(dialogView)
|
||||
.setTitle("Add Blood Group")
|
||||
.setTitle(R.string.blood_group)
|
||||
|
||||
val etBloodGroup = dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
||||
|
||||
builder.setPositiveButton("OK") { dialog, which ->
|
||||
builder.setPositiveButton(R.string.ok) { dialog, which ->
|
||||
val bloodGroup = etBloodGroup.text.toString()
|
||||
if (bloodGroup.equals("Select Blood Group") || bloodGroup.isNullOrBlank()) {
|
||||
if (bloodGroup.equals("Select Blood Group") ||bloodGroup.equals("ರಕ್ತ ಗುಂಪು ಆಯ್ಕೆಮಾಡಿ") || bloodGroup.isNullOrBlank()) {
|
||||
if (view != null) {
|
||||
etBloodGroup.error =view.context.getString(R.string.blood_group_error)
|
||||
}
|
||||
@@ -166,7 +167,7 @@ class UserListAdapter(
|
||||
// Handle the selected blood group here
|
||||
}
|
||||
|
||||
builder.setNegativeButton("Cancel") { dialog, which ->
|
||||
builder.setNegativeButton(R.string.cancel) { dialog, which ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ class UserListAdapter(
|
||||
// }
|
||||
}
|
||||
userCard.setOnClickListener {
|
||||
if (batLevel < 40) {
|
||||
if (false) {
|
||||
Toast.makeText(
|
||||
view.context,
|
||||
context?.getString(R.string.low_battery_warning),
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.example.hpostesting.data.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.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
@@ -73,6 +74,12 @@ open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -10,7 +12,12 @@ import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.navigateUp
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.NatsManager
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
import com.google.android.play.core.appupdate.AppUpdateManager
|
||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
@@ -18,11 +25,22 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||
|
||||
open interface IDataCollector {
|
||||
fun setConnect(connect: Boolean)
|
||||
fun setResponse(response: String)
|
||||
}
|
||||
@AndroidEntryPoint
|
||||
class DashboardActivity : AppCompatActivity() {
|
||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
|
||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||
private lateinit var binding: ActivityDashboardBinding
|
||||
var responses: String = ""
|
||||
lateinit var nats: NatsManager
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -30,6 +48,9 @@ class DashboardActivity : AppCompatActivity() {
|
||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||
nats = NatsManager(this)
|
||||
// nats.connect()
|
||||
// nats.pub("server.hpos.HCV-000-3001.ping", "THIS IS A TEST MSG")
|
||||
|
||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||
val navView: NavigationView = binding.navView
|
||||
@@ -95,4 +116,16 @@ class DashboardActivity : AppCompatActivity() {
|
||||
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setConnect(connect: Boolean) {
|
||||
if(connect){
|
||||
Log.i("NATS Connection", connect.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun setResponse(response: String) {
|
||||
|
||||
responses = responses+response+"\n"
|
||||
println(responses)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.BatteryManager
|
||||
import android.os.Bundle
|
||||
import android.util.Base64
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -16,9 +17,13 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.model.login.LoginRequest
|
||||
import com.example.hpostesting.data.model.login.LoginResponse
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||
import com.example.hpostesting.presentation.KitScanActivity
|
||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||
@@ -33,6 +38,7 @@ import com.google.firebase.perf.ktx.performance
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||
import org.json.JSONObject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
@@ -98,6 +104,7 @@ class HomeFragment : Fragment() {
|
||||
loadUserData()
|
||||
setSearch()
|
||||
checkForLocalDBData()
|
||||
checkForTokenAndUpdate()
|
||||
} else {
|
||||
binding.internetAvailableCL.visibility = View.GONE
|
||||
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||
@@ -107,9 +114,7 @@ class HomeFragment : Fragment() {
|
||||
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||
if (result == "Success") {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
R.string.test_upload,
|
||||
Toast.LENGTH_SHORT
|
||||
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
if (result == "Error") {
|
||||
@@ -134,15 +139,140 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForTokenAndUpdate() {
|
||||
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||
val natsToken = sharedPreference.getString(Constants.NATS_TOKEN, "").toString()
|
||||
val natsTokenExpireDate = sharedPreference.getString(Constants.NATS_TOKEN_EXPIRE_DATE, "").toString()
|
||||
if (accessToken.isEmpty() && natsToken.isEmpty()) {
|
||||
hemoCubeViewModel.login(createLoginRequestData())
|
||||
} else {
|
||||
if (isTokenExpired(accessToken)) {
|
||||
hemoCubeViewModel.login(createLoginRequestData())
|
||||
} else {
|
||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||
hemoCubeViewModel.uploadLogs()
|
||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
}
|
||||
}
|
||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
updateTokens(response)
|
||||
checkForTokenAndUpdate()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
response.exception.let { message ->
|
||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is Result.Loading -> {
|
||||
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
Toast.makeText(
|
||||
requireContext(), response.data.data?.version, Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
response.exception.let { message ->
|
||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is Result.Loading -> {
|
||||
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Log uploaded ${response.data.data?.filename}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
is Result.Error -> {
|
||||
response.exception.let { message ->
|
||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is Result.Loading -> {
|
||||
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isTokenExpired(token: String): Boolean {
|
||||
val parts = token.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val decodedPayload = String(Base64.decode(parts[1], Base64.DEFAULT))
|
||||
val jsonPayload = JSONObject(decodedPayload)
|
||||
|
||||
val exp = jsonPayload.optLong("exp", 0)
|
||||
val currentTimeSeconds = System.currentTimeMillis() / 1000
|
||||
|
||||
return exp <= currentTimeSeconds
|
||||
}
|
||||
|
||||
private fun updateTokens(response: Result.Success<LoginResponse>) {
|
||||
with(sharedPreference.edit()) {
|
||||
putString(Constants.ACCESS_TOKEN, response.data.data?.accessToken)
|
||||
putString(Constants.NATS_TOKEN, response.data.data?.deviceUser?.natsToken)
|
||||
putString(Constants.NATS_TOKEN_EXPIRE_DATE, response.data.data?.deviceUser?.natsTokenExpiry)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createLoginRequestData(): LoginRequest {
|
||||
return LoginRequest(
|
||||
password = Constants.devicePassword,
|
||||
serialNumber = Constants.deviceID,
|
||||
username = Constants.deviceID
|
||||
)
|
||||
}
|
||||
|
||||
private fun createCheckUpdateRequestData(): CheckUpdateRequest {
|
||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
return CheckUpdateRequest(
|
||||
currentVersion = version
|
||||
)
|
||||
}
|
||||
|
||||
private fun setUserId() {
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
val userId = binding.userId.text.toString()
|
||||
val bloodGroup = binding.etBloodGroup.text
|
||||
|
||||
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
||||
hemoCubeViewModel.addUser(
|
||||
HemoCubeTestData(
|
||||
_id = userId, bloodGroup = bloodGroup.toString(), incubationTime = SimpleDateFormat(
|
||||
_id = userId,
|
||||
bloodGroup = bloodGroup.toString(),
|
||||
incubationTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time).toString()
|
||||
)
|
||||
@@ -163,10 +293,10 @@ class HomeFragment : Fragment() {
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||
val currentDate = Date()
|
||||
val formattedDate = dateFormat.format(currentDate)
|
||||
// val query = Firebase.firestore.collection("patientData")
|
||||
// .whereGreaterThanOrEqualTo("createdAt", formattedDate)
|
||||
// .orderBy("createdAt", Query.Direction.DESCENDING)
|
||||
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
||||
val query = Firebase.firestore.collection("patientData")
|
||||
.whereGreaterThanOrEqualTo("createdAt", formattedDate)
|
||||
.orderBy("createdAt", Query.Direction.DESCENDING)
|
||||
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
||||
query.get().addOnSuccessListener {
|
||||
if (it.documents.isEmpty()) {
|
||||
binding.pendingTest.visibility = View.VISIBLE
|
||||
@@ -183,8 +313,12 @@ class HomeFragment : Fragment() {
|
||||
|
||||
rvAdapter = view?.let {
|
||||
UserListAdapter(
|
||||
requireContext(), hemoCubeViewModel, recyclerViewOptions,
|
||||
it, batLevel, requireActivity()
|
||||
requireContext(),
|
||||
hemoCubeViewModel,
|
||||
recyclerViewOptions,
|
||||
it,
|
||||
batLevel,
|
||||
requireActivity()
|
||||
)
|
||||
}!!
|
||||
binding.rvOrder.adapter = rvAdapter
|
||||
@@ -309,7 +443,7 @@ class HomeFragment : Fragment() {
|
||||
|
||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||
val uploadDataVisibility =
|
||||
if (userDataList.any { !it.localFlag && it.testStatus == true}) View.VISIBLE else View.GONE
|
||||
if (userDataList.any { !it.localFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||
binding.uploadData.visibility = uploadDataVisibility
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,66 @@
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.example.hpostesting.presentation.dashboard.ui.slideshow.SlideshowViewModel
|
||||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||
private var isLanguageChanged = false
|
||||
|
||||
class SlideshowFragment : Fragment() {
|
||||
private var _binding: FragmentSlideshowBinding? = null
|
||||
class SlideshowFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||
|
||||
// This property is only valid between onCreateView and
|
||||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
val languagePreference = ListPreference(requireContext())
|
||||
languagePreference.key = "language_preference"
|
||||
languagePreference.title = getString(R.string.app_language)
|
||||
languagePreference.summary = getString(R.string.select_language)
|
||||
languagePreference.entries = arrayOf("English", "Kannada", "Hindi")
|
||||
languagePreference.entryValues = arrayOf("en", "kn", "hi")
|
||||
languagePreference.setDefaultValue("en")
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?,
|
||||
): View {
|
||||
val slideshowViewModel =
|
||||
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
||||
languagePreference.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
val languageCode = newValue as String
|
||||
updateLanguage(requireContext(), languageCode)
|
||||
true
|
||||
}
|
||||
|
||||
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
||||
val root: View = binding.root
|
||||
preferenceScreen.addPreference(languagePreference)
|
||||
setPreferenceScreen(preferenceScreen)
|
||||
|
||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
binding.textSlideshow.text = version
|
||||
// App Version Preference
|
||||
val appVersionPreference = Preference(requireContext())
|
||||
appVersionPreference.title = "App Version"
|
||||
appVersionPreference.summary = getAppVersion(requireContext())
|
||||
|
||||
// val textView: TextView = binding.textSlideshow
|
||||
// slideshowViewModel.text.observe(viewLifecycleOwner) {
|
||||
// textView.text = it
|
||||
// }
|
||||
return root
|
||||
preferenceScreen.addPreference(languagePreference)
|
||||
preferenceScreen.addPreference(appVersionPreference)
|
||||
setPreferenceScreen(preferenceScreen)
|
||||
|
||||
if (isLanguageChanged) {
|
||||
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
private fun updateLanguage(context: Context, languageCode: String) {
|
||||
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||
LanguageManager.setLocale(context, languageCode)
|
||||
requireActivity().recreate() // Recreate activity to apply language changes
|
||||
isLanguageChanged = true
|
||||
}
|
||||
|
||||
private fun getAppVersion(context: Context): String {
|
||||
return try {
|
||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||
pInfo.versionName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
"N/A"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,8 @@ class LoginFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
||||
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
sharedPreference =
|
||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.example.hpostesting.data.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.testRight.UsbService
|
||||
@@ -77,6 +78,12 @@ class DiagnosticsActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityDiagnosticsBinding.inflate(layoutInflater)
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.os.IBinder
|
||||
import android.view.Menu
|
||||
import androidx.activity.viewModels
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
@@ -21,8 +22,15 @@ import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||
|
||||
class DigitalCardActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityDigitalCardBinding
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityDigitalCardBinding.inflate(layoutInflater)
|
||||
|
||||
@@ -5,15 +5,16 @@ import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
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.model.patient.DeviceData
|
||||
@@ -34,16 +35,31 @@ class HemoCubeFragment : Fragment() {
|
||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
private var isOnline = false
|
||||
private var currentDeviceData: DeviceData? = null
|
||||
private var resultData: String = ""
|
||||
private var deviceSerialNo: String = ""
|
||||
private var coefficient: String? = ""
|
||||
private var isUsingExistingBuffer = false
|
||||
private var isTestOngoing = false
|
||||
private var startListening = MutableLiveData<Boolean>(false)
|
||||
val testingTrace = Firebase.performance.newTrace("testing_trace")
|
||||
private val testingTrace = Firebase.performance.newTrace("testing_trace")
|
||||
private var led1BufferForDevice = 0.0
|
||||
private var led2BufferForDevice = 0.0
|
||||
private var led3BufferForDevice = 0.0
|
||||
private var led4BufferForDevice = 0.0
|
||||
private var led1SampleForDevice = 0.0
|
||||
private var led2SampleForDevice = 0.0
|
||||
private var led3SampleForDevice = 0.0
|
||||
private var led4SampleForDevice = 0.0
|
||||
private var fittedAbs1 = 0.0
|
||||
private var fittedAbs2 = 0.0
|
||||
private var fittedAbs3 = 0.0
|
||||
private var fittedAbs4 = 0.0
|
||||
private var _predictedDenovixRatio = 0.0
|
||||
private var validationError = false
|
||||
private var deviceHardwareId = ""
|
||||
private var allErrorMessages = ""
|
||||
private var testStatusCode = 0.0
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||
@@ -57,8 +73,9 @@ class HemoCubeFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initViews()
|
||||
listenToHemoCube()
|
||||
getDeviceInfo()
|
||||
observeViewModel()
|
||||
checkAndStartProcess()
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
@@ -70,11 +87,6 @@ class HemoCubeFragment : Fragment() {
|
||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
||||
)
|
||||
}
|
||||
if (isTestOngoing) {
|
||||
// binding.btnKit.visibility = View.GONE
|
||||
// binding.btnKit.isEnabled = false
|
||||
// binding.btnKit.isClickable = false
|
||||
}
|
||||
|
||||
binding.tvTitle2.visibility = View.GONE
|
||||
binding.etAbhaId.visibility = View.GONE
|
||||
@@ -83,27 +95,80 @@ class HemoCubeFragment : Fragment() {
|
||||
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}"
|
||||
Log.e("nametext", binding.tvName.text.toString())
|
||||
binding.tvSubtitle4.text = "Config"
|
||||
|
||||
binding.btnSamplestart.setOnClickListener {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||
// binding.tvSubtitle4.text = "Sample Started"
|
||||
}
|
||||
startSampleProcess()
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.btnPlacebuffer.setOnClickListener {
|
||||
if (isBufferValueAvailable()) {
|
||||
showBufferAlertDialog()
|
||||
} else {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||
// binding.tvSubtitle4.text = "Buffer Started"
|
||||
}
|
||||
|
||||
checkAndStartProcess()
|
||||
it.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvDeviceMessages.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeViewModel() {
|
||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||
if (result == "Success") {
|
||||
showToast("Test Results Uploaded Successfully")
|
||||
val i = Intent(
|
||||
requireContext().applicationContext, DashboardActivity::class.java
|
||||
)
|
||||
startActivity(i)
|
||||
(activity as HemocubeActivity).finish()
|
||||
showToast(R.string.test_upload)
|
||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
it1._id)
|
||||
activity?.runOnUiThread {
|
||||
binding.btnSubmit.visibility = View.GONE
|
||||
val i = Intent(
|
||||
requireContext().applicationContext,
|
||||
DashboardActivity::class.java
|
||||
)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
is Result.Error -> {
|
||||
//Remove this line of code while deploying to IOCL
|
||||
it.exception.let { message ->
|
||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result == "Local") {
|
||||
showToast("Internet not available, test details stored locally")
|
||||
showToast(R.string.internt_not_local)
|
||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||
}
|
||||
if (result == "Error") {
|
||||
showToast("Error uploading data, test details stored locally")
|
||||
showToast(R.string.error_local)
|
||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||
}
|
||||
|
||||
@@ -118,25 +183,13 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||
apply {
|
||||
// if (isNetworkAvailable) {
|
||||
// Online mode
|
||||
DataHolder.hemoCubeTestData?.let {
|
||||
currentDeviceData?.coefficients?.let { coefficients ->
|
||||
val coefficient1 = coefficients[0]
|
||||
val coefficient2 = coefficients[1]
|
||||
val result = coefficient1 * coefficient2
|
||||
// Process result in online mode
|
||||
}
|
||||
DataHolder.hemoCubeTestData?.let {
|
||||
currentDeviceData?.coefficients?.let { coefficients ->
|
||||
val coefficient1 = coefficients[0]
|
||||
val coefficient2 = coefficients[1]
|
||||
val result = coefficient1 * coefficient2
|
||||
}
|
||||
// } else {
|
||||
// // Offline mode
|
||||
// val coefficient1 = Constants.COEFFICIENTS[deviceSerialNo]?.get(0)?.get(0).toString().toDoubleOrNull() ?: 0.0
|
||||
// val coefficient2 = Constants.COEFFICIENTS[deviceSerialNo]?.get(1)?.get(0).toString().toDoubleOrNull() ?: 0.0
|
||||
// val result = coefficient1 * coefficient2
|
||||
//
|
||||
// // Process result in offline mode
|
||||
// }
|
||||
|
||||
}
|
||||
isOnline = isNetworkAvailable
|
||||
}
|
||||
}
|
||||
@@ -144,51 +197,52 @@ class HemoCubeFragment : Fragment() {
|
||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||
binding.tvSubtitle4.text = it
|
||||
}
|
||||
// startListening.observe(viewLifecycleOwner) {
|
||||
// if (it) {
|
||||
// lifecycleScope.launch {
|
||||
// delay(1000)
|
||||
// if (binding.tvSubtitle4.text.toString().isEmpty()) {
|
||||
// (activity as HemocubeActivity).reconnectDevice()
|
||||
// if (isBufferValueAvailable()) {
|
||||
// showBufferAlertDialog()
|
||||
// } else {
|
||||
// listenToHemoCube()
|
||||
// startBufferProcess()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private fun checkAndStartProcess() {
|
||||
if (isBufferValueAvailable()) {
|
||||
showBufferAlertDialog()
|
||||
} else {
|
||||
listenToHemoCube()
|
||||
startBufferProcess()
|
||||
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||
binding.tvDeviceMessages.text = it
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkAndStartProcess() {
|
||||
startBufferProcess()
|
||||
}
|
||||
|
||||
private fun isBufferValueAvailable(): Boolean {
|
||||
return if (sharedPreferences.getString(
|
||||
Constants.BUFFER_VALUE_1, ""
|
||||
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||
) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")
|
||||
?.toDouble()!! > 0.0
|
||||
} else {
|
||||
return try {
|
||||
if (sharedPreferences.getString(
|
||||
Constants.BUFFER_VALUE_1, ""
|
||||
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||
&& sharedPreferences.getString(Constants.BUFFER_VALUE_3, "") != ""
|
||||
&& sharedPreferences.getString(Constants.BUFFER_VALUE_4, "") != ""
|
||||
) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||
Constants.BUFFER_VALUE_2,
|
||||
""
|
||||
)
|
||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||
Constants.BUFFER_VALUE_3,
|
||||
""
|
||||
)
|
||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
||||
Constants.BUFFER_VALUE_4,
|
||||
""
|
||||
)
|
||||
?.toDouble()!! > 0.0
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast(R.string.error_exist)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBufferAlertDialog() {
|
||||
val title = "WARNING"
|
||||
val message = "Do you want to continue with existing buffer?"
|
||||
val message = getString(R.string.do_exist)
|
||||
val negativeText = getString(R.string.no)
|
||||
val positiveText = "Yes"
|
||||
val positiveText = getString(R.string.yes)
|
||||
|
||||
UIUtils.createAlertDialog(requireContext(),
|
||||
title,
|
||||
@@ -197,13 +251,15 @@ class HemoCubeFragment : Fragment() {
|
||||
positiveText,
|
||||
object : MyDialogListener {
|
||||
override fun onClickNegativeButton() {
|
||||
listenToHemoCube()
|
||||
startBufferProcess()
|
||||
}
|
||||
|
||||
override fun onClickPositiveButton() {
|
||||
listenToHemoCube()
|
||||
startSampleProcess()
|
||||
activity?.runOnUiThread {
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
binding.btnSamplestart.visibility = View.VISIBLE
|
||||
binding.tvSubtitle4.text = getString(R.string.place_sample)
|
||||
}
|
||||
isUsingExistingBuffer = true
|
||||
}
|
||||
})
|
||||
@@ -225,7 +281,7 @@ class HemoCubeFragment : Fragment() {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
fullReadOutput.append(stringData)
|
||||
handleUsbData(stringData, fullReadOutput)
|
||||
handleUsbData(stringData, testStatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,47 +290,134 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
showToast("test is going on")
|
||||
showToast(R.string.test_ongoing)
|
||||
Firebase.crashlytics.recordException(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||
private fun getDeviceInfo() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.getDeviceId,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
data?.let {
|
||||
val stringData = String(it)
|
||||
hemoCubeViewModel.messages.postValue(stringData)
|
||||
binding.tvSubtitle4.text = stringData
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun handleUsbData(stringData: String, testStatusCode: Double) {
|
||||
if (stringData.contains("#")) {
|
||||
hemoCubeViewModel.messages.postValue(stringData)
|
||||
isTestOngoing = true
|
||||
}
|
||||
|
||||
resultData += stringData
|
||||
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||
|
||||
when {
|
||||
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
||||
stringData.contains("#Sample Completed") -> {
|
||||
resultData.contains("SNE") && this.testStatusCode < Constants.TEST_STATUS_CODE_CONFIG_COMPLETED -> {
|
||||
val pattern = Regex("HCV-\\d{3}-\\d{4}")
|
||||
val matchResult = pattern.find(resultData)
|
||||
val hardwareId = matchResult?.value
|
||||
|
||||
if (hardwareId.toString().length == 12) {
|
||||
deviceHardwareId += hardwareId
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, deviceHardwareId)
|
||||
apply()
|
||||
}
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_CONFIG_COMPLETED
|
||||
} else {
|
||||
hemoCubeViewModel.messages.postValue("Config error")
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||
}
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
||||
}
|
||||
|
||||
resultData.contains("#BS") && this.testStatusCode < Constants.TEST_STATUS_CODE_BUFFER_STARTED -> {
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_BUFFER_STARTED
|
||||
}
|
||||
|
||||
resultData.contains("#BC") && this.testStatusCode < Constants.TEST_STATUS_CODE_BUFFER_COMPLETED -> {
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_BUFFER_COMPLETED
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.text = getString(R.string.buffer_completed)
|
||||
binding.btnSamplestart.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
resultData.contains("#SS") && this.testStatusCode < Constants.TEST_STATUS_CODE_SAMPLE_STARTED -> {
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_SAMPLE_STARTED
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.text = getString(R.string.sample_started)
|
||||
binding.btnSamplestart.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
resultData.contains("#SC") && this.testStatusCode < Constants.TEST_STATUS_CODE_SAMPLE_COMPLETED -> {
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_SAMPLE_COMPLETED
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data))
|
||||
fetchResult()
|
||||
testingTrace.stop()
|
||||
}
|
||||
|
||||
stringData.contains("RESULT") || resultData.contains("REND") -> {
|
||||
var validString: String
|
||||
val results: List<String>
|
||||
if (stringData.contains("RESULT")) {
|
||||
validString = isValidResult(stringData)
|
||||
if (validString.isEmpty()) {
|
||||
results = resultData.split("\n")
|
||||
validString = parseResult(results)
|
||||
}
|
||||
resultData.contains("REND") && this.testStatusCode < Constants.TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED -> {
|
||||
this.testStatusCode = Constants.TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED
|
||||
hemoCubeViewModel.messages.postValue(
|
||||
getString(R.string.data_collected_processing_data)
|
||||
)
|
||||
val resultLines = resultData.split("\\s+(?=LB|LS)".toRegex())
|
||||
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
||||
led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
||||
} else {
|
||||
results = resultData.split("\n")
|
||||
validString = parseResult(results)
|
||||
bufferIntensity.toDoubleOrNull()!!
|
||||
}
|
||||
if (validString.isNotEmpty()) {
|
||||
handleValidResult(validString, resultData)
|
||||
bufferIntensity = resultLines[2].split(' ')[1].trim()
|
||||
led2BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()!!
|
||||
} else {
|
||||
bufferIntensity.toDoubleOrNull()!!
|
||||
}
|
||||
bufferIntensity = resultLines[3].split(' ')[1].trim()
|
||||
led3BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_3, "")?.toDoubleOrNull()!!
|
||||
} else {
|
||||
bufferIntensity.toDoubleOrNull()!!
|
||||
}
|
||||
bufferIntensity = resultLines[4].split(' ')[1].trim()
|
||||
led4BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_4, "")?.toDoubleOrNull()!!
|
||||
} else {
|
||||
bufferIntensity.toDoubleOrNull()!!
|
||||
}
|
||||
|
||||
var sampleIntensity = resultLines[5].split(' ')[1].trim()
|
||||
led1SampleForDevice = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
sampleIntensity = resultLines[6].split(' ')[1].trim()
|
||||
led2SampleForDevice = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
sampleIntensity = resultLines[7].split(' ')[1].trim()
|
||||
led3SampleForDevice = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||
sampleIntensity = resultLines[8].split(' ')[1].split('\r')[0].trim()
|
||||
led4SampleForDevice =
|
||||
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||
processResult()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun showError() {
|
||||
activity?.runOnUiThread {
|
||||
UIUtils.createAlertDialog(requireContext(),
|
||||
@@ -297,166 +440,268 @@ class HemoCubeFragment : Fragment() {
|
||||
// If the test is ongoing, don't allow the back button action
|
||||
// You can optionally show a message to the user indicating why the back button is disabled
|
||||
// For example, show a Toast or Snackbar.
|
||||
showToast("Test is ongoing. Cannot go back.")
|
||||
showToast(R.string.test_go_noback)
|
||||
} else {
|
||||
// If the test is not ongoing, you can trigger the back action of the hosting activity
|
||||
activity?.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showStartSampleDialog() {
|
||||
activity?.runOnUiThread {
|
||||
UIUtils.createAlertDialog(requireContext(),
|
||||
"Start Sample",
|
||||
"Do you want to start sample reading?",
|
||||
getString(R.string.no),
|
||||
"Yes",
|
||||
object : MyDialogListener {
|
||||
override fun onClickNegativeButton() {}
|
||||
|
||||
override fun onClickPositiveButton() {
|
||||
listenToHemoCube()
|
||||
startSampleProcess()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun handleValidResult(validString: String, fullReadOutput: String) {
|
||||
private fun processResult() {
|
||||
try {
|
||||
val result = validString.split(" ")
|
||||
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
||||
val deviceLog = resultData
|
||||
if (result.size == 8) {
|
||||
val deviceSerialNo = result[2]
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, deviceSerialNo)
|
||||
apply()
|
||||
}
|
||||
val loginId = sharedPreferences.getString(Constants.USER_ID, "").toString()
|
||||
if (checkDeviceIdMismatch(deviceSerialNo, loginId)) {
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = "Warning: Login Id is different"
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
val led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()
|
||||
} else {
|
||||
result[3].toDoubleOrNull()
|
||||
}
|
||||
val led2BufferForDevice = if (isUsingExistingBuffer) {
|
||||
sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()
|
||||
} else {
|
||||
result[4].toDoubleOrNull()
|
||||
}
|
||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
val led1Sample = result[5].toDoubleOrNull()
|
||||
val led2Sample = result[6].toDoubleOrNull()
|
||||
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
||||
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||
val deviceRatio = led1Average / led2Average
|
||||
val coefficientsList = Constants.COEFFICIENTS[deviceSerialNo]
|
||||
// if (coefficientsList != null) {
|
||||
val coefficient1 = coefficientsList?.get(0)?.get(0).toString()
|
||||
val coefficient2 = coefficientsList?.get(1)?.get(0).toString()
|
||||
val coefficientsString = "$coefficient1,$coefficient2"
|
||||
|
||||
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||
// if (deviceRatio < 0.08) {
|
||||
// if (deviceRatio > 1.07) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||
requireActivity().packageName, 0
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
|
||||
if (led1Average < 0 || led2Average < 0) {
|
||||
activity?.runOnUiThread{
|
||||
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
val led1Average = log10(led1BufferForDevice.div(led1SampleForDevice))
|
||||
val led2Average = log10(led2BufferForDevice.div(led2SampleForDevice))
|
||||
val led3Average = log10(led3BufferForDevice.div(led3SampleForDevice))
|
||||
val led4Average = log10(led4BufferForDevice.div(led4SampleForDevice))
|
||||
val deviceRatio = led3Average / led1Average
|
||||
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
deviceId = deviceSerialNo
|
||||
led1Buffer = led1BufferForDevice
|
||||
led2Buffer = led2BufferForDevice
|
||||
appVersion = version
|
||||
this.led1Sample = led1Sample
|
||||
this.led2Sample = led2Sample
|
||||
this.led1Average = led1Average
|
||||
this.led2Average = led2Average
|
||||
this.deviceRatio = deviceRatio
|
||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||
this.coefficients = coefficientsString
|
||||
this.classificationResult = findResult(calculatedRatio)
|
||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||
this.resultData = deviceLog
|
||||
if (!isUsingExistingBuffer) {
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.BUFFER_VALUE_1, led1Buffer.toString())
|
||||
putString(Constants.BUFFER_VALUE_2, led2Buffer.toString())
|
||||
apply()
|
||||
}
|
||||
}
|
||||
activity?.runOnUiThread {
|
||||
binding.btnSubmit.visibility = View.VISIBLE
|
||||
binding.btnSubmit.isEnabled = true
|
||||
binding.btnSubmit.isClickable = true
|
||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||
}
|
||||
if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)
|
||||
?.get(0)!!
|
||||
|| led2BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
1
|
||||
)?.get(0)!!
|
||||
|| led3BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
2
|
||||
)?.get(0)!!
|
||||
|| led4BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
3
|
||||
)?.get(0)!!
|
||||
) {
|
||||
validationError = true
|
||||
allErrorMessages += "Error: Invalid Test. Improper buffer reading (low)"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = getString(R.string.error_improper_buffer_low)
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
if (led1BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)
|
||||
?.get(1)!!
|
||||
|| led2BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
1
|
||||
)?.get(1)!!
|
||||
|| led3BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
2
|
||||
)?.get(1)!!
|
||||
|| led4BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||
3
|
||||
)?.get(1)!!
|
||||
) {
|
||||
validationError = true
|
||||
allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text =
|
||||
getString(R.string.error_improper_buffer_high)
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
binding.btnSubmit.isEnabled = true
|
||||
binding.btnSubmit.isClickable = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var gradient = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(0)
|
||||
var constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(1)
|
||||
fittedAbs1 = gradient?.times(led1Average)?.plus(constant!!)!!
|
||||
|
||||
gradient = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(1)?.get(0)
|
||||
constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(1)?.get(1)
|
||||
fittedAbs2 = gradient?.times(led2Average)?.plus(constant!!)!!
|
||||
|
||||
gradient = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(2)?.get(0)
|
||||
constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(2)?.get(1)
|
||||
fittedAbs3 = gradient?.times(led3Average)?.plus(constant!!)!!
|
||||
|
||||
gradient = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(3)?.get(0)
|
||||
constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(3)?.get(1)
|
||||
fittedAbs4 = gradient?.times(led4Average)?.plus(constant!!)!!
|
||||
|
||||
_predictedDenovixRatio = fittedAbs3.div(fittedAbs1)
|
||||
|
||||
if (fittedAbs1 <= fittedAbs2) {
|
||||
validationError = true
|
||||
allErrorMessages += "Error: Invalid Test. Problem with de-oxygenation" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = getString(R.string.error_invalid_test)
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
if (fittedAbs1 < 0 || fittedAbs2 < 0 || fittedAbs3 < 0 || fittedAbs4 < 0) {
|
||||
validationError = true
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = getString(R.string.error_negative_abs)
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
if (fittedAbs3 < 0.1) {
|
||||
validationError = true
|
||||
allErrorMessages += "Error: Low Hb. Repeat test" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = "Error: Low Hb. Repeat test"
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
DataHolder.hemoCubeTestData?.apply {
|
||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()
|
||||
led1Buffer = led1BufferForDevice
|
||||
led2Buffer = led2BufferForDevice
|
||||
led3Buffer = led3BufferForDevice
|
||||
led4Buffer = led4BufferForDevice
|
||||
appVersion = version
|
||||
this.led1Sample = led1SampleForDevice
|
||||
this.led2Sample = led2SampleForDevice
|
||||
this.led3Sample = led3SampleForDevice
|
||||
this.led4Sample = led4SampleForDevice
|
||||
this.led1Average = led1Average
|
||||
this.led2Average = led2Average
|
||||
this.led3Average = led3Average
|
||||
this.led4Average = led4Average
|
||||
this.abs1 = fittedAbs1
|
||||
this.abs2 = fittedAbs2
|
||||
this.abs3 = fittedAbs3
|
||||
this.abs4 = fittedAbs4
|
||||
this.deviceRatio = deviceRatio
|
||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||
this.predictedDenovixRatio = _predictedDenovixRatio
|
||||
this.coefficients = currentDeviceData?.coefficients?.get(0)
|
||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||
this.classificationResult = findResult(calculatedRatio)
|
||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||
hemoCubeViewModel.messages.postValue(this.prdClassification)
|
||||
this.errorMessages = allErrorMessages
|
||||
this.resultData = deviceLog
|
||||
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()
|
||||
this.batteryCapacity =
|
||||
hemoCubeViewModel.getBatteryCapacity(requireContext()).toString()
|
||||
this.batteryMaxCapacity =
|
||||
hemoCubeViewModel.getBatteryMaxCapacity(requireContext()).toString()
|
||||
this.batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString()
|
||||
this.batteryVoltage =
|
||||
hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
||||
}
|
||||
|
||||
if (!isUsingExistingBuffer) {
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.BUFFER_VALUE_1, led1BufferForDevice.toString())
|
||||
putString(Constants.BUFFER_VALUE_2, led2BufferForDevice.toString())
|
||||
putString(Constants.BUFFER_VALUE_3, led3BufferForDevice.toString())
|
||||
putString(Constants.BUFFER_VALUE_4, led4BufferForDevice.toString())
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
// if (!validationError) {
|
||||
activity?.runOnUiThread {
|
||||
binding.btnSubmit.visibility = View.VISIBLE
|
||||
binding.btnSubmit.isEnabled = true
|
||||
binding.btnSubmit.isClickable = true
|
||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||
}
|
||||
// }
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Error while processing device data",
|
||||
R.string.error_processing_device_data,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
Firebase.crashlytics.recordException(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun findResult(calculatedRatio: Double?): String {
|
||||
fun findResult(calculatedRatio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
if (calculatedRatio != null) {
|
||||
if (calculatedRatio < 0.05)
|
||||
return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||
if (calculatedRatio in 0.05..0.155)
|
||||
return "Normal"
|
||||
return getString(R.string.error_repeat_test_higher_volume)
|
||||
if (calculatedRatio in 0.05..0.155) {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.brightGreen
|
||||
)
|
||||
)
|
||||
}
|
||||
return getString(R.string.normal)
|
||||
}
|
||||
if (calculatedRatio in 0.155..0.175)
|
||||
return "Negative Borderline. Repeat Test"
|
||||
return getString(R.string.negative_borderline)
|
||||
if (calculatedRatio in 0.175..0.22)
|
||||
return "Sickle Cell Trait"
|
||||
return getString(R.string.sickle_cell_trait)
|
||||
if (calculatedRatio in 0.22..0.25)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
return getString(R.string.positive_for_sickle_cell)
|
||||
if (calculatedRatio in 0.25..0.35)
|
||||
return "Sickle Cell Disease"
|
||||
return getString(R.string.sickle_cell_disease)
|
||||
if (calculatedRatio > 0.35)
|
||||
return "Inconclusive. Repeat with test with lower volume of blood"
|
||||
return getString(R.string.error_repeat_test_lower_volume)
|
||||
} else {
|
||||
return "NULL"
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast("error while performing classification")
|
||||
showToast(R.string.error_classification)
|
||||
Firebase.crashlytics.recordException(e)
|
||||
return "ERROR"
|
||||
return getString(R.string.error)
|
||||
}
|
||||
return "NULL"
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
|
||||
private fun showToast(message: String) {
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||
try {
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
if (predictedDenovixRatio != null) {
|
||||
if (predictedDenovixRatio in 0.0..0.16) {
|
||||
activity?.runOnUiThread {
|
||||
binding.tvSubtitle4.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.brightGreen
|
||||
)
|
||||
)
|
||||
}
|
||||
return getString(R.string.normal)
|
||||
}
|
||||
if (predictedDenovixRatio in 0.16..0.165)
|
||||
return getString(R.string.negative_borderline)
|
||||
if (predictedDenovixRatio in 0.165..0.235)
|
||||
return getString(R.string.sickle_cell_trait)
|
||||
if (predictedDenovixRatio in 0.235..0.24)
|
||||
return getString(R.string.positive_borderline)
|
||||
if (predictedDenovixRatio in 0.24..1.0)
|
||||
return getString(R.string.sickle_cell_disease)
|
||||
} else {
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast(R.string.error_classification)
|
||||
Firebase.crashlytics.recordException(e)
|
||||
return getString(R.string.error)
|
||||
}
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
|
||||
private fun showToast(messageResId: Int) {
|
||||
Toast.makeText(requireContext(), getString(messageResId), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
private fun startBufferProcess() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
activity?.runOnUiThread {
|
||||
binding.btnPlacebuffer.visibility = View.GONE
|
||||
}
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startBuffer,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
@@ -495,35 +740,11 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun calculateRatio(ratio: Double): Double {
|
||||
val coefficient1: Double = (Constants.COEFFICIENTS[deviceSerialNo]?.get(0) ?: 0.0) as Double
|
||||
val coefficient2: Double = (Constants.COEFFICIENTS[deviceSerialNo]?.get(1) ?: 0.0) as Double
|
||||
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||
return coefficient1 * ratio + coefficient2
|
||||
}
|
||||
|
||||
|
||||
private fun parseResult(frames: List<String>): String {
|
||||
val lines = mutableListOf<String>()
|
||||
for (frame in frames.reversed()) {
|
||||
if (frame.contains("REND") || frame.contains("RESULT")) lines += frame
|
||||
if (frame.contains("RESULT")) {
|
||||
break
|
||||
}
|
||||
}
|
||||
val line = lines.reversed().joinToString("").trim()
|
||||
if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||
return line
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun isValidResult(line: String): String {
|
||||
return if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||
line
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDeviceIdMismatch(deviceId: String, loginId: String): Boolean {
|
||||
if (!deviceId.isNullOrEmpty() && !loginId.isNullOrEmpty() && deviceId.last() != loginId.last())
|
||||
return true
|
||||
|
||||
@@ -1,283 +1,394 @@
|
||||
package com.example.hpostesting.presentation.hemocube
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.os.BatteryManager
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||
import com.example.hpostesting.data.Result
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.model.Response
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||
import com.example.hpostesting.data.model.login.LoginRequest
|
||||
import com.example.hpostesting.data.model.login.LoginResponse
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||
import com.example.hpostesting.data.model.patient.UserData
|
||||
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.DatabaseRepository
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||
import com.example.hpostesting.domain.LogFileManager
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody.Companion.asRequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class HemoCubeViewModel @Inject constructor(
|
||||
private val hemoCubeDao: HemoCubeDao,
|
||||
private val repository: Repository,
|
||||
context: Context,
|
||||
private val databaseRepository: DatabaseRepository,
|
||||
private val logFileManager: LogFileManager,
|
||||
context: Context
|
||||
) : ViewModel() {
|
||||
var isServiceConnected = false
|
||||
val progressBar = MutableLiveData(false)
|
||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
val messages = MutableLiveData<String>()
|
||||
private val sharedPreference: SharedPreferences =
|
||||
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||
val messages = MutableLiveData<String>()
|
||||
private val sharedPreference: SharedPreferences =
|
||||
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
|
||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||
private val workManager = WorkManager.getInstance(context)
|
||||
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
val networkStatusLiveData: LiveData<Boolean>
|
||||
get() = _networkStatusLiveData
|
||||
val fireBaseUpload = MutableLiveData<String>()
|
||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
||||
// init {
|
||||
// startPeriodicCheckUpdate()
|
||||
// }
|
||||
|
||||
private val batteryStatus: Intent? =
|
||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
||||
context.registerReceiver(null, ifilter)
|
||||
}
|
||||
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
||||
|
||||
fun uploadHemoCubeResultToDatabase(
|
||||
isOnline: Boolean,
|
||||
testStatus: Boolean,
|
||||
kitSerial: String?
|
||||
) =
|
||||
viewModelScope.launch {
|
||||
if (kitSerial != null) {
|
||||
testDetails?.kitSerial = kitSerial
|
||||
}
|
||||
testDetails?.testStatus = testStatus
|
||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||
|
||||
try {
|
||||
if (isOnline) {
|
||||
parseData()
|
||||
addResultTestToDb()
|
||||
} else {
|
||||
parseData()
|
||||
testDetails?.testTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
hemoCubeDao.insertAll(testDetails!!)
|
||||
fireBaseUpload.postValue("Local")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Upload failed: ${e.message}")
|
||||
}
|
||||
}
|
||||
val resultUpload = MutableLiveData<Result<MolbioV2ResultResponse>>()
|
||||
|
||||
val checkUpdate = MutableLiveData<Result<CheckUpdateResponse>>()
|
||||
|
||||
val deviceUpdate = MutableLiveData<Result<ResponseBody>>()
|
||||
|
||||
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
||||
|
||||
|
||||
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
||||
viewModelScope.launch {
|
||||
addResultTestToDbforbuffercheck(bufferCheckData)
|
||||
}
|
||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||
|
||||
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
||||
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
|
||||
|
||||
val networkStatusLiveData: LiveData<Boolean>
|
||||
get() = _networkStatusLiveData
|
||||
val deviceMessages = MutableLiveData<String?>()
|
||||
val fireBaseUpload = MutableLiveData<String>()
|
||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
||||
|
||||
private val batteryStatus: Intent? =
|
||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
||||
context.registerReceiver(null, ifilter)
|
||||
}
|
||||
|
||||
private fun parseData() {
|
||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||
testDetails?.location = DataHolder.location
|
||||
testDetails?.testTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
||||
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
||||
testDetails?.deviceSerialNumber =
|
||||
sharedPreference.getString(Constants.USER_ID, "").toString()
|
||||
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
||||
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
||||
testDetails?.led3Buffer = DataHolder.hemoCubeTestData?.led3Buffer
|
||||
testDetails?.led4Buffer = DataHolder.hemoCubeTestData?.led4Buffer
|
||||
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
||||
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
||||
testDetails?.led3Sample = DataHolder.hemoCubeTestData?.led3Sample
|
||||
testDetails?.led4Sample = DataHolder.hemoCubeTestData?.led4Sample
|
||||
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
||||
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
||||
testDetails?.led3Average = DataHolder.hemoCubeTestData?.led3Average
|
||||
testDetails?.led4Average = DataHolder.hemoCubeTestData?.led4Average
|
||||
testDetails?.abs1 = DataHolder.hemoCubeTestData?.abs1
|
||||
testDetails?.abs2 = DataHolder.hemoCubeTestData?.abs2
|
||||
testDetails?.abs3 = DataHolder.hemoCubeTestData?.abs3
|
||||
testDetails?.abs4 = DataHolder.hemoCubeTestData?.abs4
|
||||
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
||||
testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio
|
||||
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||
testDetails?.prdClassification =
|
||||
DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
||||
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
||||
testDetails?.batteryMaxCapacity =
|
||||
DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString()
|
||||
testDetails?.batteryTemperature =
|
||||
DataHolder.hemoCubeTestData?.batteryTemperature.toString()
|
||||
testDetails?.batteryVoltage = DataHolder.hemoCubeTestData?.batteryVoltage.toString()
|
||||
fun uploadHemoCubeResultToDatabase(
|
||||
isOnline: Boolean, testStatus: Boolean, kitSerial: String?
|
||||
) = viewModelScope.launch {
|
||||
if (kitSerial != null) {
|
||||
testDetails?.kitSerial = kitSerial
|
||||
}
|
||||
testDetails?.testStatus = testStatus
|
||||
|
||||
private fun addResultTestToDb() {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
|
||||
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||
is Response.Success -> {
|
||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||
with(sharedPreference.edit()) {
|
||||
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||
apply()
|
||||
}
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
testDetails.localFlag = true
|
||||
hemoCubeDao.insertAll(testDetails)
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||
fireBaseUpload.postValue("Error")
|
||||
hemoCubeDao.insertAll(testDetails)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun addResultTestToDbforbuffercheck(bufferCheckData: BufferCheckData) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
|
||||
when (val response =
|
||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
is Response.Success -> {
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
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}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bulkAddResultTestToDb(userData: HemoCubeTestData) {
|
||||
viewModelScope.launch {
|
||||
userData.reportUploadTime = SimpleDateFormat(
|
||||
try {
|
||||
if (isOnline) {
|
||||
parseData()
|
||||
addResultTestToDb()
|
||||
} else {
|
||||
parseData()
|
||||
testDetails?.testTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
when (repository.addTestToDatabase(userData)) {
|
||||
is Response.Success -> {
|
||||
fireBaseBulkUpload.postValue("Success")
|
||||
updateLocalFlag(userData._id)
|
||||
}
|
||||
hemoCubeDao.insertAll(testDetails!!)
|
||||
fireBaseUpload.postValue("Local")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Upload failed: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
fireBaseBulkUpload.postValue("Error")
|
||||
}
|
||||
fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest) = viewModelScope.launch {
|
||||
deviceProvisionResponse.postValue(Result.Loading())
|
||||
databaseRepository.deviceProvision(deviceProvisionRequest).let {
|
||||
deviceProvisionResponse.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun login(loginRequest: LoginRequest) = viewModelScope.launch {
|
||||
loginResponse.postValue(Result.Loading())
|
||||
databaseRepository.login(loginRequest).let {
|
||||
loginResponse.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun uploadResult(molbioV2ResultRequest: MolbioV2ResultRequest) = viewModelScope.launch {
|
||||
resultUpload.postValue(Result.Loading())
|
||||
databaseRepository.uploadResults(molbioV2ResultRequest).let {
|
||||
resultUpload.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
||||
checkUpdate.postValue(Result.Loading())
|
||||
databaseRepository.checkUpdate(checkUpdateRequest).let {
|
||||
checkUpdate.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun deviceUpdate(deviceUpdateRequest: DeviceUpdateRequest) = viewModelScope.launch {
|
||||
deviceUpdate.postValue(Result.Loading())
|
||||
databaseRepository.deviceUpdate(deviceUpdateRequest).let {
|
||||
deviceUpdate.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun startPeriodicCheckUpdate() {
|
||||
val periodicRequest = PeriodicWorkRequestBuilder<CheckUpdateWorker>(
|
||||
repeatInterval = 1, repeatIntervalTimeUnit = TimeUnit.MINUTES
|
||||
).build()
|
||||
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
"checkUpdateWorker", ExistingPeriodicWorkPolicy.KEEP, periodicRequest
|
||||
)
|
||||
}
|
||||
|
||||
fun uploadLogs() = viewModelScope.launch {
|
||||
uploadLogs.postValue(Result.Loading())
|
||||
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) }
|
||||
multipartFile?.let { partFile ->
|
||||
databaseRepository.uploadLogs(partFile).let { result ->
|
||||
uploadLogs.postValue(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.updateFieldById(id = userId, true)
|
||||
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
||||
viewModelScope.launch {
|
||||
addResultTestToDbforbuffercheck(bufferCheckData)
|
||||
}
|
||||
|
||||
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
||||
hemoCubeDao.insertAll(userData)
|
||||
}
|
||||
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
||||
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
||||
}
|
||||
|
||||
fun deleteById(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.deleteById(id = userId)
|
||||
}
|
||||
private fun parseData() {
|
||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||
testDetails?.location = DataHolder.location
|
||||
testDetails?.testTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
||||
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
||||
testDetails?.deviceSerialNumber =
|
||||
sharedPreference.getString(Constants.USER_ID, "").toString()
|
||||
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
||||
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
||||
testDetails?.led3Buffer = DataHolder.hemoCubeTestData?.led3Buffer
|
||||
testDetails?.led4Buffer = DataHolder.hemoCubeTestData?.led4Buffer
|
||||
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
||||
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
||||
testDetails?.led3Sample = DataHolder.hemoCubeTestData?.led3Sample
|
||||
testDetails?.led4Sample = DataHolder.hemoCubeTestData?.led4Sample
|
||||
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
||||
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
||||
testDetails?.led3Average = DataHolder.hemoCubeTestData?.led3Average
|
||||
testDetails?.led4Average = DataHolder.hemoCubeTestData?.led4Average
|
||||
testDetails?.abs1 = DataHolder.hemoCubeTestData?.abs1
|
||||
testDetails?.abs2 = DataHolder.hemoCubeTestData?.abs2
|
||||
testDetails?.abs3 = DataHolder.hemoCubeTestData?.abs3
|
||||
testDetails?.abs4 = DataHolder.hemoCubeTestData?.abs4
|
||||
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
||||
testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio
|
||||
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
||||
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
||||
testDetails?.batteryMaxCapacity = DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString()
|
||||
testDetails?.batteryTemperature = DataHolder.hemoCubeTestData?.batteryTemperature.toString()
|
||||
testDetails?.batteryVoltage = DataHolder.hemoCubeTestData?.batteryVoltage.toString()
|
||||
}
|
||||
|
||||
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)
|
||||
level * 100 / scale.toFloat()
|
||||
private fun addResultTestToDb() {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
|
||||
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||
is Response.Success -> {
|
||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||
with(sharedPreference.edit()) {
|
||||
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||
apply()
|
||||
}
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
testDetails.localFlag = true
|
||||
uploadResult(
|
||||
MolbioV2ResultRequest(
|
||||
listOf(
|
||||
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,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
hemoCubeDao.insertAll(testDetails)
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||
fireBaseUpload.postValue("Error")
|
||||
hemoCubeDao.insertAll(testDetails)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
|
||||
return batteryPct
|
||||
}
|
||||
|
||||
fun getBatteryTemperature(): Float? {
|
||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||
val temperature = intent?.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0) ?: 0
|
||||
temperature.toFloat() / 10
|
||||
}
|
||||
|
||||
return batteryTemp
|
||||
}
|
||||
|
||||
fun getBatteryVoltage(context: Context): Float {
|
||||
val batteryIntent =
|
||||
context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||
val voltage = batteryIntent?.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0) ?: 0
|
||||
|
||||
// milli-volts to volts
|
||||
return voltage.toFloat() / 1000
|
||||
}
|
||||
|
||||
fun getBatteryCapacity(context: Context): Int {
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val currentCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
|
||||
return currentCapacity
|
||||
}
|
||||
|
||||
fun getBatteryMaxCapacity(context: Context): Float {
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val designCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||
val currentCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
|
||||
// Calculate the estimated maximum battery capacity in mAh
|
||||
val maxCapacity = currentCapacity.toFloat() / designCapacity.toFloat() * 100
|
||||
|
||||
return maxCapacity
|
||||
}
|
||||
}
|
||||
|
||||
private fun addResultTestToDbforbuffercheck(bufferCheckData: BufferCheckData) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
|
||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||
is Response.Success -> {
|
||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||
fireBaseUpload.postValue("Success")
|
||||
}
|
||||
|
||||
is Response.Error -> {
|
||||
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}")
|
||||
fireBaseUpload.postValue("Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bulkAddResultTestToDb(userData: HemoCubeTestData) {
|
||||
viewModelScope.launch {
|
||||
userData.reportUploadTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
when (repository.addTestToDatabase(userData)) {
|
||||
is Response.Success -> {
|
||||
fireBaseBulkUpload.postValue("Success")
|
||||
updateLocalFlag(userData._id)
|
||||
}
|
||||
|
||||
else -> {
|
||||
fireBaseBulkUpload.postValue("Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.updateFieldById(id = userId, true)
|
||||
}
|
||||
|
||||
fun updateMolbioFlag(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.updateMolbioFlag(id = userId, true)
|
||||
}
|
||||
|
||||
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
||||
hemoCubeDao.insertAll(userData)
|
||||
}
|
||||
|
||||
fun deleteById(userId: String) = viewModelScope.launch {
|
||||
hemoCubeDao.deleteById(id = userId)
|
||||
}
|
||||
|
||||
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)
|
||||
level * 100 / scale.toFloat()
|
||||
}
|
||||
|
||||
return batteryPct
|
||||
}
|
||||
|
||||
fun getBatteryTemperature(): Float? {
|
||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||
val temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)
|
||||
temperature.toFloat() / 10
|
||||
}
|
||||
|
||||
return batteryTemp
|
||||
}
|
||||
|
||||
fun getBatteryVoltage(context: Context): Float {
|
||||
val batteryIntent =
|
||||
context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||
val voltage = batteryIntent?.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0) ?: 0
|
||||
|
||||
// milli-volts to volts
|
||||
return voltage.toFloat() / 1000
|
||||
}
|
||||
|
||||
fun getBatteryCapacity(context: Context): Int {
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
}
|
||||
|
||||
fun getBatteryMaxCapacity(context: Context): Float {
|
||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||
val currentCapacity =
|
||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||
|
||||
// Calculate the estimated maximum battery capacity in mAh
|
||||
|
||||
return currentCapacity.toFloat() / designCapacity.toFloat() * 100
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
@@ -72,6 +73,12 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
viewModel.isServiceConnected = false
|
||||
}
|
||||
}
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||
LanguageManager.setLocale(newBase, languageCode)
|
||||
super.attachBaseContext(newBase)
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -34,7 +34,7 @@ class UsbService : Service() {
|
||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||
mPort.open(connection)
|
||||
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||
isUsbConnected = true
|
||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.hpostesting.util
|
||||
|
||||
import android.content.res.AssetManager
|
||||
import com.example.hpostesting.data.api.PropertyProvider
|
||||
import java.io.InputStream
|
||||
import java.util.Properties
|
||||
|
||||
class PropertyProviderImpl (private val assetManager: AssetManager) : PropertyProvider {
|
||||
override fun getProperty(key: String): String {
|
||||
val inputStream: InputStream = assetManager.open("app.properties")
|
||||
val properties = Properties()
|
||||
properties.load(inputStream)
|
||||
return properties.getProperty(key)
|
||||
}
|
||||
}
|
||||
@@ -31,17 +31,17 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_subtitle3"-->
|
||||
<!-- style="@style/title2"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginHorizontal="24dp"-->
|
||||
<!-- android:layout_marginTop="16dp"-->
|
||||
<!-- android:text="@string/step5"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/tv_subtitle3"-->
|
||||
<!-- style="@style/title2"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginHorizontal="24dp"-->
|
||||
<!-- android:layout_marginTop="16dp"-->
|
||||
<!-- android:text="@string/step5"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
@@ -147,8 +147,35 @@
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toEndOf="@id/et_abha_id"
|
||||
app:layout_constraintTop_toTopOf="@id/et_abha_id" />
|
||||
<Button
|
||||
android:visibility="gone"
|
||||
android:id="@+id/btn_samplestart"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/Start_Sample"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_placebuffer" />
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_placebuffer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/place_buffer"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||
|
||||
<Button
|
||||
android:visibility="gone"
|
||||
android:id="@+id/btn_submit"
|
||||
@@ -168,72 +195,44 @@
|
||||
style="@style/title1_1"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="172dp"
|
||||
android:layout_marginTop="72dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="18sp"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||
|
||||
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
||||
<!-- android:id="@+id/til_blood_group"-->
|
||||
<!-- style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginHorizontal="24dp"-->
|
||||
<!-- android:layout_marginTop="16dp"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">-->
|
||||
|
||||
<!-- <AutoCompleteTextView-->
|
||||
<!-- android:id="@+id/et_blood_group"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:hint="@string/select_blood_group"-->
|
||||
<!-- android:inputType="none"-->
|
||||
<!-- android:labelFor="@id/til_blood_group"-->
|
||||
<!-- app:simpleItems="@array/blood_group" />-->
|
||||
|
||||
<!-- </com.google.android.material.textfield.TextInputLayout>-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_kit"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_margin="10dp"-->
|
||||
<!-- android:text="@string/new_kit"-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_buffer"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="@string/new_buffer"-->
|
||||
<!-- android:textColor="@color/white"-->
|
||||
<!-- android:layout_margin="10dp"-->
|
||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||
<!-- app:layout_constraintEnd_toStartOf="@id/btn_kit"/>-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btn_read"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="@string/read"-->
|
||||
<!-- android:layout_margin="16dp"-->
|
||||
<!-- android:clickable="false"-->
|
||||
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||
|
||||
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||
<TextView
|
||||
android:id="@+id/tv_device_messages"
|
||||
style="@style/title1_1"
|
||||
android:visibility="gone"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="180dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="72dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="11sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||
|
||||
<Button
|
||||
android:visibility="gone"
|
||||
android:id="@+id/btn_digitalCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="DigitalCard View"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -249,5 +248,5 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
</layout>
|
||||
|
||||
|
||||
@@ -1,36 +1,9 @@
|
||||
<!-- SlideshowFragment layout -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
||||
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:id="@+id/text_slideshow"
|
||||
style="@style/title1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="24dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:text="@string/to_be_launched_in_next_version_of_the_app"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<!-- Language Settings -->
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/text_slideshow"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
|
||||
|
||||
</FrameLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -48,20 +48,6 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/userID"
|
||||
tools:text="UserID: MohamedKaif" />
|
||||
<TextView
|
||||
android:id="@+id/teststatus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/title1_1"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
||||
tools:text="Test Status: Completed"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
@@ -75,8 +61,9 @@
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/teststatus"
|
||||
tools:text="startedAt: yyyy-MM-dd HH:mm:ss" />
|
||||
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
||||
tools:text="Test Status: Completed" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -255,5 +255,9 @@
|
||||
<string name="place_sample">सैम्पल रखें</string>
|
||||
<string name="invalid">अमान्य</string>
|
||||
<string name="error">त्रुटि</string>
|
||||
|
||||
<string name="language_update">भाषा सफलतापूर्वक अपडेट की गई है</string>
|
||||
<string name="select_language">अपनी पसंदीदा भाषा का चयन करें</string>
|
||||
<string name="app_language">ऐप भाषा</string>
|
||||
<string name="add_blood_group">रक्त समूह जोड़ें</string>
|
||||
<string name="ok">ठीक है</string>
|
||||
</resources>
|
||||
@@ -255,5 +255,11 @@
|
||||
<string name="place_sample">ನಮೂನೆ ಇಟ್ಟುಕೊಳ್ಳಿ</string>
|
||||
<string name="invalid">ಅಮಾನ್ಯ</string>
|
||||
<string name="error">ದೋಷ</string>
|
||||
<string name="language_update">ಭಾಷೆ ಯಶಸ್ವಿಯಾಗಿ ನವೀಕರಿಸಲಾಗಿದೆ</string>
|
||||
<string name="select_language">ನಿಮ್ಮ ಆದರಿತ ಭಾಷೆಯನ್ನು ಆಯ್ಕೆ ಮಾಡಿ</string>
|
||||
<string name="app_language">ಅಪ್ಲಿಕೇಶನ್ ಭಾಷೆ</string>
|
||||
<string name="add_blood_group">ರಕ್ತ ಗುಂಡನ್ನು ಸೇರಿಸಿ</string>
|
||||
<string name="ok">ಸರಿ</string>
|
||||
<!-- Add translations for other strings -->
|
||||
|
||||
</resources>
|
||||
@@ -9,6 +9,8 @@
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="gray">#808080</color>
|
||||
|
||||
<color name="brightGreen">#00FF00</color>
|
||||
<color name="red">#FF0000</color>
|
||||
<color name="blue_app">#4daaff</color>
|
||||
<color name="blue_app_dark">#005db3</color>
|
||||
<color name="blue_app_light">#e5f3ff</color>
|
||||
@@ -17,7 +19,7 @@
|
||||
<color name="primary">#4daaff</color>
|
||||
<color name="primary_dark">#005db3</color>
|
||||
<color name="primary_light">#e5f3ff</color>
|
||||
<color name="red">#FF0000</color>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
<string name="is_patient_married_yes_no">Is Patient Married? (Yes/No)</string>
|
||||
<string name="category">Category</string>
|
||||
<string name="blood_group">Blood Group</string>
|
||||
<string name="add_blood_group">Add Blood Group</string>
|
||||
<string name="digital_card">Digital Counselling Card</string>
|
||||
<string name="patient_medical_records">Patient Medical Records</string>
|
||||
<string name="patient_address_details">Patient Address Details</string>
|
||||
@@ -231,6 +232,7 @@
|
||||
<string name="permission_grant">You must grant permission to access all files to use the app</string>
|
||||
<string name="permission_required">All permissions are required to use the app.</string>
|
||||
<string name="device_not">Device Not Connected.</string>
|
||||
<string name="device">Device is Connected.</string>
|
||||
<string name="enter_proper_login_id">Please enter a proper Login ID</string>
|
||||
<string name="enter_proper_password">Please enter a proper password</string>
|
||||
<string name="wrong_password">Wrong Password</string>
|
||||
@@ -255,5 +257,8 @@
|
||||
<string name="place_sample">Place Sample</string>
|
||||
<string name="invalid">Invalid</string>
|
||||
<string name="error">Error</string>
|
||||
|
||||
<string name="language_update">Language updated successfully</string>
|
||||
<string name="select_language">Select your preferred language</string>
|
||||
<string name="app_language">App Language</string>
|
||||
<string name="ok">OK</string>
|
||||
</resources>
|
||||
@@ -9,7 +9,7 @@
|
||||
<!-- <usb-device vendor-id="1027" product-id="24592" /> <!– 0x6010: FT2232H –>-->
|
||||
<!-- <usb-device vendor-id="1027" product-id="24593" /> <!– 0x6011: FT4232H –>-->
|
||||
<!-- <usb-device vendor-id="1027" product-id="24596" /> <!– 0x6014: FT232H –>-->
|
||||
<usb-device vendor-id="1027" product-id="24597" /> <!-- 0x6015: FT230X, FT231X, FT234XD -->
|
||||
<usb-device vendor-id="1027" product-id="24577" /> <!-- 0x6015: FT230X, FT231X, FT234XD -->
|
||||
<usb-device vendor-id="6790" product-id="29987" /> <!-- 0x6015: FT230X, FT231X, FT234XD -->
|
||||
|
||||
<!-- 0x10C4 / 0xEA??: Silabs CP210x -->
|
||||
|
||||
Reference in New Issue
Block a user