Fetching caliberation value done
This commit is contained in:
@@ -3,6 +3,6 @@ package com.example.hpostesting.data.model.patient
|
|||||||
data class DeviceData (
|
data class DeviceData (
|
||||||
val deviceId: String? = "",
|
val deviceId: String? = "",
|
||||||
val deviceType: String? = "",
|
val deviceType: String? = "",
|
||||||
val coefficient: List<Double>? = null,
|
val coefficients: List<Double>? = null,
|
||||||
val calibratedAt: String
|
val calibratedAt: String
|
||||||
)
|
)
|
||||||
@@ -116,7 +116,19 @@ class DatabaseRepository : Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDeviceDataById(): List<DeviceData> {
|
suspend fun getDeviceData(): List<DeviceData> {
|
||||||
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
||||||
|
val querySnapshot = db.collection("devices").get().await()
|
||||||
|
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
||||||
|
|
||||||
|
// Find the DeviceData object with the specified deviceId
|
||||||
|
return allDeviceDataList.find { it.deviceId == deviceId }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
hemoCubeViewModel.getDeviceData()
|
hemoCubeViewModel.getDeviceData()
|
||||||
|
|
||||||
|
|
||||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
deviceData = it
|
deviceData = it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,13 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
|
|
||||||
|
|
||||||
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val deviceData = MutableLiveData<List<DeviceData>>()
|
val deviceData = MutableLiveData<List<DeviceData>>()
|
||||||
|
val deviceIdToRetrieve = deviceData.value?.firstOrNull()?.deviceId
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
val networkStatusLiveData: LiveData<Boolean>
|
||||||
get() = _networkStatusLiveData
|
get() = _networkStatusLiveData
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
@@ -63,12 +68,20 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun getDeviceData() = viewModelScope.launch {
|
fun getDeviceData() = viewModelScope.launch {
|
||||||
repository.getDeviceDataById().let {
|
deviceIdToRetrieve?.let { deviceId ->
|
||||||
deviceData.postValue(it)
|
val deviceIdinfo = repository.getDeviceDataById(deviceId)
|
||||||
|
deviceData.postValue(listOf(deviceIdinfo!!))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun addResultTestToDb() {
|
private fun addResultTestToDb() {
|
||||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
||||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
style="@style/title2"
|
style="@style/title2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="80dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:hint="Result"
|
android:hint="Result"
|
||||||
|
|||||||
Reference in New Issue
Block a user