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">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@@ -14,6 +13,7 @@
|
|||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="resolveExternalAnnotations" value="false" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ android {
|
|||||||
compileSdk 34
|
compileSdk 34
|
||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
// prod - production, preprod - preproduction, quality - qc,
|
// prod - production, preprod - preproduction, quality - qc
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting"
|
applicationId "in.sminnovations.hpostesting"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 44
|
versionCode 56
|
||||||
versionName "2.1.44"
|
versionName "2.1.56"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.12.0'
|
implementation 'androidx.core:core-ktx:1.12.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
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.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.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("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 '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
|
// Testing
|
||||||
@@ -97,13 +100,13 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
|
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 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
||||||
|
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
|
|
||||||
// CSV read, write
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
implementation 'com.opencsv:opencsv:5.5'
|
||||||
|
|
||||||
// Barcode scanner
|
// Barcode scanner
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
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'
|
implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
|
||||||
|
|
||||||
//Room
|
//Room
|
||||||
implementation "androidx.room:room-ktx:2.6.0"
|
implementation "androidx.room:room-ktx:2.6.1"
|
||||||
implementation "androidx.room:room-runtime:2.6.0"
|
implementation "androidx.room:room-runtime:2.6.1"
|
||||||
kapt ("androidx.room:room-compiler:2.6.0")
|
kapt ("androidx.room:room-compiler:2.6.1")
|
||||||
|
|
||||||
//image
|
//image
|
||||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||||
|
|
||||||
// Navigation Component
|
// Navigation Component
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.5"
|
implementation "androidx.navigation:navigation-fragment-ktx:2.7.6"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.5"
|
implementation "androidx.navigation:navigation-ui-ktx:2.7.6"
|
||||||
|
|
||||||
//Dagger - Hilt
|
//Dagger - Hilt
|
||||||
implementation "com.google.dagger:hilt-android:2.46"
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
@@ -132,5 +135,12 @@ dependencies {
|
|||||||
// Retrofit + GSON
|
// Retrofit + GSON
|
||||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
implementation "com.squareup.retrofit2:converter-gson: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 ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
||||||
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.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 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 WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
||||||
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
||||||
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
||||||
@@ -29,6 +43,8 @@ object Constants {
|
|||||||
const val DEVICE_VENDOR_ID = 1027
|
const val DEVICE_VENDOR_ID = 1027
|
||||||
const val HOMO_CUBE_ID = 29987
|
const val HOMO_CUBE_ID = 29987
|
||||||
const val VENDOR_ID = 6790
|
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_NORMAL = 400
|
||||||
const val ERROR_CRITICAL = 401
|
const val ERROR_CRITICAL = 401
|
||||||
@@ -38,6 +54,7 @@ object Constants {
|
|||||||
const val USER_ID = "usernameId"
|
const val USER_ID = "usernameId"
|
||||||
|
|
||||||
val STATICID = listOf(
|
val STATICID = listOf(
|
||||||
|
"ADMIN",
|
||||||
"VIZ-1000-0004",
|
"VIZ-1000-0004",
|
||||||
"VIZ-1000-0005",
|
"VIZ-1000-0005",
|
||||||
"VIZ-1000-0006",
|
"VIZ-1000-0006",
|
||||||
@@ -63,6 +80,14 @@ object Constants {
|
|||||||
"HC-V1-020",
|
"HC-V1-020",
|
||||||
"HCV-000-3001",
|
"HCV-000-3001",
|
||||||
"HCV-000-3002",
|
"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"
|
const val password = "SMI@12345"
|
||||||
@@ -78,6 +103,19 @@ object Constants {
|
|||||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||||
const val BUFFER_LED_UPPER_BOUND = 24500
|
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>>>(
|
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
||||||
"HCV-000-3001" to listOf(
|
"HCV-000-3001" to listOf(
|
||||||
listOf(1.313, -0.89), // LED1, 435nm
|
listOf(1.313, -0.89), // LED1, 435nm
|
||||||
@@ -91,10 +129,59 @@ object Constants {
|
|||||||
listOf(0.1964, 0.011565), // LED3, 555nm
|
listOf(0.1964, 0.011565), // LED3, 555nm
|
||||||
listOf(1.0, 0.0) // LED4
|
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_MIN = 0
|
||||||
const val INCUBATION_TIME_MAX = 1400
|
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>>>(
|
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
||||||
"HCV-000-3001" to listOf(
|
"HCV-000-3001" to listOf(
|
||||||
@@ -108,15 +195,54 @@ object Constants {
|
|||||||
listOf(24500, 26250),
|
listOf(24500, 26250),
|
||||||
listOf(24500, 26250),
|
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")
|
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
||||||
suspend fun updateFieldById(id: String, newValue: Boolean)
|
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 com.google.android.datatransport.runtime.dagger.Provides
|
||||||
import javax.inject.Singleton
|
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)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
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 batteryMaxCapacity: String = "",
|
||||||
var batteryTemperature: String = "",
|
var batteryTemperature: String = "",
|
||||||
var batteryVoltage: 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
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.net.Uri
|
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.PendingUploads
|
||||||
import com.example.hpostesting.data.model.Response
|
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.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.BufferCheckData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
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.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.storage.ktx.storage
|
import com.google.firebase.storage.ktx.storage
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
import okhttp3.ResponseBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.net.ConnectException
|
||||||
|
import java.net.SocketTimeoutException
|
||||||
import javax.inject.Inject
|
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 db: FirebaseFirestore = Firebase.firestore
|
||||||
private val storage = Firebase.storage
|
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> {
|
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
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()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.collection("testData").add(data!!).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data!!._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
}
|
}
|
||||||
@@ -39,14 +99,15 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
|
|
||||||
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
||||||
return try {
|
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()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.collection("testData").add(data!!).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data!!._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
@@ -56,7 +117,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("buffers").add(data!!).await()
|
db.collection("buffers").add(data!!).await()
|
||||||
Response.Success(data!!.kitno)
|
Response.Success(data.kitno)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
@@ -66,14 +127,16 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
db.collection("diagnostics").add(data!!).await()
|
db.collection("diagnostics").add(data!!).await()
|
||||||
Response.Success(data!!.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
Response.Error(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 {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
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.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.res.AssetManager
|
||||||
import androidx.room.Room
|
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.HemoCubeDao
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
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.DatabaseRepository
|
||||||
import com.example.hpostesting.data.repository.LocalFileRepository
|
import com.example.hpostesting.data.repository.LocalFileRepository
|
||||||
import com.example.hpostesting.data.repository.Repository
|
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.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
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
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@@ -28,9 +41,7 @@ object AppModule {
|
|||||||
fun provideMyDatabase(@ApplicationContext context: Context): MyDatabase {
|
fun provideMyDatabase(@ApplicationContext context: Context): MyDatabase {
|
||||||
return Room.databaseBuilder(
|
return Room.databaseBuilder(
|
||||||
context, MyDatabase::class.java, "my_database"
|
context, MyDatabase::class.java, "my_database"
|
||||||
)
|
).fallbackToDestructiveMigration().build()
|
||||||
.fallbackToDestructiveMigration()
|
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -67,13 +78,89 @@ object AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideDatabaseRepository(): DatabaseRepository {
|
fun provideDatabaseRepository(
|
||||||
return DatabaseRepository()
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
|
molbioResultApi: MolbioResultApi
|
||||||
|
): DatabaseRepository {
|
||||||
|
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRepository(): Repository {
|
fun provideRepository(
|
||||||
return DatabaseRepository()
|
@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 androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.hemocube.HemocubeActivity
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
@@ -44,6 +45,12 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
binding.nameEditText.setText(contents)
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.patient.UserData
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.google.android.gms.location.*
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
@@ -97,6 +104,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val deviceType = when {
|
val deviceType = when {
|
||||||
availableDrivers.isNotEmpty() -> {
|
availableDrivers.isNotEmpty() -> {
|
||||||
val device = availableDrivers[0].device
|
val device = availableDrivers[0].device
|
||||||
|
Toast.makeText(this, R.string.device, Toast.LENGTH_SHORT).show()
|
||||||
when {
|
when {
|
||||||
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
@@ -107,6 +115,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Constants.DEVICE_TYPE_HOMOCUBE
|
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 -> {
|
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
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 com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@@ -14,6 +15,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
@@ -32,6 +34,12 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private var allPermissionsGranted = false
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivitySplashBinding.inflate(layoutInflater)
|
binding = ActivitySplashBinding.inflate(layoutInflater)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation.adapter
|
package com.example.hpostesting.presentation.adapter
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -28,9 +26,7 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
||||||
|
|
||||||
inner class OfflineUserListViewHolder(val binding: OfflineUserListViewBinding) :
|
inner class OfflineUserListViewHolder(val binding: OfflineUserListViewBinding) :
|
||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
||||||
override fun areItemsTheSame(
|
override fun areItemsTheSame(
|
||||||
@@ -58,58 +54,61 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
return differ.currentList.size
|
return differ.currentList.size
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
||||||
val userList = differ.currentList[position]
|
val userList = differ.currentList[position]
|
||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
userID.text = "User ID: ${userList._id}"
|
userID.text = "User ID: ${userList._id}"
|
||||||
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
||||||
time.text = "Time: ${isBetween15And30Minutes(userList.incubationTime)} \n Started at: ${
|
time.text = "Time: ${userList.incubationTime}"
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
userCard.setOnClickListener {
|
userCard.setOnClickListener {
|
||||||
if (batLevel < 40) {
|
if (batLevel < 40) {
|
||||||
showWarningToast(R.string.low_battery_warning)
|
Toast.makeText(
|
||||||
} else {
|
view.context,
|
||||||
if (userList.testStatus != null) {
|
context?.getString(R.string.low_battery_warning),
|
||||||
if (userList.testStatus!!) {
|
Toast.LENGTH_SHORT
|
||||||
showWarningToast(R.string.test_already_conducted)
|
).show()
|
||||||
} else {
|
return@setOnClickListener
|
||||||
if (userList.incubationTime != "") {
|
}
|
||||||
val incubationTimeDiff = isBetween15And30Minutes(userList.incubationTime)
|
if (userList.testStatus != null) {
|
||||||
if (incubationTimeDiff < 15) {
|
if (userList.testStatus!!) {
|
||||||
showWarningToast(R.string.incubation_not_completed)
|
Toast.makeText(
|
||||||
} else if (incubationTimeDiff > 30) {
|
view.context,
|
||||||
showWarningToast(R.string.incubation_crossed_30_minutes)
|
context?.getString(R.string.test_already_conducted),
|
||||||
} else {
|
Toast.LENGTH_SHORT
|
||||||
DataHolder.selectedTest = UserData(
|
).show()
|
||||||
_id = userList._id,
|
} else {
|
||||||
bloodGroup = userList.bloodGroup,
|
if (userList.incubationTime != "") {
|
||||||
incubationTime = userList.incubationTime
|
if (isBetween15And30Minutes(userList.incubationTime) < Constants.INCUBATION_TIME_MIN) {
|
||||||
)
|
Toast.makeText(
|
||||||
view.findNavController()
|
view.context,
|
||||||
.navigate(R.id.action_nav_home_to_mainActivity)
|
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 {
|
} 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)
|
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.ContextCompat.getSystemService
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
|
||||||
@@ -94,13 +95,13 @@ class UserListAdapter(
|
|||||||
|
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
.setView(dialogView)
|
.setView(dialogView)
|
||||||
.setTitle("Add Blood Group")
|
.setTitle(R.string.blood_group)
|
||||||
|
|
||||||
val etBloodGroup = dialogView.findViewById<AutoCompleteTextView>(R.id.et_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()
|
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) {
|
if (view != null) {
|
||||||
etBloodGroup.error =view.context.getString(R.string.blood_group_error)
|
etBloodGroup.error =view.context.getString(R.string.blood_group_error)
|
||||||
}
|
}
|
||||||
@@ -166,7 +167,7 @@ class UserListAdapter(
|
|||||||
// Handle the selected blood group here
|
// Handle the selected blood group here
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setNegativeButton("Cancel") { dialog, which ->
|
builder.setNegativeButton(R.string.cancel) { dialog, which ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ class UserListAdapter(
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
userCard.setOnClickListener {
|
userCard.setOnClickListener {
|
||||||
if (batLevel < 40) {
|
if (false) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
view.context,
|
view.context,
|
||||||
context?.getString(R.string.low_battery_warning),
|
context?.getString(R.string.low_battery_warning),
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -10,7 +12,12 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||||||
import androidx.navigation.ui.navigateUp
|
import androidx.navigation.ui.navigateUp
|
||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
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.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.FirebaseAppDistribution
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
@@ -18,11 +25,22 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
|
|
||||||
|
open interface IDataCollector {
|
||||||
|
fun setConnect(connect: Boolean)
|
||||||
|
fun setResponse(response: String)
|
||||||
|
}
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity() {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
|
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
private lateinit var binding: ActivityDashboardBinding
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -30,6 +48,9 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
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 drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
val navView: NavigationView = binding.navView
|
val navView: NavigationView = binding.navView
|
||||||
@@ -95,4 +116,16 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
|
// 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.content.SharedPreferences
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Base64
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -16,9 +17,13 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.DataHolder
|
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.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.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
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.KitScanActivity
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
@@ -33,6 +38,7 @@ import com.google.firebase.perf.ktx.performance
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
|
import org.json.JSONObject
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -98,6 +104,7 @@ class HomeFragment : Fragment() {
|
|||||||
loadUserData()
|
loadUserData()
|
||||||
setSearch()
|
setSearch()
|
||||||
checkForLocalDBData()
|
checkForLocalDBData()
|
||||||
|
checkForTokenAndUpdate()
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
@@ -107,9 +114,7 @@ class HomeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||||
R.string.test_upload,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
if (result == "Error") {
|
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() {
|
private fun setUserId() {
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
val userId = binding.userId.text.toString()
|
val userId = binding.userId.text.toString()
|
||||||
val bloodGroup = binding.etBloodGroup.text
|
val bloodGroup = binding.etBloodGroup.text
|
||||||
|
|
||||||
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
||||||
hemoCubeViewModel.addUser(
|
hemoCubeViewModel.addUser(
|
||||||
HemoCubeTestData(
|
HemoCubeTestData(
|
||||||
_id = userId, bloodGroup = bloodGroup.toString(), incubationTime = SimpleDateFormat(
|
_id = userId,
|
||||||
|
bloodGroup = bloodGroup.toString(),
|
||||||
|
incubationTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time).toString()
|
).format(Calendar.getInstance().time).toString()
|
||||||
)
|
)
|
||||||
@@ -163,10 +293,10 @@ class HomeFragment : Fragment() {
|
|||||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||||
val currentDate = Date()
|
val currentDate = Date()
|
||||||
val formattedDate = dateFormat.format(currentDate)
|
val formattedDate = dateFormat.format(currentDate)
|
||||||
// val query = Firebase.firestore.collection("patientData")
|
val query = Firebase.firestore.collection("patientData")
|
||||||
// .whereGreaterThanOrEqualTo("createdAt", formattedDate)
|
.whereGreaterThanOrEqualTo("createdAt", formattedDate)
|
||||||
// .orderBy("createdAt", Query.Direction.DESCENDING)
|
.orderBy("createdAt", Query.Direction.DESCENDING)
|
||||||
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
||||||
query.get().addOnSuccessListener {
|
query.get().addOnSuccessListener {
|
||||||
if (it.documents.isEmpty()) {
|
if (it.documents.isEmpty()) {
|
||||||
binding.pendingTest.visibility = View.VISIBLE
|
binding.pendingTest.visibility = View.VISIBLE
|
||||||
@@ -183,8 +313,12 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(
|
||||||
requireContext(), hemoCubeViewModel, recyclerViewOptions,
|
requireContext(),
|
||||||
it, batLevel, requireActivity()
|
hemoCubeViewModel,
|
||||||
|
recyclerViewOptions,
|
||||||
|
it,
|
||||||
|
batLevel,
|
||||||
|
requireActivity()
|
||||||
)
|
)
|
||||||
}!!
|
}!!
|
||||||
binding.rvOrder.adapter = rvAdapter
|
binding.rvOrder.adapter = rvAdapter
|
||||||
@@ -309,7 +443,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val uploadDataVisibility =
|
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
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,66 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.widget.Toast
|
||||||
import android.view.View
|
import androidx.preference.ListPreference
|
||||||
import android.view.ViewGroup
|
import androidx.preference.Preference
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.ui.slideshow.SlideshowViewModel
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
private var isLanguageChanged = false
|
||||||
|
|
||||||
class SlideshowFragment : Fragment() {
|
class SlideshowFragment : PreferenceFragmentCompat() {
|
||||||
private var _binding: FragmentSlideshowBinding? = null
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
val languagePreference = ListPreference(requireContext())
|
||||||
// onDestroyView.
|
languagePreference.key = "language_preference"
|
||||||
private val binding get() = _binding!!
|
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(
|
languagePreference.onPreferenceChangeListener =
|
||||||
inflater: LayoutInflater,
|
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
container: ViewGroup?,
|
val languageCode = newValue as String
|
||||||
savedInstanceState: Bundle?,
|
updateLanguage(requireContext(), languageCode)
|
||||||
): View {
|
true
|
||||||
val slideshowViewModel =
|
}
|
||||||
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
|
||||||
|
|
||||||
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
preferenceScreen.addPreference(languagePreference)
|
||||||
val root: View = binding.root
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
// App Version Preference
|
||||||
requireActivity().packageName, 0
|
val appVersionPreference = Preference(requireContext())
|
||||||
)
|
appVersionPreference.title = "App Version"
|
||||||
val version = pInfo.versionName
|
appVersionPreference.summary = getAppVersion(requireContext())
|
||||||
binding.textSlideshow.text = version
|
|
||||||
|
|
||||||
// val textView: TextView = binding.textSlideshow
|
preferenceScreen.addPreference(languagePreference)
|
||||||
// slideshowViewModel.text.observe(viewLifecycleOwner) {
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
// textView.text = it
|
setPreferenceScreen(preferenceScreen)
|
||||||
// }
|
|
||||||
return root
|
if (isLanguageChanged) {
|
||||||
|
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
private fun updateLanguage(context: Context, languageCode: String) {
|
||||||
super.onDestroyView()
|
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||||
_binding = null
|
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?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
_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
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.HemoCubeFragment
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityDiagnosticsBinding.inflate(layoutInflater)
|
binding = ActivityDiagnosticsBinding.inflate(layoutInflater)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import android.os.IBinder
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -21,8 +22,15 @@ import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
|
|
||||||
class DigitalCardActivity : AppCompatActivity() {
|
class DigitalCardActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityDigitalCardBinding
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityDigitalCardBinding.inflate(layoutInflater)
|
binding = ActivityDigitalCardBinding.inflate(layoutInflater)
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ import android.content.Intent
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpostesting.data.DataHolder
|
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.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
@@ -34,16 +35,31 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
private var isOnline = false
|
private var isOnline = false
|
||||||
private var currentDeviceData: DeviceData? = null
|
private var currentDeviceData: DeviceData? = null
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
private var deviceSerialNo: String = ""
|
|
||||||
private var coefficient: String? = ""
|
|
||||||
private var isUsingExistingBuffer = false
|
private var isUsingExistingBuffer = false
|
||||||
private var isTestOngoing = false
|
private var isTestOngoing = false
|
||||||
private var startListening = MutableLiveData<Boolean>(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(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
@@ -57,8 +73,9 @@ class HemoCubeFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
|
listenToHemoCube()
|
||||||
|
getDeviceInfo()
|
||||||
observeViewModel()
|
observeViewModel()
|
||||||
checkAndStartProcess()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
@@ -70,11 +87,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
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.tvTitle2.visibility = View.GONE
|
||||||
binding.etAbhaId.visibility = View.GONE
|
binding.etAbhaId.visibility = View.GONE
|
||||||
@@ -83,27 +95,80 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.btnGo.visibility = View.GONE
|
binding.btnGo.visibility = View.GONE
|
||||||
// binding.btnSubmit.isEnabled = false
|
// binding.btnSubmit.isEnabled = false
|
||||||
// binding.btnSubmit.isClickable = false
|
// binding.btnSubmit.isClickable = false
|
||||||
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
|
|
||||||
binding.tvName.text = "Name: ${testDetails?.name}\n ID: ${testDetails?._id}"
|
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() {
|
private fun observeViewModel() {
|
||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
showToast("Test Results Uploaded Successfully")
|
showToast(R.string.test_upload)
|
||||||
val i = Intent(
|
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
requireContext().applicationContext, DashboardActivity::class.java
|
when (it) {
|
||||||
)
|
is Result.Success -> {
|
||||||
startActivity(i)
|
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||||
(activity as HemocubeActivity).finish()
|
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") {
|
if (result == "Local") {
|
||||||
showToast("Internet not available, test details stored locally")
|
showToast(R.string.internt_not_local)
|
||||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||||
}
|
}
|
||||||
if (result == "Error") {
|
if (result == "Error") {
|
||||||
showToast("Error uploading data, test details stored locally")
|
showToast(R.string.error_local)
|
||||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,25 +183,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
apply {
|
apply {
|
||||||
// if (isNetworkAvailable) {
|
DataHolder.hemoCubeTestData?.let {
|
||||||
// Online mode
|
currentDeviceData?.coefficients?.let { coefficients ->
|
||||||
DataHolder.hemoCubeTestData?.let {
|
val coefficient1 = coefficients[0]
|
||||||
currentDeviceData?.coefficients?.let { coefficients ->
|
val coefficient2 = coefficients[1]
|
||||||
val coefficient1 = coefficients[0]
|
val result = coefficient1 * coefficient2
|
||||||
val coefficient2 = coefficients[1]
|
|
||||||
val result = coefficient1 * coefficient2
|
|
||||||
// Process result in online mode
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// } 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
|
isOnline = isNetworkAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,51 +197,52 @@ class HemoCubeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
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() {
|
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||||
if (isBufferValueAvailable()) {
|
binding.tvDeviceMessages.text = it
|
||||||
showBufferAlertDialog()
|
|
||||||
} else {
|
|
||||||
listenToHemoCube()
|
|
||||||
startBufferProcess()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkAndStartProcess() {
|
||||||
|
startBufferProcess()
|
||||||
|
}
|
||||||
|
|
||||||
private fun isBufferValueAvailable(): Boolean {
|
private fun isBufferValueAvailable(): Boolean {
|
||||||
return if (sharedPreferences.getString(
|
return try {
|
||||||
Constants.BUFFER_VALUE_1, ""
|
if (sharedPreferences.getString(
|
||||||
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
Constants.BUFFER_VALUE_1, ""
|
||||||
) {
|
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
&& sharedPreferences.getString(Constants.BUFFER_VALUE_3, "") != ""
|
||||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")
|
&& sharedPreferences.getString(Constants.BUFFER_VALUE_4, "") != ""
|
||||||
?.toDouble()!! > 0.0
|
) {
|
||||||
} else {
|
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
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showBufferAlertDialog() {
|
private fun showBufferAlertDialog() {
|
||||||
val title = "WARNING"
|
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 negativeText = getString(R.string.no)
|
||||||
val positiveText = "Yes"
|
val positiveText = getString(R.string.yes)
|
||||||
|
|
||||||
UIUtils.createAlertDialog(requireContext(),
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
title,
|
title,
|
||||||
@@ -197,13 +251,15 @@ class HemoCubeFragment : Fragment() {
|
|||||||
positiveText,
|
positiveText,
|
||||||
object : MyDialogListener {
|
object : MyDialogListener {
|
||||||
override fun onClickNegativeButton() {
|
override fun onClickNegativeButton() {
|
||||||
listenToHemoCube()
|
|
||||||
startBufferProcess()
|
startBufferProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClickPositiveButton() {
|
override fun onClickPositiveButton() {
|
||||||
listenToHemoCube()
|
activity?.runOnUiThread {
|
||||||
startSampleProcess()
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
|
binding.btnSamplestart.visibility = View.VISIBLE
|
||||||
|
binding.tvSubtitle4.text = getString(R.string.place_sample)
|
||||||
|
}
|
||||||
isUsingExistingBuffer = true
|
isUsingExistingBuffer = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -225,7 +281,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
fullReadOutput.append(stringData)
|
fullReadOutput.append(stringData)
|
||||||
handleUsbData(stringData, fullReadOutput)
|
handleUsbData(stringData, testStatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,47 +290,134 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showToast("test is going on")
|
showToast(R.string.test_ongoing)
|
||||||
Firebase.crashlytics.recordException(e)
|
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("#")) {
|
if (stringData.contains("#")) {
|
||||||
hemoCubeViewModel.messages.postValue(stringData)
|
|
||||||
isTestOngoing = true
|
isTestOngoing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData += stringData
|
resultData += stringData
|
||||||
|
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
resultData.contains("SNE") && this.testStatusCode < Constants.TEST_STATUS_CODE_CONFIG_COMPLETED -> {
|
||||||
stringData.contains("#Sample 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()
|
fetchResult()
|
||||||
testingTrace.stop()
|
testingTrace.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("RESULT") || resultData.contains("REND") -> {
|
resultData.contains("REND") && this.testStatusCode < Constants.TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED -> {
|
||||||
var validString: String
|
this.testStatusCode = Constants.TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED
|
||||||
val results: List<String>
|
hemoCubeViewModel.messages.postValue(
|
||||||
if (stringData.contains("RESULT")) {
|
getString(R.string.data_collected_processing_data)
|
||||||
validString = isValidResult(stringData)
|
)
|
||||||
if (validString.isEmpty()) {
|
val resultLines = resultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
results = resultData.split("\n")
|
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
||||||
validString = parseResult(results)
|
led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
}
|
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
||||||
} else {
|
} else {
|
||||||
results = resultData.split("\n")
|
bufferIntensity.toDoubleOrNull()!!
|
||||||
validString = parseResult(results)
|
|
||||||
}
|
}
|
||||||
if (validString.isNotEmpty()) {
|
bufferIntensity = resultLines[2].split(' ')[1].trim()
|
||||||
handleValidResult(validString, resultData)
|
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() {
|
private fun showError() {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
UIUtils.createAlertDialog(requireContext(),
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
@@ -297,166 +440,268 @@ class HemoCubeFragment : Fragment() {
|
|||||||
// If the test is ongoing, don't allow the back button action
|
// 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
|
// You can optionally show a message to the user indicating why the back button is disabled
|
||||||
// For example, show a Toast or Snackbar.
|
// For example, show a Toast or Snackbar.
|
||||||
showToast("Test is ongoing. Cannot go back.")
|
showToast(R.string.test_go_noback)
|
||||||
} else {
|
} else {
|
||||||
// If the test is not ongoing, you can trigger the back action of the hosting activity
|
// If the test is not ongoing, you can trigger the back action of the hosting activity
|
||||||
activity?.onBackPressed()
|
activity?.onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showStartSampleDialog() {
|
private fun processResult() {
|
||||||
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) {
|
|
||||||
try {
|
try {
|
||||||
val result = validString.split(" ")
|
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
||||||
val deviceLog = resultData
|
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) {
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
requireActivity().packageName, 0
|
||||||
// if (deviceRatio < 0.08) {
|
)
|
||||||
// if (deviceRatio > 1.07) {
|
val version = pInfo.versionName
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (led1Average < 0 || led2Average < 0) {
|
val led1Average = log10(led1BufferForDevice.div(led1SampleForDevice))
|
||||||
activity?.runOnUiThread{
|
val led2Average = log10(led2BufferForDevice.div(led2SampleForDevice))
|
||||||
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
val led3Average = log10(led3BufferForDevice.div(led3SampleForDevice))
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
val led4Average = log10(led4BufferForDevice.div(led4SampleForDevice))
|
||||||
}
|
val deviceRatio = led3Average / led1Average
|
||||||
}
|
|
||||||
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)
|
||||||
deviceId = deviceSerialNo
|
?.get(0)!!
|
||||||
led1Buffer = led1BufferForDevice
|
|| led2BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||||
led2Buffer = led2BufferForDevice
|
1
|
||||||
appVersion = version
|
)?.get(0)!!
|
||||||
this.led1Sample = led1Sample
|
|| led3BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||||
this.led2Sample = led2Sample
|
2
|
||||||
this.led1Average = led1Average
|
)?.get(0)!!
|
||||||
this.led2Average = led2Average
|
|| led4BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(
|
||||||
this.deviceRatio = deviceRatio
|
3
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
)?.get(0)!!
|
||||||
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
) {
|
||||||
this.coefficients = coefficientsString
|
validationError = true
|
||||||
this.classificationResult = findResult(calculatedRatio)
|
allErrorMessages += "Error: Invalid Test. Improper buffer reading (low)"
|
||||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
activity?.runOnUiThread {
|
||||||
this.resultData = deviceLog
|
binding.errorMessage.text = getString(R.string.error_improper_buffer_low)
|
||||||
if (!isUsingExistingBuffer) {
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
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(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) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
"Error while processing device data",
|
R.string.error_processing_device_data,
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findResult(calculatedRatio: Double?): String {
|
fun findResult(calculatedRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
if (calculatedRatio != null) {
|
if (calculatedRatio != null) {
|
||||||
if (calculatedRatio < 0.05)
|
if (calculatedRatio < 0.05)
|
||||||
return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
return getString(R.string.error_repeat_test_higher_volume)
|
||||||
if (calculatedRatio in 0.05..0.155)
|
if (calculatedRatio in 0.05..0.155) {
|
||||||
return "Normal"
|
activity?.runOnUiThread {
|
||||||
|
binding.tvSubtitle4.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
requireContext(),
|
||||||
|
R.color.brightGreen
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return getString(R.string.normal)
|
||||||
|
}
|
||||||
if (calculatedRatio in 0.155..0.175)
|
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)
|
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)
|
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)
|
if (calculatedRatio in 0.25..0.35)
|
||||||
return "Sickle Cell Disease"
|
return getString(R.string.sickle_cell_disease)
|
||||||
if (calculatedRatio > 0.35)
|
if (calculatedRatio > 0.35)
|
||||||
return "Inconclusive. Repeat with test with lower volume of blood"
|
return getString(R.string.error_repeat_test_lower_volume)
|
||||||
} else {
|
} else {
|
||||||
return "NULL"
|
return getString(R.string.invalid)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showToast("error while performing classification")
|
showToast(R.string.error_classification)
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
return "ERROR"
|
return getString(R.string.error)
|
||||||
}
|
}
|
||||||
return "NULL"
|
return getString(R.string.invalid)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
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() {
|
private fun startBufferProcess() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startBuffer,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startBuffer,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -495,35 +740,11 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateRatio(ratio: Double): Double {
|
private fun calculateRatio(ratio: Double): Double {
|
||||||
val coefficient1: Double = (Constants.COEFFICIENTS[deviceSerialNo]?.get(0) ?: 0.0) as Double
|
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||||
val coefficient2: Double = (Constants.COEFFICIENTS[deviceSerialNo]?.get(1) ?: 0.0) as Double
|
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||||
return coefficient1 * ratio + coefficient2
|
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 {
|
private fun checkDeviceIdMismatch(deviceId: String, loginId: String): Boolean {
|
||||||
if (!deviceId.isNullOrEmpty() && !loginId.isNullOrEmpty() && deviceId.last() != loginId.last())
|
if (!deviceId.isNullOrEmpty() && !loginId.isNullOrEmpty() && deviceId.last() != loginId.last())
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,283 +1,394 @@
|
|||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.lifecycle.AndroidViewModel
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
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.DataHolder
|
||||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.model.Response
|
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.BufferCheckData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
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.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.DatabaseRepository
|
||||||
import com.example.hpostesting.data.repository.Repository
|
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 dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
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.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class HemoCubeViewModel @Inject constructor(
|
class HemoCubeViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
context: Context,
|
private val databaseRepository: DatabaseRepository,
|
||||||
|
private val logFileManager: LogFileManager,
|
||||||
|
context: Context
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference: SharedPreferences =
|
private val sharedPreference: SharedPreferences =
|
||||||
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
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)
|
// init {
|
||||||
val allUserData = hemoCubeDao.getAll()
|
// startPeriodicCheckUpdate()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
// }
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
|
||||||
get() = _networkStatusLiveData
|
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
|
||||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
|
||||||
|
|
||||||
private val batteryStatus: Intent? =
|
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
||||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
|
||||||
context.registerReceiver(null, ifilter)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabase(
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
isOnline: Boolean,
|
|
||||||
testStatus: Boolean,
|
|
||||||
kitSerial: String?
|
|
||||||
) =
|
|
||||||
viewModelScope.launch {
|
|
||||||
if (kitSerial != null) {
|
|
||||||
testDetails?.kitSerial = kitSerial
|
|
||||||
}
|
|
||||||
testDetails?.testStatus = testStatus
|
|
||||||
|
|
||||||
try {
|
val resultUpload = MutableLiveData<Result<MolbioV2ResultResponse>>()
|
||||||
if (isOnline) {
|
|
||||||
parseData()
|
val checkUpdate = MutableLiveData<Result<CheckUpdateResponse>>()
|
||||||
addResultTestToDb()
|
|
||||||
} else {
|
val deviceUpdate = MutableLiveData<Result<ResponseBody>>()
|
||||||
parseData()
|
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
||||||
"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}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
viewModelScope.launch {
|
|
||||||
addResultTestToDbforbuffercheck(bufferCheckData)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
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() {
|
fun uploadHemoCubeResultToDatabase(
|
||||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
isOnline: Boolean, testStatus: Boolean, kitSerial: String?
|
||||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
) = viewModelScope.launch {
|
||||||
testDetails?.location = DataHolder.location
|
if (kitSerial != null) {
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
testDetails?.kitSerial = kitSerial
|
||||||
"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()
|
|
||||||
}
|
}
|
||||||
|
testDetails?.testStatus = testStatus
|
||||||
|
|
||||||
private fun addResultTestToDb() {
|
try {
|
||||||
viewModelScope.launch {
|
if (isOnline) {
|
||||||
try {
|
parseData()
|
||||||
testDetails!!.reportUploadTime = SimpleDateFormat(
|
addResultTestToDb()
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
} else {
|
||||||
).format(Calendar.getInstance().time)
|
parseData()
|
||||||
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
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(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
hemoCubeDao.insertAll(testDetails!!)
|
||||||
is Response.Success -> {
|
fireBaseUpload.postValue("Local")
|
||||||
fireBaseBulkUpload.postValue("Success")
|
}
|
||||||
updateLocalFlag(userData._id)
|
} catch (e: Exception) {
|
||||||
}
|
Log.e("Testdb", "Upload failed: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest) = viewModelScope.launch {
|
||||||
fireBaseBulkUpload.postValue("Error")
|
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 {
|
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
||||||
hemoCubeDao.updateFieldById(id = userId, true)
|
viewModelScope.launch {
|
||||||
|
addResultTestToDbforbuffercheck(bufferCheckData)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
||||||
hemoCubeDao.insertAll(userData)
|
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteById(userId: String) = viewModelScope.launch {
|
private fun parseData() {
|
||||||
hemoCubeDao.deleteById(id = userId)
|
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? {
|
private fun addResultTestToDb() {
|
||||||
val batteryPct: Float? = batteryStatus?.let { intent ->
|
viewModelScope.launch {
|
||||||
val level: Int = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
|
try {
|
||||||
val scale: Int = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
|
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||||
level * 100 / scale.toFloat()
|
"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 androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -72,6 +73,12 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
viewModel.isServiceConnected = false
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class UsbService : Service() {
|
|||||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||||
mPort.open(connection)
|
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
|
isUsbConnected = true
|
||||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
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_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||||
|
|
||||||
<!-- <TextView-->
|
<!-- <TextView-->
|
||||||
<!-- android:id="@+id/tv_subtitle3"-->
|
<!-- android:id="@+id/tv_subtitle3"-->
|
||||||
<!-- style="@style/title2"-->
|
<!-- style="@style/title2"-->
|
||||||
<!-- android:layout_width="0dp"-->
|
<!-- android:layout_width="0dp"-->
|
||||||
<!-- android:layout_height="wrap_content"-->
|
<!-- android:layout_height="wrap_content"-->
|
||||||
<!-- android:layout_marginHorizontal="24dp"-->
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
<!-- android:layout_marginTop="16dp"-->
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
<!-- android:text="@string/step5"-->
|
<!-- android:text="@string/step5"-->
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_name"
|
android:id="@+id/tv_name"
|
||||||
@@ -147,8 +147,35 @@
|
|||||||
app:layout_constraintHorizontal_bias="1.0"
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
app:layout_constraintStart_toEndOf="@id/et_abha_id"
|
app:layout_constraintStart_toEndOf="@id/et_abha_id"
|
||||||
app:layout_constraintTop_toTopOf="@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
|
<Button
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:id="@+id/btn_submit"
|
android:id="@+id/btn_submit"
|
||||||
@@ -168,72 +195,44 @@
|
|||||||
style="@style/title1_1"
|
style="@style/title1_1"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="80dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="172dp"
|
android:layout_marginTop="72dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/red"
|
android:textColor="@color/red"
|
||||||
android:textSize="18sp"
|
android:textSize="12sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
<TextView
|
||||||
<!-- android:id="@+id/til_blood_group"-->
|
android:id="@+id/tv_device_messages"
|
||||||
<!-- style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"-->
|
style="@style/title1_1"
|
||||||
<!-- android:layout_width="match_parent"-->
|
android:visibility="gone"
|
||||||
<!-- android:layout_height="wrap_content"-->
|
android:layout_width="0dp"
|
||||||
<!-- android:layout_marginHorizontal="24dp"-->
|
android:layout_height="180dp"
|
||||||
<!-- android:layout_marginTop="16dp"-->
|
android:layout_marginHorizontal="24dp"
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
android:layout_marginTop="72dp"
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
android:gravity="center"
|
||||||
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">-->
|
android:textColor="@color/black"
|
||||||
|
android:textSize="11sp"
|
||||||
<!-- <AutoCompleteTextView-->
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
<!-- android:id="@+id/et_blood_group"-->
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
<!-- android:layout_width="match_parent"-->
|
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||||
<!-- 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>-->
|
|
||||||
|
|
||||||
|
<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
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -249,5 +248,5 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,9 @@
|
|||||||
<!-- SlideshowFragment layout -->
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -48,20 +48,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/userID"
|
app:layout_constraintTop_toBottomOf="@id/userID"
|
||||||
tools:text="UserID: MohamedKaif" />
|
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
|
<TextView
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
@@ -75,8 +61,9 @@
|
|||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/teststatus"
|
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
||||||
tools:text="startedAt: yyyy-MM-dd HH:mm:ss" />
|
tools:text="Test Status: Completed" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|||||||
@@ -255,5 +255,9 @@
|
|||||||
<string name="place_sample">सैम्पल रखें</string>
|
<string name="place_sample">सैम्पल रखें</string>
|
||||||
<string name="invalid">अमान्य</string>
|
<string name="invalid">अमान्य</string>
|
||||||
<string name="error">त्रुटि</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>
|
</resources>
|
||||||
@@ -255,5 +255,11 @@
|
|||||||
<string name="place_sample">ನಮೂನೆ ಇಟ್ಟುಕೊಳ್ಳಿ</string>
|
<string name="place_sample">ನಮೂನೆ ಇಟ್ಟುಕೊಳ್ಳಿ</string>
|
||||||
<string name="invalid">ಅಮಾನ್ಯ</string>
|
<string name="invalid">ಅಮಾನ್ಯ</string>
|
||||||
<string name="error">ದೋಷ</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>
|
</resources>
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
<color name="gray">#808080</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">#4daaff</color>
|
||||||
<color name="blue_app_dark">#005db3</color>
|
<color name="blue_app_dark">#005db3</color>
|
||||||
<color name="blue_app_light">#e5f3ff</color>
|
<color name="blue_app_light">#e5f3ff</color>
|
||||||
@@ -17,7 +19,7 @@
|
|||||||
<color name="primary">#4daaff</color>
|
<color name="primary">#4daaff</color>
|
||||||
<color name="primary_dark">#005db3</color>
|
<color name="primary_dark">#005db3</color>
|
||||||
<color name="primary_light">#e5f3ff</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="is_patient_married_yes_no">Is Patient Married? (Yes/No)</string>
|
||||||
<string name="category">Category</string>
|
<string name="category">Category</string>
|
||||||
<string name="blood_group">Blood Group</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="digital_card">Digital Counselling Card</string>
|
||||||
<string name="patient_medical_records">Patient Medical Records</string>
|
<string name="patient_medical_records">Patient Medical Records</string>
|
||||||
<string name="patient_address_details">Patient Address Details</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_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="permission_required">All permissions are required to use the app.</string>
|
||||||
<string name="device_not">Device Not Connected.</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_login_id">Please enter a proper Login ID</string>
|
||||||
<string name="enter_proper_password">Please enter a proper password</string>
|
<string name="enter_proper_password">Please enter a proper password</string>
|
||||||
<string name="wrong_password">Wrong Password</string>
|
<string name="wrong_password">Wrong Password</string>
|
||||||
@@ -255,5 +257,8 @@
|
|||||||
<string name="place_sample">Place Sample</string>
|
<string name="place_sample">Place Sample</string>
|
||||||
<string name="invalid">Invalid</string>
|
<string name="invalid">Invalid</string>
|
||||||
<string name="error">Error</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>
|
</resources>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<!-- <usb-device vendor-id="1027" product-id="24592" /> <!– 0x6010: FT2232H –>-->
|
<!-- <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="24593" /> <!– 0x6011: FT4232H –>-->
|
||||||
<!-- <usb-device vendor-id="1027" product-id="24596" /> <!– 0x6014: FT232H –>-->
|
<!-- <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 -->
|
<usb-device vendor-id="6790" product-id="29987" /> <!-- 0x6015: FT230X, FT231X, FT234XD -->
|
||||||
|
|
||||||
<!-- 0x10C4 / 0xEA??: Silabs CP210x -->
|
<!-- 0x10C4 / 0xEA??: Silabs CP210x -->
|
||||||
|
|||||||
Reference in New Issue
Block a user