Compare commits
2 Commits
DigitalPre
...
HposUnitTe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7f3729dd6 | ||
|
|
a068ae492c |
@@ -14,13 +14,12 @@ android {
|
|||||||
compileSdk 34
|
compileSdk 34
|
||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
// 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 30
|
versionCode 24
|
||||||
versionName "2.1.30"
|
versionName "2.1.24"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -55,10 +54,9 @@ 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.9.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'
|
|
||||||
|
|
||||||
//firebase
|
//firebase
|
||||||
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
||||||
@@ -81,13 +79,8 @@ dependencies {
|
|||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
// Mockito dependencies
|
testImplementation 'org.mockito:mockito-core:3.12.0'
|
||||||
testImplementation 'org.mockito:mockito-core:3.12.4'
|
|
||||||
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
|
|
||||||
androidTestImplementation 'org.mockito:mockito-inline:3.12.4'
|
|
||||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
|
||||||
|
|
||||||
|
|
||||||
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:4.6'
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.BATTERY_STATS"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.camera" />
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
|
||||||
@@ -32,9 +29,6 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.HPOSTesting"
|
android:theme="@style/Theme.HPOSTesting"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardActivity"
|
|
||||||
android:exported="false" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ object Constants {
|
|||||||
"HC-V1-018",
|
"HC-V1-018",
|
||||||
"HC-V1-019",
|
"HC-V1-019",
|
||||||
"HC-V1-020",
|
"HC-V1-020",
|
||||||
"HCV-000-3001",
|
|
||||||
"HCV-000-3002",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const val password = "SMI@12345"
|
const val password = "SMI@12345"
|
||||||
@@ -71,43 +69,5 @@ object Constants {
|
|||||||
const val KIT_COUNT = "KitCount"
|
const val KIT_COUNT = "KitCount"
|
||||||
const val BUFFER_VALUE_1 = "BufferValue1"
|
const val BUFFER_VALUE_1 = "BufferValue1"
|
||||||
const val BUFFER_VALUE_2 = "BufferValue2"
|
const val BUFFER_VALUE_2 = "BufferValue2"
|
||||||
const val BUFFER_VALUE_3 = "BufferValue3"
|
|
||||||
const val BUFFER_VALUE_4 = "BufferValue4"
|
|
||||||
const val DEVICE_ID = "DEVICE_ID"
|
const val DEVICE_ID = "DEVICE_ID"
|
||||||
|
|
||||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
|
||||||
const val BUFFER_LED_UPPER_BOUND = 24500
|
|
||||||
|
|
||||||
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
|
||||||
"HCV-000-3001" to listOf(
|
|
||||||
listOf(1.264817, -0.85965), // LED1, 435nm
|
|
||||||
listOf(0.581462456, -0.58502), // LED2, 415nm
|
|
||||||
listOf(0.184991, 0.001704), // LED3, 555nm
|
|
||||||
listOf(1.0, 0.0) // LED4
|
|
||||||
),
|
|
||||||
"HCV-000-3002" to listOf(
|
|
||||||
listOf(1.264817, -0.85965),
|
|
||||||
listOf(0.581462456, -0.58502),
|
|
||||||
listOf(0.184991, 0.001704),
|
|
||||||
listOf(1.0, 0.0)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
const val INCUBATION_TIME_MIN = 15
|
|
||||||
const val INCUBATION_TIME_MAX = 30
|
|
||||||
|
|
||||||
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
|
||||||
"HCV-000-3001" to listOf(
|
|
||||||
listOf(24000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
),
|
|
||||||
"HCV-000-3002" to listOf(
|
|
||||||
listOf(21000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
listOf(21000, 24500),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
@@ -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 = 9, exportSchema = false)
|
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 3, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
abstract fun userDao(): UserDao
|
||||||
|
|||||||
@@ -8,18 +8,13 @@ data class HemoCubeTestData(
|
|||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
var incubationTime: String = "",
|
|
||||||
var bloodGroup: String = "",
|
|
||||||
var birthYear: String = "",
|
var birthYear: String = "",
|
||||||
var state: String = "",
|
|
||||||
var abhaId: String = "",
|
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
var location: UserData.Location? = null,
|
var location: UserData.Location? = null,
|
||||||
var reportUploadTime: String? = "",
|
var reportUploadTime: String? = "",
|
||||||
var testType: String? = "HEMOCUBE",
|
var testType: String? = "HEMOCUBE",
|
||||||
var testTime: String? = "",
|
var testTime: String? = "",
|
||||||
var testStatus: Boolean? = false,
|
var testStatus: Boolean? = false,
|
||||||
var gender: String = "",
|
|
||||||
var localFlag: Boolean = false,
|
var localFlag: Boolean = false,
|
||||||
var deviceId: String? = "",
|
var deviceId: String? = "",
|
||||||
var appVersion:String? = "",
|
var appVersion:String? = "",
|
||||||
@@ -29,29 +24,12 @@ data class HemoCubeTestData(
|
|||||||
var resultData: String = "",
|
var resultData: String = "",
|
||||||
var led1Buffer: Double? = null,
|
var led1Buffer: Double? = null,
|
||||||
var led2Buffer: Double? = null,
|
var led2Buffer: Double? = null,
|
||||||
var led3Buffer: Double? = null,
|
|
||||||
var led4Buffer: Double? = null,
|
|
||||||
var led1Sample: Double? = null,
|
var led1Sample: Double? = null,
|
||||||
var led2Sample: Double? = null,
|
var led2Sample: Double? = null,
|
||||||
var led3Sample: Double? = null,
|
|
||||||
var led4Sample: Double? = null,
|
|
||||||
var led1Average: Double? = null,
|
var led1Average: Double? = null,
|
||||||
var led2Average: 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 deviceRatio: Double? = null,
|
||||||
var calculatedRatio: Double? = null,
|
var calculatedRatio: Double? = null,
|
||||||
var predictedDenovixRatio: Double? = null,
|
|
||||||
var coefficients: String? = "",
|
var coefficients: String? = "",
|
||||||
var classificationResult: String = "",
|
var classificationResult: String = ""
|
||||||
var prdClassification: String = "",
|
|
||||||
var batteryLevel: String = "",
|
|
||||||
var batteryCapacity: String = "",
|
|
||||||
var batteryMaxCapacity: String = "",
|
|
||||||
var batteryTemperature: String = "",
|
|
||||||
var batteryVoltage: String = "",
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ data class UserData(
|
|||||||
var name: String = "",
|
var name: String = "",
|
||||||
var incubationTime: String = "",
|
var incubationTime: String = "",
|
||||||
var birthYear: String = "",
|
var birthYear: String = "",
|
||||||
var abhaId: String = "",
|
|
||||||
var bloodGroup: String = "",
|
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
var gender: String ="",
|
|
||||||
var location: Location? = null,
|
var location: Location? = null,
|
||||||
var createdBy: String? = "",
|
var createdBy: String? = "",
|
||||||
var reportUploadTime: String? = "",
|
var reportUploadTime: String? = "",
|
||||||
@@ -22,14 +19,12 @@ data class UserData(
|
|||||||
var testStatus: Boolean? = false,
|
var testStatus: Boolean? = false,
|
||||||
var mobileId: String = "",
|
var mobileId: String = "",
|
||||||
var deviceId: String = "",
|
var deviceId: String = "",
|
||||||
var state: String = "",
|
|
||||||
var deviceSerialNumber: String = "",
|
var deviceSerialNumber: String = "",
|
||||||
var kitSerial: String = "",
|
var kitSerial: String = "",
|
||||||
var csvPath: String = "",
|
var csvPath: String = "",
|
||||||
var reportPath: String = "",
|
var reportPath: String = "",
|
||||||
var result: TestRightResultType? = null,
|
var result: TestRightResultType? = null,
|
||||||
var resultRatio: Double? = null,
|
var resultRatio: Double? = null
|
||||||
var prdClassification: String = ""
|
|
||||||
) {
|
) {
|
||||||
enum class Gender {
|
enum class Gender {
|
||||||
MALE,
|
MALE,
|
||||||
@@ -49,11 +44,5 @@ fun UserData.toHemoCubeTestData() = HemoCubeTestData(
|
|||||||
birthYear = birthYear,
|
birthYear = birthYear,
|
||||||
userImageURL = userImageURL,
|
userImageURL = userImageURL,
|
||||||
testStatus = testStatus,
|
testStatus = testStatus,
|
||||||
location = location,
|
location = location
|
||||||
gender = gender,
|
|
||||||
state = state,
|
|
||||||
abhaId = abhaId,
|
|
||||||
bloodGroup = bloodGroup,
|
|
||||||
prdClassification = prdClassification,
|
|
||||||
testTime = testTime
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.example.hpostesting.di
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.android.components.ViewModelComponent
|
||||||
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(ViewModelComponent::class)
|
||||||
|
object ViewModelModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun provideTestRightViewModel(
|
||||||
|
saveRawData: SaveRawData,
|
||||||
|
saveRawDataTest: SaveRawDataTest,
|
||||||
|
databaseRepository: DatabaseRepository,
|
||||||
|
userDao: UserDao,
|
||||||
|
context: Context
|
||||||
|
): TestRightViewModel {
|
||||||
|
return TestRightViewModel(saveRawData, saveRawDataTest, databaseRepository, userDao, context)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,14 +15,13 @@ 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 java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class DatabaseRepository @Inject constructor() : Repository {
|
class DatabaseRepository : Repository {
|
||||||
|
|
||||||
private val db: FirebaseFirestore = Firebase.firestore
|
private val db: FirebaseFirestore = Firebase.firestore
|
||||||
private val storage = Firebase.storage
|
private val storage = Firebase.storage
|
||||||
|
|
||||||
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
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()) {
|
||||||
@@ -37,7 +36,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
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()) {
|
||||||
@@ -53,7 +52,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
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)
|
||||||
@@ -63,7 +62,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
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)
|
||||||
@@ -73,7 +72,7 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> {
|
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
val file = Uri.fromFile(File(filePath))
|
||||||
@@ -132,11 +131,15 @@ class DatabaseRepository @Inject constructor() : Repository {
|
|||||||
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
||||||
val querySnapshot = db.collection("devices").get().await()
|
val querySnapshot = db.collection("devices").get().await()
|
||||||
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
||||||
|
|
||||||
// Find the DeviceData object with the specified deviceId
|
// Find the DeviceData object with the specified deviceId
|
||||||
return allDeviceDataList.find { it.deviceId == deviceId }
|
return allDeviceDataList.find { it.deviceId == deviceId }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,6 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
|
||||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
|
||||||
|
|
||||||
interface Repository {
|
interface Repository {
|
||||||
suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String>
|
abstract fun <UserData> addTestToDatabase(testDetails: UserData): Any
|
||||||
|
// suspend fun addToDatabase(data: PatientDetails)
|
||||||
suspend fun addTestToDatabase(data: UserData?): Response<String>
|
|
||||||
|
|
||||||
suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String>
|
|
||||||
|
|
||||||
suspend fun addDiagnostics(data: DiagnosticsData?): Response<String>
|
|
||||||
|
|
||||||
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
|
||||||
|
|
||||||
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ import com.example.hpostesting.data.dao.UserDao
|
|||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
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.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
@@ -70,10 +69,4 @@ object AppModule {
|
|||||||
fun provideDatabaseRepository(): DatabaseRepository {
|
fun provideDatabaseRepository(): DatabaseRepository {
|
||||||
return DatabaseRepository()
|
return DatabaseRepository()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideRepository(): Repository {
|
|
||||||
return DatabaseRepository()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ 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.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
|
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||||
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
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.adapter
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.navigation.findNavController
|
|
||||||
import androidx.recyclerview.widget.AsyncListDiffer
|
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.OfflineUserListViewBinding
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class OfflineUserListAdapter(private val view: View, private val batLevel: Int) :
|
|
||||||
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
|
||||||
|
|
||||||
inner class OfflineUserListViewHolder(val binding: OfflineUserListViewBinding) :
|
|
||||||
RecyclerView.ViewHolder(binding.root)
|
|
||||||
|
|
||||||
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
|
||||||
override fun areItemsTheSame(
|
|
||||||
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
|
||||||
): Boolean {
|
|
||||||
return oldItem._id == newItem._id
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun areContentsTheSame(
|
|
||||||
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
|
||||||
): Boolean {
|
|
||||||
return oldItem == newItem
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val differ = AsyncListDiffer(this, differCallback)
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OfflineUserListViewHolder {
|
|
||||||
return OfflineUserListViewHolder(
|
|
||||||
OfflineUserListViewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return differ.currentList.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
|
||||||
val userList = differ.currentList[position]
|
|
||||||
holder.binding.apply {
|
|
||||||
userID.text = "User ID: ${userList._id}"
|
|
||||||
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
|
||||||
time.text = "Time: ${userList.incubationTime}"
|
|
||||||
userCard.setOnClickListener {
|
|
||||||
if (batLevel < 40) {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
"Battery level is low than 40%, please charge the device to continue testing",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
if (userList.testStatus != null) {
|
|
||||||
if (userList.testStatus!!) {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
"Test has been already conducted for this user",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
} else {
|
|
||||||
if (userList.incubationTime != "") {
|
|
||||||
if (isBetween15And30Minutes(userList.incubationTime) < Constants.INCUBATION_TIME_MIN) {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
"Incubation has not completed 15 minutes",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
} else if (isBetween15And30Minutes(userList.incubationTime) > Constants.INCUBATION_TIME_MAX) {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
"Incubation crossed 30 minutes, need to repeat the incubation",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
} else {
|
|
||||||
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,
|
|
||||||
"Incubation not started for this user",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isBetween15And30Minutes(createdAt: String): Long {
|
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
|
||||||
val createdAtDate: Date = formatter.parse(createdAt)!!
|
|
||||||
|
|
||||||
val currentTime = Calendar.getInstance().time
|
|
||||||
|
|
||||||
val diffMillis = currentTime.time - createdAtDate.time
|
|
||||||
|
|
||||||
return diffMillis / (60 * 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,7 +20,6 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
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.presentation.KitScanActivity
|
import com.example.hpostesting.presentation.KitScanActivity
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
@@ -34,7 +33,6 @@ 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 java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@@ -42,12 +40,10 @@ import java.util.Locale
|
|||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
private var _binding: FragmentHomeBinding? = null
|
private var _binding: FragmentHomeBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel<Any?> by activityViewModels()
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var rvAdapter: UserListAdapter
|
private lateinit var rvAdapter: UserListAdapter
|
||||||
private var batLevel: Int =
|
private var batLevel: Int = 0 // Initialize with a default value, or obtain the actual battery level
|
||||||
0 // Initialize with a default value, or obtain the actual battery level
|
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
|
||||||
|
|
||||||
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
@@ -77,19 +73,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteHemoCubeIncompleteRegistrations(userData)
|
deleteHemoCubeIncompleteRegistrations(userData)
|
||||||
if (userData.isNotEmpty()) {
|
|
||||||
val userList = mutableListOf<HemoCubeTestData>()
|
|
||||||
userData.forEach {
|
|
||||||
if (it.testStatus == false) {
|
|
||||||
userList.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val bm = requireContext().getSystemService(BATTERY_SERVICE) as BatteryManager
|
|
||||||
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
|
||||||
adapter = OfflineUserListAdapter(binding.root, batLevel)
|
|
||||||
adapter.differ.submitList(userList)
|
|
||||||
binding.rvOrderOffline.adapter = adapter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
@@ -137,18 +120,10 @@ class HomeFragment : Fragment() {
|
|||||||
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
|
if (userId.length >= 18) {
|
||||||
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
val userData = UserData(_id = userId)
|
||||||
hemoCubeViewModel.addUser(
|
DataHolder.selectedTest = userData
|
||||||
HemoCubeTestData(
|
findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
_id = userId, bloodGroup = bloodGroup.toString(), incubationTime = SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
|
||||||
).format(Calendar.getInstance().time).toString()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// val userData = UserData(_id = userId)
|
|
||||||
// DataHolder.selectedTest = userData
|
|
||||||
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
|
||||||
} else {
|
} else {
|
||||||
val errorMessage = getString(R.string.user_id_error_message)
|
val errorMessage = getString(R.string.user_id_error_message)
|
||||||
Toast.makeText(requireContext(), errorMessage, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), errorMessage, Toast.LENGTH_SHORT).show()
|
||||||
@@ -181,10 +156,8 @@ class HomeFragment : Fragment() {
|
|||||||
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
|
||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(requireContext(), hemoCubeViewModel, recyclerViewOptions,
|
||||||
requireContext(), hemoCubeViewModel, recyclerViewOptions,
|
it, batLevel, requireActivity())
|
||||||
it, batLevel, requireActivity()
|
|
||||||
)
|
|
||||||
}!!
|
}!!
|
||||||
binding.rvOrder.adapter = rvAdapter
|
binding.rvOrder.adapter = rvAdapter
|
||||||
|
|
||||||
@@ -233,8 +206,7 @@ class HomeFragment : Fragment() {
|
|||||||
val partition = dateFormat.format(currentDate)
|
val partition = dateFormat.format(currentDate)
|
||||||
val searchTerm = partition + search
|
val searchTerm = partition + search
|
||||||
val searchField = field + "Search"
|
val searchField = field + "Search"
|
||||||
val query =
|
val query = Firebase.firestore.collection("patientData").orderBy(searchField).startAt(searchTerm)
|
||||||
Firebase.firestore.collection("patientData").orderBy(searchField).startAt(searchTerm)
|
|
||||||
.endAt(searchTerm + "\uf8ff")
|
.endAt(searchTerm + "\uf8ff")
|
||||||
query.get().addOnSuccessListener {
|
query.get().addOnSuccessListener {
|
||||||
userSearchTrace.stop()
|
userSearchTrace.stop()
|
||||||
@@ -246,14 +218,7 @@ class HomeFragment : Fragment() {
|
|||||||
batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
|
||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(requireContext(), hemoCubeViewModel, recyclerViewOptions, it, batLevel, requireActivity())
|
||||||
requireContext(),
|
|
||||||
hemoCubeViewModel,
|
|
||||||
recyclerViewOptions,
|
|
||||||
it,
|
|
||||||
batLevel,
|
|
||||||
requireActivity()
|
|
||||||
)
|
|
||||||
}!!
|
}!!
|
||||||
binding.rvOrder.adapter = rvAdapter
|
binding.rvOrder.adapter = rvAdapter
|
||||||
rvAdapter.startListening()
|
rvAdapter.startListening()
|
||||||
@@ -307,8 +272,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val uploadDataVisibility =
|
val uploadDataVisibility = if (userDataList.any { !it.localFlag }) 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,7 +331,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||||
userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
if (userData._id.isEmpty()) {
|
if (userData.testTime?.isEmpty() == true) {
|
||||||
hemoCubeViewModel.deleteById(userData._id)
|
hemoCubeViewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.hemocube
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.hardware.usb.UsbDevice
|
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
|
||||||
import android.hardware.usb.UsbManager
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.view.Menu
|
|
||||||
import androidx.activity.viewModels
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|
||||||
|
|
||||||
class DigitalCardActivity : AppCompatActivity() {
|
|
||||||
private lateinit var binding: ActivityDigitalCardBinding
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = ActivityDigitalCardBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
|
||||||
moveToNext()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun moveToNext() {
|
|
||||||
if (supportFragmentManager.isDestroyed) return
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, DigitalCardFragment())
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.hemocube
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.activityViewModels
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class DigitalCardFragment : Fragment() {
|
|
||||||
private lateinit var binding: FragmentDigitalCardBinding
|
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
|
||||||
): View {
|
|
||||||
binding = FragmentDigitalCardBinding.inflate(inflater, container, false)
|
|
||||||
sharedPreferences =
|
|
||||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
initViews()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
private fun initViews() {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
Log.d("DigitalCardFragment", "Name: ${DataHolder.hemoCubeTestData?.name}")
|
|
||||||
Log.d("DigitalCardFragment", "DOB: ${testDetails?.birthYear}")
|
|
||||||
Log.d("DigitalCardFragment", "Gender: ${testDetails?.gender}")
|
|
||||||
Log.d("DigitalCardFragment", "State: ${testDetails?.state}")
|
|
||||||
Log.d("DigitalCardFragment", "ABHA ID: ${testDetails?.abhaId}")
|
|
||||||
Log.d("DigitalCardFragment", "Blood Group: ${testDetails?.bloodGroup}")
|
|
||||||
Log.d("DigitalCardFragment", "Sickle-Cell: ${testDetails?.classificationResult}")
|
|
||||||
// Log.d("DigitalCardFragment", "Issue Date: $formattedDate")
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
binding.name.text = "Name: ${DataHolder.hemoCubeTestData?.name}"
|
|
||||||
binding.dob.text = "DOB: ${testDetails?.birthYear}"
|
|
||||||
binding.gender.text = "Gender: ${testDetails?.gender}"
|
|
||||||
binding.State.text = "State: ${testDetails?.state}"
|
|
||||||
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
|
||||||
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
|
||||||
binding.sicklecell.text = "Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
|
||||||
|
|
||||||
}
|
|
||||||
// Update the UI with the fetched details
|
|
||||||
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
|
||||||
val originalDate: Date? = originalDateFormat.parse(SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
|
||||||
).format(Calendar.getInstance().time))
|
|
||||||
|
|
||||||
// Format the parsed date to "mm date, year"
|
|
||||||
val desiredDateFormat = SimpleDateFormat("MMM dd, yyyy", Locale.getDefault())
|
|
||||||
val formattedDate: String = originalDate?.let { desiredDateFormat.format(it) } ?: "N/A"
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.issueDate.text = "Issue Date: ${formattedDate}"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,10 @@ 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.FrameLayout
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@@ -20,7 +20,6 @@ import com.example.hpostesting.data.model.patient.DeviceData
|
|||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
@@ -35,29 +34,14 @@ 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
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
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 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)
|
||||||
private val testingTrace = Firebase.performance.newTrace("testing_trace")
|
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 = ""
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
@@ -71,9 +55,8 @@ 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() {
|
||||||
@@ -85,60 +68,34 @@ 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
|
||||||
binding.nameEditText.visibility = View.GONE
|
binding.nameEditText.visibility = View.GONE
|
||||||
binding.tvTitle.visibility = View.GONE
|
binding.tvTitle.visibility = View.GONE
|
||||||
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}"
|
||||||
binding.tvSubtitle4.text = "Config"
|
Log.e("nametext", binding.tvName.text.toString())
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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("Test Results Uploaded Successfully")
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.visibility = View.GONE
|
|
||||||
binding.btnDigitalCard.visibility = View.VISIBLE
|
|
||||||
binding.btnDigitalCard.setOnClickListener {
|
|
||||||
val i = Intent(
|
val i = Intent(
|
||||||
requireContext().applicationContext, DigitalCardActivity::class.java
|
requireContext().applicationContext, DashboardActivity::class.java
|
||||||
)
|
)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
(activity as HemocubeActivity).finish()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (result == "Local") {
|
if (result == "Local") {
|
||||||
showToast("Internet not available, test details stored locally")
|
showToast("Internet not available, test details stored locally")
|
||||||
@@ -174,41 +131,44 @@ 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() {
|
private fun checkAndStartProcess() {
|
||||||
|
if (isBufferValueAvailable()) {
|
||||||
|
showBufferAlertDialog()
|
||||||
|
} else {
|
||||||
|
listenToHemoCube()
|
||||||
startBufferProcess()
|
startBufferProcess()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun isBufferValueAvailable(): Boolean {
|
private fun isBufferValueAvailable(): Boolean {
|
||||||
return try {
|
return if (sharedPreferences.getString(
|
||||||
if (sharedPreferences.getString(
|
|
||||||
Constants.BUFFER_VALUE_1, ""
|
Constants.BUFFER_VALUE_1, ""
|
||||||
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
) != "" && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||||
&& sharedPreferences.getString(Constants.BUFFER_VALUE_3, "") != ""
|
|
||||||
&& sharedPreferences.getString(Constants.BUFFER_VALUE_4, "") != ""
|
|
||||||
) {
|
) {
|
||||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")
|
||||||
?.toDouble()!! > 0.0 && sharedPreferences.getString(
|
?.toDouble()!! > 0.0 && sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")
|
||||||
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
|
?.toDouble()!! > 0.0
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
showToast("error while getting existing buffer")
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showBufferAlertDialog() {
|
private fun showBufferAlertDialog() {
|
||||||
@@ -224,15 +184,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
positiveText,
|
positiveText,
|
||||||
object : MyDialogListener {
|
object : MyDialogListener {
|
||||||
override fun onClickNegativeButton() {
|
override fun onClickNegativeButton() {
|
||||||
|
listenToHemoCube()
|
||||||
startBufferProcess()
|
startBufferProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClickPositiveButton() {
|
override fun onClickPositiveButton() {
|
||||||
activity?.runOnUiThread {
|
listenToHemoCube()
|
||||||
binding.btnPlacebuffer.visibility = View.GONE
|
startSampleProcess()
|
||||||
binding.btnSamplestart.visibility = View.VISIBLE
|
|
||||||
binding.tvSubtitle4.text = "Place Sample"
|
|
||||||
}
|
|
||||||
isUsingExistingBuffer = true
|
isUsingExistingBuffer = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -268,117 +226,41 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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, fullReadOutput: StringBuilder) {
|
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||||
if (stringData.contains("#")) {
|
if (stringData.contains("#")) {
|
||||||
|
hemoCubeViewModel.messages.postValue(stringData)
|
||||||
isTestOngoing = true
|
isTestOngoing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData += stringData
|
resultData += stringData
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("SN") -> {
|
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
||||||
val slData = stringData.split(" ")
|
stringData.contains("#Sample Completed") -> {
|
||||||
if (slData.size > 1) {
|
|
||||||
val hardwareId = slData[1].trim()
|
|
||||||
deviceHardwareId = hardwareId
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.DEVICE_ID, hardwareId)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
hemoCubeViewModel.messages.postValue("Start")
|
|
||||||
}
|
|
||||||
|
|
||||||
stringData.contains("#BS") -> {
|
|
||||||
hemoCubeViewModel.messages.postValue("Buffer Started")
|
|
||||||
}
|
|
||||||
|
|
||||||
stringData.contains("#BC") -> {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.tvSubtitle4.text = "Buffer Completed"
|
|
||||||
binding.btnSamplestart.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stringData.contains("#SS") -> {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.tvSubtitle4.text = "Sample Started"
|
|
||||||
binding.btnSamplestart.visibility = View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stringData.contains("#SC") -> {
|
|
||||||
hemoCubeViewModel.messages.postValue("Sample Completed \nGathering data")
|
|
||||||
fetchResult()
|
fetchResult()
|
||||||
testingTrace.stop()
|
testingTrace.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData.contains("REND") -> {
|
stringData.contains("RESULT") || resultData.contains("REND") -> {
|
||||||
hemoCubeViewModel.messages.postValue(
|
var validString: String
|
||||||
"Data collected \n" +
|
val results: List<String>
|
||||||
" Processing data"
|
if (stringData.contains("RESULT")) {
|
||||||
)
|
validString = isValidResult(stringData)
|
||||||
val resultLines = resultData.split("\\s+(?=LB|LS)".toRegex())
|
if (validString.isEmpty()) {
|
||||||
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
results = resultData.split("\n")
|
||||||
led1BufferForDevice = if (isUsingExistingBuffer) {
|
validString = parseResult(results)
|
||||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
|
||||||
} else {
|
|
||||||
bufferIntensity.toDoubleOrNull()!!
|
|
||||||
}
|
}
|
||||||
bufferIntensity = resultLines[2].split(' ')[1].trim()
|
|
||||||
led2BufferForDevice = if (isUsingExistingBuffer) {
|
|
||||||
sharedPreferences.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()!!
|
|
||||||
} else {
|
} else {
|
||||||
bufferIntensity.toDoubleOrNull()!!
|
results = resultData.split("\n")
|
||||||
|
validString = parseResult(results)
|
||||||
|
}
|
||||||
|
if (validString.isNotEmpty()) {
|
||||||
|
handleValidResult(validString, resultData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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 {
|
||||||
@@ -409,129 +291,99 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processResult() {
|
private fun showStartSampleDialog() {
|
||||||
try {
|
activity?.runOnUiThread {
|
||||||
hemoCubeViewModel.messages.postValue("processing result")
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
val deviceLog = resultData
|
"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 {
|
||||||
|
val result = validString.split(" ")
|
||||||
|
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(
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
requireActivity().packageName, 0
|
requireActivity().packageName, 0
|
||||||
)
|
)
|
||||||
val version = pInfo.versionName
|
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
|
||||||
|
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||||
|
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||||
|
// if (deviceRatio < 0.08) {
|
||||||
|
// if (deviceRatio > 1.07) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
val led1Average = log10(led1BufferForDevice?.div(led1SampleForDevice!!) ?: 0.0)
|
if (led1Average < 0 || led2Average < 0) {
|
||||||
val led2Average = log10(led2BufferForDevice?.div(led2SampleForDevice!!) ?: 0.0)
|
|
||||||
val led3Average = log10(led3BufferForDevice?.div(led3SampleForDevice!!) ?: 0.0)
|
|
||||||
val led4Average = log10(led4BufferForDevice?.div(led4SampleForDevice!!) ?: 0.0)
|
|
||||||
val deviceRatio = led3Average / led1Average
|
|
||||||
|
|
||||||
if (led1BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)?.get(0)!!
|
|
||||||
|| led2BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(1)?.get(0)!!
|
|
||||||
|| led3BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(2)?.get(0)!!
|
|
||||||
|| led4BufferForDevice < Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(0)!!
|
|
||||||
) {
|
|
||||||
validationError = true
|
|
||||||
activity?.runOnUiThread{
|
activity?.runOnUiThread{
|
||||||
binding.errorMessage.text = "Error: Invalid Test. Improper buffer reading (low)"
|
binding.errorMessage.text = "Warning: Negative Abs. Retake Blank Reading"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (led1BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(0)?.get(1)!!
|
|
||||||
|| led2BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(1)?.get(1)!!
|
|
||||||
|| led3BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(2)?.get(1)!!
|
|
||||||
|| led4BufferForDevice > Constants.BUFFER_INTENSITY_THRESHOLDS[deviceHardwareId]?.get(3)?.get(1)!!
|
|
||||||
) {
|
|
||||||
validationError = true
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.errorMessage.text =
|
|
||||||
"Error: Invalid Test. Improper buffer reading (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
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.errorMessage.text = "Error: Invalid Test. Problem with de-oxygenation"
|
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fittedAbs1 < 0 || fittedAbs2 < 0 || fittedAbs3 < 0 || fittedAbs4 < 0) {
|
|
||||||
validationError = true
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.errorMessage.text = "Error: Negative Abs. Retake Blank Reading"
|
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()
|
deviceId = deviceSerialNo
|
||||||
led1Buffer = led1BufferForDevice
|
led1Buffer = led1BufferForDevice
|
||||||
led2Buffer = led2BufferForDevice
|
led2Buffer = led2BufferForDevice
|
||||||
led3Buffer = led3BufferForDevice
|
|
||||||
led4Buffer = led4BufferForDevice
|
|
||||||
appVersion = version
|
appVersion = version
|
||||||
this.led1Sample = led1SampleForDevice
|
this.led1Sample = led1Sample
|
||||||
this.led2Sample = led2SampleForDevice
|
this.led2Sample = led2Sample
|
||||||
this.led3Sample = led3SampleForDevice
|
|
||||||
this.led4Sample = led4SampleForDevice
|
|
||||||
this.led1Average = led1Average
|
this.led1Average = led1Average
|
||||||
this.led2Average = led2Average
|
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.deviceRatio = deviceRatio
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||||
this.predictedDenovixRatio = _predictedDenovixRatio
|
this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
this.coefficients = currentDeviceData?.coefficients?.get(0)
|
|
||||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
|
||||||
this.classificationResult = findResult(calculatedRatio)
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||||
hemoCubeViewModel.messages.postValue(this.prdClassification)
|
|
||||||
this.resultData = deviceLog
|
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) {
|
if (!isUsingExistingBuffer) {
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.BUFFER_VALUE_1, led1BufferForDevice.toString())
|
putString(Constants.BUFFER_VALUE_1, led1Buffer.toString())
|
||||||
putString(Constants.BUFFER_VALUE_2, led2BufferForDevice.toString())
|
putString(Constants.BUFFER_VALUE_2, led2Buffer.toString())
|
||||||
putString(Constants.BUFFER_VALUE_3, led3BufferForDevice.toString())
|
|
||||||
putString(Constants.BUFFER_VALUE_4, led4BufferForDevice.toString())
|
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validationError) {
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
@@ -539,6 +391,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@@ -549,9 +402,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findResult(calculatedRatio: Double?): String {
|
private 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 "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||||
@@ -568,39 +420,14 @@ class HemoCubeFragment : Fragment() {
|
|||||||
if (calculatedRatio > 0.35)
|
if (calculatedRatio > 0.35)
|
||||||
return "Inconclusive. Repeat with test with lower volume of blood"
|
return "Inconclusive. Repeat with test with lower volume of blood"
|
||||||
} else {
|
} else {
|
||||||
return "INVALID"
|
return "NULL"
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showToast("error while performing classification")
|
showToast("error while performing classification")
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
return "ERROR"
|
return "ERROR"
|
||||||
}
|
}
|
||||||
return "INVALID"
|
return "NULL"
|
||||||
}
|
|
||||||
|
|
||||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
|
||||||
try {
|
|
||||||
hemoCubeViewModel.messages.postValue("result classification")
|
|
||||||
if (predictedDenovixRatio != null) {
|
|
||||||
if (predictedDenovixRatio in 0.0..0.16)
|
|
||||||
return "Normal"
|
|
||||||
if (predictedDenovixRatio in 0.16..0.165)
|
|
||||||
return "Negative Borderline"
|
|
||||||
if (predictedDenovixRatio in 0.165..0.235)
|
|
||||||
return "Sickle Cell Trait"
|
|
||||||
if (predictedDenovixRatio in 0.235..0.24)
|
|
||||||
return "Positive Borderline"
|
|
||||||
if (predictedDenovixRatio in 0.24..1.0)
|
|
||||||
return "Sickle Cell Disease"
|
|
||||||
} else {
|
|
||||||
return "INVALID"
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
showToast("error while performing classification")
|
|
||||||
Firebase.crashlytics.recordException(e)
|
|
||||||
return "ERROR"
|
|
||||||
}
|
|
||||||
return "INVALID"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
private fun showToast(message: String) {
|
||||||
@@ -610,10 +437,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
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?) {}
|
||||||
@@ -657,6 +480,29 @@ class HemoCubeFragment : Fragment() {
|
|||||||
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,13 +1,8 @@
|
|||||||
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.IntentFilter
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
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
|
||||||
@@ -20,10 +15,8 @@ import com.example.hpostesting.data.model.Response
|
|||||||
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.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
import com.example.hpostesting.data.repository.Repository
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@@ -34,7 +27,7 @@ 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: DatabaseRepository,
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
@@ -53,17 +46,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
get() = _networkStatusLiveData
|
get() = _networkStatusLiveData
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
val fireBaseBulkUpload = MutableLiveData<String>()
|
||||||
|
fun uploadHemoCubeResultToDatabase(isOnline: Boolean, testStatus: Boolean, kitSerial: String?) =
|
||||||
private val batteryStatus: Intent? =
|
|
||||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
|
||||||
context.registerReceiver(null, ifilter)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabase(
|
|
||||||
isOnline: Boolean,
|
|
||||||
testStatus: Boolean,
|
|
||||||
kitSerial: String?
|
|
||||||
) =
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (kitSerial != null) {
|
if (kitSerial != null) {
|
||||||
testDetails?.kitSerial = kitSerial
|
testDetails?.kitSerial = kitSerial
|
||||||
@@ -88,6 +71,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
addResultTestToDbforbuffercheck(bufferCheckData)
|
addResultTestToDbforbuffercheck(bufferCheckData)
|
||||||
@@ -111,34 +95,14 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
||||||
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
||||||
testDetails?.led3Buffer = DataHolder.hemoCubeTestData?.led3Buffer
|
|
||||||
testDetails?.led4Buffer = DataHolder.hemoCubeTestData?.led4Buffer
|
|
||||||
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
||||||
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
||||||
testDetails?.led3Sample = DataHolder.hemoCubeTestData?.led3Sample
|
|
||||||
testDetails?.led4Sample = DataHolder.hemoCubeTestData?.led4Sample
|
|
||||||
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
||||||
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
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?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
||||||
testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio
|
|
||||||
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
||||||
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||||
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResultTestToDb() {
|
private fun addResultTestToDb() {
|
||||||
@@ -179,8 +143,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
when (val response =
|
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -220,60 +183,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
hemoCubeDao.updateFieldById(id = userId, true)
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
|
||||||
hemoCubeDao.insertAll(userData)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteById(userId: String) = viewModelScope.launch {
|
fun deleteById(userId: String) = viewModelScope.launch {
|
||||||
hemoCubeDao.deleteById(id = userId)
|
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) ?: 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityTestRightBinding
|
|||||||
class TestRightActivity : AppCompatActivity() {
|
class TestRightActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityTestRightBinding
|
private lateinit var binding: ActivityTestRightBinding
|
||||||
private val viewModel by viewModels<TestRightViewModel>()
|
private val viewModel by viewModels<TestRightViewModel<Any?>>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import `in`.sminnovations.hpostesting.databinding.FragmentTestRightExpReferenceB
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TestRightExpReference : Fragment() {
|
class TestRightExpReference : Fragment() {
|
||||||
private lateinit var binding: FragmentTestRightExpReferenceBinding
|
private lateinit var binding: FragmentTestRightExpReferenceBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel<Any?> by activityViewModels()
|
||||||
private val TAG = "TestRightExpReference"
|
private val TAG = "TestRightExpReference"
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import `in`.sminnovations.hpostesting.databinding.FragmentTestRightExpSampleBind
|
|||||||
class TestRightExpSample : Fragment() {
|
class TestRightExpSample : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentTestRightExpSampleBinding
|
private lateinit var binding: FragmentTestRightExpSampleBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel<Any?> by activityViewModels()
|
||||||
|
|
||||||
private val TAG = "TestRightExpSample"
|
private val TAG = "TestRightExpSample"
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import kotlinx.coroutines.withContext
|
|||||||
class TestRightResults : Fragment() {
|
class TestRightResults : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentTestRightResultsBinding
|
private lateinit var binding: FragmentTestRightResultsBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel<Any?> by activityViewModels()
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.example.hpostesting.domain.TestRightResultCalculation
|
|||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import dagger.hilt.android.scopes.ViewModelScoped
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -38,14 +39,16 @@ import kotlin.math.log10
|
|||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
|
@ViewModelScoped
|
||||||
class TestRightViewModel @Inject constructor(
|
class TestRightViewModel @Inject constructor(
|
||||||
private val saveRawData: SaveRawData,
|
private val saveRawData: SaveRawData,
|
||||||
private val saveRawDataTest: SaveRawDataTest,
|
private val saveRawDataTest: SaveRawDataTest,
|
||||||
private val repository: DatabaseRepository,
|
private val repository: DatabaseRepository,
|
||||||
private val userDao: UserDao,
|
private val userDao: UserDao,
|
||||||
context: Context
|
context: Context?
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|
||||||
@@ -54,10 +57,10 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
|
|
||||||
val testDetails = DataHolder.selectedTest
|
var testDetails = DataHolder.selectedTest
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = context?.let { NetworkStatusLiveData(it) }
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
val networkStatusLiveData: NetworkStatusLiveData?
|
||||||
get() = _networkStatusLiveData
|
get() = _networkStatusLiveData
|
||||||
|
|
||||||
val allUserData = userDao.getAll()
|
val allUserData = userDao.getAll()
|
||||||
@@ -439,7 +442,7 @@ class TestRightViewModel @Inject constructor(
|
|||||||
"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(testDetails)) {
|
when (repository.addTestToDatabase(testDetails)) {
|
||||||
is Response.Success -> {
|
is Response.Success<*> -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +451,8 @@ class TestRightViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadResultToDatabase(context: Context, isOnline: Boolean,deviceSerialNumber: String) = viewModelScope.launch {
|
fun uploadResultToDatabase(context: Context, isOnline: Boolean, deviceSerialNumber: String) =
|
||||||
|
viewModelScope.launch {
|
||||||
val csvFilePath = MyUtils.getAppFolderPath(context) + getCSVFileName()
|
val csvFilePath = MyUtils.getAppFolderPath(context) + getCSVFileName()
|
||||||
val logTxtFilePath = MyUtils.getAppFolderPath(context) + getLogFileName()
|
val logTxtFilePath = MyUtils.getAppFolderPath(context) + getLogFileName()
|
||||||
testDetails?.csvPath = csvFilePath
|
testDetails?.csvPath = csvFilePath
|
||||||
@@ -463,7 +467,8 @@ class TestRightViewModel @Inject constructor(
|
|||||||
val logTxtFileUri = Uri.fromFile(File(logTxtFilePath))
|
val logTxtFileUri = Uri.fromFile(File(logTxtFilePath))
|
||||||
|
|
||||||
val csvUploadTask =
|
val csvUploadTask =
|
||||||
storageTestDetailsRef.child(csvFileUri.lastPathSegment!!).putFile(csvFileUri)
|
storageTestDetailsRef.child(csvFileUri.lastPathSegment!!)
|
||||||
|
.putFile(csvFileUri)
|
||||||
.await()
|
.await()
|
||||||
val logUploadTask = storageTestDetailsRef.child(logTxtFileUri.lastPathSegment!!)
|
val logUploadTask = storageTestDetailsRef.child(logTxtFileUri.lastPathSegment!!)
|
||||||
.putFile(logTxtFileUri).await()
|
.putFile(logTxtFileUri).await()
|
||||||
@@ -519,7 +524,7 @@ class TestRightViewModel @Inject constructor(
|
|||||||
"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)) {
|
when (repository.addTestToDatabase(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success<*> -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
mPort.setParameters(115200, 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}")
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.0 KiB |
@@ -1,5 +0,0 @@
|
|||||||
<vector android:height="24dp" android:tint="#000000"
|
|
||||||
android:viewportHeight="24" android:viewportWidth="24"
|
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
|
||||||
</vector>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_parent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:visibility="gone"
|
|
||||||
android:id="@+id/my_toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
app:titleTextColor="#FFFFFF"
|
|
||||||
android:elevation="4dp"
|
|
||||||
app:menu="@menu/my_menu"
|
|
||||||
android:theme="@style/ToolbarTheme"
|
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/fghemocube"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<!-- NavHostFragment for navigation -->
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout 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">
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_parent"
|
android:id="@+id/cl_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -25,11 +27,15 @@
|
|||||||
android:id="@+id/fghemocube"
|
android:id="@+id/fghemocube"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
tools:context=".presentation.hemocube.HemocubeActivity">
|
tools:context=".presentation.hemocube.HemocubeActivity">
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -18,6 +18,4 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:navGraph="@navigation/dashboard_navigation" />
|
app:navGraph="@navigation/dashboard_navigation" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context="com.example.hpostesting.presentation.hemocube.DigitalCardFragment">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/userCard"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="350dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:cardBackgroundColor="#C0C0C0"
|
|
||||||
app:cardCornerRadius="25dp"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/fragment_container_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@android:color/background_light"/>
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="22dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/userImage"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
android:src="@drawable/karnataka" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/userName"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/userImage"
|
|
||||||
android:src="@drawable/sickle_cell_gov_logo"/>
|
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/userImage3"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/userName"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/userName"
|
|
||||||
android:src="@drawable/indianoil"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/userdetails"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:cardBackgroundColor="#FFFFFF"
|
|
||||||
app:cardCornerRadius="5dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage"
|
|
||||||
app:cardElevation="0dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/name"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="80dp"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage"
|
|
||||||
android:text="name: Mariya" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dob"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="80dp"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/name"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/name"
|
|
||||||
android:text="DOB: 1998" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/gender"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="80dp"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="50dp"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/dob"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/dob"
|
|
||||||
android:text="gender: female" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/State"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="130dp"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="70dp"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/gender"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/gender"
|
|
||||||
android:text="State: Kerala" />
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/userdetails2"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:cardBackgroundColor="#FFFFFF"
|
|
||||||
app:cardCornerRadius="5dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/userdetails"
|
|
||||||
app:cardElevation="0dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/abhaid"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:gravity="start"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
|
||||||
android:text="ABHA-ID: XXXX-8734" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/blood"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
android:gravity="start"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
|
||||||
android:text="Blood Group: O +ve" />
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/sicklecell"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="6dp"
|
|
||||||
android:layout_marginTop="50dp"
|
|
||||||
android:gravity="start"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
|
||||||
android:text="Sickle-Cell: Normal (HbA)" />
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/issueDate"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="20dp"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="70dp"
|
|
||||||
android:gravity="start"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="10sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
|
||||||
android:text="Issue Date: Oct 2,2023" />
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/digitalcard"
|
|
||||||
android:backgroundTint="#00008B"
|
|
||||||
app:cardBackgroundColor="#00008B"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:text="@string/digital_card"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/userdetails" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:elevation="12dp"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -147,35 +147,8 @@
|
|||||||
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"
|
||||||
@@ -205,19 +178,62 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
<Button
|
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
||||||
android:visibility="gone"
|
<!-- android:id="@+id/til_blood_group"-->
|
||||||
android:id="@+id/btn_digitalCard"
|
<!-- style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"-->
|
||||||
android:layout_width="wrap_content"
|
<!-- android:layout_width="match_parent"-->
|
||||||
android:layout_height="wrap_content"
|
<!-- android:layout_height="wrap_content"-->
|
||||||
android:layout_marginHorizontal="16dp"
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
android:layout_marginTop="24dp"
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
android:clickable="false"
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
android:text="DigitalCard View"
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
android:textColor="@color/white"
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">-->
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
<!-- <AutoCompleteTextView-->
|
||||||
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
<!-- android:id="@+id/et_blood_group"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:hint="@string/select_blood_group"-->
|
||||||
|
<!-- android:inputType="none"-->
|
||||||
|
<!-- android:labelFor="@id/til_blood_group"-->
|
||||||
|
<!-- app:simpleItems="@array/blood_group" />-->
|
||||||
|
|
||||||
|
<!-- </com.google.android.material.textfield.TextInputLayout>-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_kit"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_margin="10dp"-->
|
||||||
|
<!-- android:text="@string/new_kit"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_buffer"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/new_buffer"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- android:layout_margin="10dp"-->
|
||||||
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintEnd_toStartOf="@id/btn_kit"/>-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_read"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/read"-->
|
||||||
|
<!-- android:layout_margin="16dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
android:id="@+id/internetNotAvailableCL"
|
android:id="@+id/internetNotAvailableCL"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -57,27 +57,6 @@
|
|||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:id="@+id/til_blood_group"
|
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/til_name">
|
|
||||||
|
|
||||||
<AutoCompleteTextView
|
|
||||||
android:id="@+id/et_blood_group"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/select_blood_group"
|
|
||||||
android:inputType="none"
|
|
||||||
android:labelFor="@id/til_blood_group"
|
|
||||||
app:simpleItems="@array/blood_group" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_submit"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -87,18 +66,7 @@
|
|||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
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/til_blood_group" />
|
app:layout_constraintTop_toBottomOf="@+id/til_name" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rv_order_offline"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/btn_submit"
|
|
||||||
tools:listitem="@layout/offline_user_list_view" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
@@ -106,7 +74,7 @@
|
|||||||
android:id="@+id/internetAvailableCL"
|
android:id="@+id/internetAvailableCL"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"
|
android:visibility="visible"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/userCard"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
app:cardBackgroundColor="@color/primary_light"
|
|
||||||
app:cardCornerRadius="25dp"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="12dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userID"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
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_toTopOf="parent"
|
|
||||||
tools:text="Name: MohamedKaif" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/bloodGroup"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
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/userID"
|
|
||||||
tools:text="UserID: MohamedKaif" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/time"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
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" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/navigation_graph"
|
|
||||||
app:startDestination="@id/hemoCubeFragment">
|
|
||||||
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/hemoCubeFragment"
|
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.HemoCubeFragment"
|
|
||||||
android:label="fragment_hemo_cube_reference"
|
|
||||||
tools:layout="@layout/fragment_hemo_cube_reference" >
|
|
||||||
<action
|
|
||||||
android:id="@+id/action_hemoCubeFragment_to_digitalCardFragment"
|
|
||||||
app:destination="@id/digitalCardFragment" />
|
|
||||||
</fragment>
|
|
||||||
<fragment
|
|
||||||
android:id="@+id/digitalCardFragment"
|
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardFragment"
|
|
||||||
android:label="fragment_digital_card"
|
|
||||||
tools:layout="@layout/fragment_digital_card" />
|
|
||||||
</navigation>
|
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
<string name="sickle_find">Sickle Find</string>
|
<string name="sickle_find">Sickle Find</string>
|
||||||
<string name="submit">Submit</string>
|
<string name="submit">Submit</string>
|
||||||
<string name="diagnostics">Device Diagnostics</string>
|
<string name="diagnostics">Device Diagnostics</string>
|
||||||
<string name="place_buffer">Start</string>
|
<string name="place_buffer">Start Buffer</string>
|
||||||
<string name="Start_Sample">Start Sample</string>
|
<string name="Start_Sample">Start Sample</string>
|
||||||
<string name="new_kit">New Kit</string>
|
<string name="new_kit">New Kit</string>
|
||||||
<string name="new_buffer">New Buffer</string>
|
<string name="new_buffer">New Buffer</string>
|
||||||
@@ -158,7 +158,6 @@
|
|||||||
<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="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>
|
||||||
<string name="district">District</string>
|
<string name="district">District</string>
|
||||||
@@ -184,10 +183,10 @@
|
|||||||
<string name="user_list">User List</string>
|
<string name="user_list">User List</string>
|
||||||
<string name="user_id">User ID</string>
|
<string name="user_id">User ID</string>
|
||||||
<string name="aadhar_id">Aadhar ID</string>
|
<string name="aadhar_id">Aadhar ID</string>
|
||||||
<string name="internet_not_available_please_enter_the_user_id_manually">Internet not available, please enter the user ID and blood group manually</string>
|
<string name="internet_not_available_please_enter_the_user_id_manually">Internet not available, please enter the user ID manually</string>
|
||||||
<string name="user_id_error_message">User ID should be 18 digits and please select the blood group</string>
|
<string name="user_id_error_message">User ID should be 18 digits</string>
|
||||||
<string name="upload_db_registration_title">Upload DB Tests</string>
|
<string name="upload_db_registration_title">Upload DB Registration</string>
|
||||||
<string name="upload_db_registration_message">Do you want to upload the local DB tests to the cloud?</string>
|
<string name="upload_db_registration_message">Do you want to upload the local DB Registration to the cloud?</string>
|
||||||
<string name="upload">Upload</string>
|
<string name="upload">Upload</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="upload_success_message">Upload done successfully</string>
|
<string name="upload_success_message">Upload done successfully</string>
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
package com.example.hpostesting
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.data.repository.Repository
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
|
||||||
import com.example.hpostesting.util.TestCoroutineRule
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.test.advanceUntilIdle
|
|
||||||
import kotlinx.coroutines.test.runBlockingTest
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Rule
|
|
||||||
import org.junit.Test
|
|
||||||
import org.mockito.ArgumentMatchers.any
|
|
||||||
import org.mockito.ArgumentMatchers.anyString
|
|
||||||
import org.mockito.Mock
|
|
||||||
import org.mockito.Mockito.verify
|
|
||||||
import org.mockito.Mockito.`when`
|
|
||||||
import org.mockito.MockitoAnnotations
|
|
||||||
|
|
||||||
@ExperimentalCoroutinesApi
|
|
||||||
class HemoCubeViewModelTest {
|
|
||||||
|
|
||||||
// Add rule for testing LiveData
|
|
||||||
@get:Rule
|
|
||||||
val rule = InstantTaskExecutorRule()
|
|
||||||
|
|
||||||
// Add rule for testing coroutines
|
|
||||||
@get:Rule
|
|
||||||
val coroutineRule = TestCoroutineRule()
|
|
||||||
|
|
||||||
// Mock dependencies
|
|
||||||
@Mock
|
|
||||||
lateinit var hemoCubeDao: HemoCubeDao
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
lateinit var repository: Repository
|
|
||||||
|
|
||||||
// Mock context
|
|
||||||
@Mock
|
|
||||||
lateinit var context: Context
|
|
||||||
|
|
||||||
// Mock LiveData for testing
|
|
||||||
@Mock
|
|
||||||
lateinit var networkStatusLiveData: LiveData<Boolean>
|
|
||||||
|
|
||||||
// Initialize the ViewModel
|
|
||||||
lateinit var viewModel: HemoCubeViewModel
|
|
||||||
|
|
||||||
private lateinit var hemoCubeFragment: HemoCubeFragment
|
|
||||||
|
|
||||||
@Before
|
|
||||||
fun setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this)
|
|
||||||
// viewModel = HemoCubeViewModel(hemoCubeDao, repository, context)
|
|
||||||
hemoCubeFragment = HemoCubeFragment()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `uploadHemoCubeResultToDatabase with online status should call addResultTestToDb`() =
|
|
||||||
coroutineRule.runBlockingTest {
|
|
||||||
// Mock data and setup
|
|
||||||
val isOnline = true
|
|
||||||
val testStatus = true
|
|
||||||
val kitSerial = "12345"
|
|
||||||
|
|
||||||
// Mock the necessary methods
|
|
||||||
`when`(repository.addTestToDatabase(viewModel.testDetails!!))
|
|
||||||
.thenReturn(Response.Success("Success"))
|
|
||||||
|
|
||||||
// Call the function to be tested
|
|
||||||
viewModel.uploadHemoCubeResultToDatabase(isOnline, testStatus, kitSerial)
|
|
||||||
|
|
||||||
// Verify that addResultTestToDb is called
|
|
||||||
advanceUntilIdle()
|
|
||||||
assertEquals("Local", viewModel.fireBaseUpload.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Similar tests can be written for other methods in HemoCubeViewModel
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mockSharedPreferences: SharedPreferences
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mockActivity: HemocubeActivity // Replace with your actual Activity class
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mockBinding: FragmentHemoCubeReferenceBinding // Replace with your actual Binding class
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `findResult with valid input`() {
|
|
||||||
// Arrange
|
|
||||||
val validString = "valid string"
|
|
||||||
val fullReadOutput = "full read output"
|
|
||||||
`when`(mockSharedPreferences.getString(anyString(), anyString())).thenReturn("dummy_value")
|
|
||||||
`when`(mockActivity.runOnUiThread(any())).thenAnswer {
|
|
||||||
val runnable = it.getArgument(0, Runnable::class.java)
|
|
||||||
runnable.run()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Act
|
|
||||||
val result = hemoCubeFragment.findResult(calculatedRatio = 0.06)
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
// Add appropriate assertions based on the behavior you expect
|
|
||||||
// verify(mockSharedPreferences).edit()
|
|
||||||
// verify(mockBinding).btnSubmit.visibility = View.VISIBLE
|
|
||||||
// verify(mockBinding).btnSubmit.isEnabled = true
|
|
||||||
// Add more verifications as needed
|
|
||||||
|
|
||||||
assertEquals("Normal", result)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.example.hpostesting
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.view.View
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mockito.ArgumentMatchers.any
|
||||||
|
import org.mockito.ArgumentMatchers.anyString
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito.verify
|
||||||
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
|
class HemocubeViewModelTest {
|
||||||
|
@Mock
|
||||||
|
private lateinit var mockSharedPreferences: SharedPreferences
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var mockActivity: HemocubeActivity // Replace with your actual Activity class
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var mockBinding: FragmentHemoCubeReferenceBinding // Replace with your actual Binding class
|
||||||
|
|
||||||
|
private lateinit var hemoCubeFragment: HemoCubeFragment
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this)
|
||||||
|
hemoCubeFragment = HemoCubeFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `handleValidResult with valid input`() {
|
||||||
|
|
||||||
|
val validString = "valid string"
|
||||||
|
val fullReadOutput = "full read output"
|
||||||
|
`when`(mockSharedPreferences.getString(anyString(), anyString())).thenReturn("dummy_value")
|
||||||
|
`when`(mockActivity.runOnUiThread(any())).thenAnswer {
|
||||||
|
val runnable = it.getArgument(0, Runnable::class.java)
|
||||||
|
runnable.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
hemoCubeFragment.handleValidResult(validString, fullReadOutput)
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// Add appropriate assertions based on the behavior you expect
|
||||||
|
verify(mockSharedPreferences).edit()
|
||||||
|
verify(mockBinding).btnSubmit.visibility = View.VISIBLE
|
||||||
|
verify(mockBinding).btnSubmit.isEnabled = true
|
||||||
|
// Add more verifications as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add more test cases for different scenarios if needed
|
||||||
|
}
|
||||||
@@ -1,101 +1,136 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
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.model.PatientData
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
import com.example.hpostesting.data.model.test.TestRightResultType
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
import junit.framework.Assert.assertEquals
|
import junit.framework.Assert.assertEquals
|
||||||
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
import java.math.RoundingMode
|
import java.math.RoundingMode
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TestRightViewModelTest {
|
class TestRightViewModelTest {
|
||||||
// private val viewModel = TestRightViewModel()
|
|
||||||
// private val data = InputData()
|
@Mock
|
||||||
//
|
lateinit var mockContext: Context
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
lateinit var mockRepository: DatabaseRepository
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
lateinit var mockSaveRawData: SaveRawData
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
lateinit var mockSaveRawDataTest: SaveRawDataTest
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
lateinit var mockUserDao: UserDao
|
||||||
|
|
||||||
|
lateinit var viewModel: TestRightViewModel<Any?>
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
// Initialize mocks
|
||||||
|
MockitoAnnotations.initMocks(this)
|
||||||
|
|
||||||
|
// Create the ViewModel with mock dependencies
|
||||||
|
viewModel = TestRightViewModel(mockSaveRawData,mockSaveRawDataTest,mockRepository,mockUserDao,mockContext)
|
||||||
|
}
|
||||||
|
private val data = InputData()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_mapDeviceConstants() {
|
||||||
|
viewModel.mapDeviceConstants(data.inputRead)
|
||||||
|
assertEquals("0", DataHolder.deviceConstant!!.a)
|
||||||
|
assertEquals("1.69989422e-06", DataHolder.deviceConstant!!.b)
|
||||||
|
assertEquals("1.60642711e-01", DataHolder.deviceConstant!!.c)
|
||||||
|
assertEquals("3.85754470e+02", DataHolder.deviceConstant!!.d)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_mapPixelNumberToWavelength() {
|
||||||
|
viewModel.mapDeviceConstants(data.inputRead)
|
||||||
|
viewModel.mapPixelNumberToWavelength()
|
||||||
|
|
||||||
|
val outputList = TestDataGenerator().getOutputMapPixelNumberToWavelength()
|
||||||
|
|
||||||
|
assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, DataHolder.wavelengthToPixelArray.size)
|
||||||
|
assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, outputList.size)
|
||||||
|
|
||||||
|
val df = DecimalFormat("#.###")
|
||||||
|
df.roundingMode = RoundingMode.FLOOR
|
||||||
|
|
||||||
|
for (i in 0 until Constants.TEST_RIGHT_TOTAL_PIXEL){
|
||||||
|
assertEquals(df.format(outputList[i]), df.format(DataHolder.wavelengthToPixelArray[i]))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// fun test_mapDeviceConstants() {
|
// fun test_mapIntensityValues() {
|
||||||
// viewModel.mapDeviceConstants(data.inputRead)
|
// val inputReference = TestDataGenerator().getInputReferenceMapIntensityValues()
|
||||||
// assertEquals("0", DataHolder.deviceConstant!!.a)
|
// val inputSample = TestDataGenerator().getInputSampleMapIntensityValues()
|
||||||
// assertEquals("1.69989422e-06", DataHolder.deviceConstant!!.b)
|
//
|
||||||
// assertEquals("1.60642711e-01", DataHolder.deviceConstant!!.c)
|
// viewModel.mapIntensityValues(inputReference, true)
|
||||||
// assertEquals("3.85754470e+02", DataHolder.deviceConstant!!.d)
|
// viewModel.mapIntensityValues(inputSample, false)
|
||||||
// }
|
//
|
||||||
//
|
// val outputReference = TestDataGenerator().getOutputReferenceMapIntensityValues()
|
||||||
// @Test
|
// val outputSample = TestDataGenerator().getOutputSampleMapIntensityValues()
|
||||||
// fun test_mapPixelNumberToWavelength() {
|
//
|
||||||
// viewModel.mapDeviceConstants(data.inputRead)
|
// assertEquals(outputReference, DataHolder.intensityReferenceArray)
|
||||||
// viewModel.mapPixelNumberToWavelength()
|
// assertEquals(outputSample, viewModel.intensitySampleArray)
|
||||||
//
|
|
||||||
// val outputList = TestDataGenerator().getOutputMapPixelNumberToWavelength()
|
|
||||||
//
|
|
||||||
// assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, DataHolder.wavelengthToPixelArray.size)
|
|
||||||
// assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, outputList.size)
|
|
||||||
//
|
|
||||||
// val df = DecimalFormat("#.###")
|
|
||||||
// df.roundingMode = RoundingMode.FLOOR
|
|
||||||
//
|
|
||||||
// for (i in 0 until Constants.TEST_RIGHT_TOTAL_PIXEL){
|
|
||||||
// assertEquals(df.format(outputList[i]), df.format(DataHolder.wavelengthToPixelArray[i]))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// @Test
|
|
||||||
//// fun test_mapIntensityValues() {
|
|
||||||
//// val inputReference = TestDataGenerator().getInputReferenceMapIntensityValues()
|
|
||||||
//// val inputSample = TestDataGenerator().getInputSampleMapIntensityValues()
|
|
||||||
////
|
|
||||||
//// viewModel.mapIntensityValues(inputReference, true)
|
|
||||||
//// viewModel.mapIntensityValues(inputSample, false)
|
|
||||||
////
|
|
||||||
//// val outputReference = TestDataGenerator().getOutputReferenceMapIntensityValues()
|
|
||||||
//// val outputSample = TestDataGenerator().getOutputSampleMapIntensityValues()
|
|
||||||
////
|
|
||||||
//// assertEquals(outputReference, DataHolder.intensityReferenceArray)
|
|
||||||
//// assertEquals(outputSample, viewModel.intensitySampleArray)
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// fun test_mapWavelengthToAbsorbance() {
|
|
||||||
//
|
|
||||||
// viewModel.mapDeviceConstants(data.inputRead)
|
|
||||||
// viewModel.mapPixelNumberToWavelength()
|
|
||||||
// viewModel.mapIntensityValues(TestDataGenerator().getInputReferenceMapIntensityValues(), true)
|
|
||||||
// viewModel.mapIntensityValues(TestDataGenerator().getInputSampleMapIntensityValues(), false)
|
|
||||||
// viewModel.patientDetails = PatientData("Surya", 2, "Male", TestRightResultType.UNDEFINED)
|
|
||||||
// viewModel.mapWavelengthToAbsorbance()
|
|
||||||
//
|
|
||||||
// val wavelengthList = TestDataGenerator().getOutputMapPixelNumberToWavelength()
|
|
||||||
// val absorbanceList = TestDataGenerator().getOutputMapWavelengthToAbsorbance()
|
|
||||||
//
|
|
||||||
// val df = DecimalFormat("#.###")
|
|
||||||
// df.roundingMode = RoundingMode.FLOOR
|
|
||||||
//
|
|
||||||
// assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, viewModel.wavelengthToAbsorbance.size)
|
|
||||||
// for (i in 0 until Constants.TEST_RIGHT_TOTAL_PIXEL){
|
|
||||||
// assertEquals(df.format(wavelengthList[i]), df.format(viewModel.wavelengthToAbsorbance[i][0]))
|
|
||||||
// assertEquals(df.format(absorbanceList[i]), df.format(viewModel.wavelengthToAbsorbance[i][1]))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// fun testRightViewModel_calculateDataForCSV() {
|
|
||||||
//
|
|
||||||
// viewModel.mapDeviceConstants(data.inputRead)
|
|
||||||
// viewModel.mapPixelNumberToWavelength()
|
|
||||||
// viewModel.mapIntensityValues(data.printForReference, true)
|
|
||||||
// viewModel.mapIntensityValues(data.printForSample, false)
|
|
||||||
//// viewModel.patientDetails = PatientData("Surya", 2, "Male", null)
|
|
||||||
//// viewModel.calculateResults()
|
|
||||||
// viewModel.mapWavelengthToAbsorbance()
|
|
||||||
//
|
|
||||||
// for (each in viewModel.wavelengthToAbsorbance){
|
|
||||||
// println(each[0].toString() + " -> " + each[1])
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_mapWavelengthToAbsorbance() {
|
||||||
|
|
||||||
|
viewModel.mapDeviceConstants(data.inputRead)
|
||||||
|
viewModel.mapPixelNumberToWavelength()
|
||||||
|
viewModel.mapIntensityValues(TestDataGenerator().getInputReferenceMapIntensityValues(), true)
|
||||||
|
val mapIntensityValues = viewModel.mapIntensityValues(
|
||||||
|
TestDataGenerator().getInputSampleMapIntensityValues(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
viewModel.testDetails = UserData("Surya", "2", "Male")
|
||||||
|
viewModel.mapWavelengthToAbsorbance()
|
||||||
|
|
||||||
|
val wavelengthList = TestDataGenerator().getOutputMapPixelNumberToWavelength()
|
||||||
|
val absorbanceList = TestDataGenerator().getOutputMapWavelengthToAbsorbance()
|
||||||
|
|
||||||
|
val df = DecimalFormat("#.###")
|
||||||
|
df.roundingMode = RoundingMode.FLOOR
|
||||||
|
|
||||||
|
assertEquals(Constants.TEST_RIGHT_TOTAL_PIXEL, viewModel.wavelengthToAbsorbance.size)
|
||||||
|
for (i in 0 until Constants.TEST_RIGHT_TOTAL_PIXEL){
|
||||||
|
assertEquals(df.format(wavelengthList[i]), df.format(viewModel.wavelengthToAbsorbance[i][0]))
|
||||||
|
assertEquals(df.format(absorbanceList[i]), df.format(viewModel.wavelengthToAbsorbance[i][1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testRightViewModel_calculateDataForCSV() {
|
||||||
|
|
||||||
|
viewModel.mapDeviceConstants(data.inputRead)
|
||||||
|
viewModel.mapPixelNumberToWavelength()
|
||||||
|
viewModel.mapIntensityValues(data.printForReference, true)
|
||||||
|
viewModel.mapIntensityValues(data.printForSample, false)
|
||||||
|
// viewModel.patientDetails = PatientData("Surya", 2, "Male", null)
|
||||||
|
// viewModel.calculateResults()
|
||||||
|
viewModel.mapWavelengthToAbsorbance()
|
||||||
|
|
||||||
|
for (each in viewModel.wavelengthToAbsorbance){
|
||||||
|
println(each[0].toString() + " -> " + each[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.example.hpostesting.util
|
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
|
||||||
import kotlinx.coroutines.test.TestCoroutineScope
|
|
||||||
import kotlinx.coroutines.test.resetMain
|
|
||||||
import kotlinx.coroutines.test.setMain
|
|
||||||
import org.junit.rules.TestWatcher
|
|
||||||
import org.junit.runner.Description
|
|
||||||
|
|
||||||
@ExperimentalCoroutinesApi
|
|
||||||
class TestCoroutineRule : TestWatcher(), TestCoroutineScope by TestCoroutineScope() {
|
|
||||||
|
|
||||||
private val testCoroutineDispatcher = TestCoroutineDispatcher()
|
|
||||||
|
|
||||||
override fun starting(description: Description?) {
|
|
||||||
super.starting(description)
|
|
||||||
Dispatchers.setMain(testCoroutineDispatcher)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun finished(description: Description?) {
|
|
||||||
super.finished(description)
|
|
||||||
Dispatchers.resetMain()
|
|
||||||
cleanupTestCoroutines()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ buildscript {
|
|||||||
kotlin_version = '1.8.21'
|
kotlin_version = '1.8.21'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.1.1'
|
classpath 'com.android.tools.build:gradle:8.0.2'
|
||||||
classpath 'com.google.gms:google-services:4.4.0'
|
classpath 'com.google.gms:google-services:4.4.0'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user