Merge branch 'blood-group' into 'Homocube'

Blood group

See merge request sminnovations/hpos!1
This commit is contained in:
Mariya Varghese
2023-08-16 10:22:40 +00:00
4 changed files with 48 additions and 12 deletions

1
.idea/misc.xml generated
View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">

View File

@@ -62,7 +62,7 @@ dependencies {
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
implementation 'com.google.android.gms:play-services-auth:20.5.0'
implementation 'com.google.android.gms:play-services-auth:20.6.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
@@ -74,9 +74,9 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation 'com.opencsv:opencsv:4.6'
implementation 'com.github.mik3y:usb-serial-for-android:3.4.6'
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
implementation "androidx.fragment:fragment-ktx:1.6.0"
implementation "androidx.fragment:fragment-ktx:1.6.1"
// CSV read, write
implementation 'com.opencsv:opencsv:4.6'
@@ -85,20 +85,20 @@ dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
// Google ML Kit usign play services
implementation 'com.google.android.gms:play-services-code-scanner:16.0.0'
implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
//Room
implementation "androidx.room:room-ktx:2.6.0-alpha01"
implementation "androidx.room:room-runtime:2.6.0-alpha01"
kapt ("androidx.room:room-compiler:2.6.0-alpha01")
implementation "androidx.room:room-ktx:2.6.0-alpha02"
implementation "androidx.room:room-runtime:2.6.0-alpha02"
kapt ("androidx.room:room-compiler:2.6.0-alpha02")
//image
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0-beta01"
implementation "androidx.navigation:navigation-ui-ktx:2.7.0-beta01"
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0-rc01"
implementation "androidx.navigation:navigation-ui-ktx:2.7.0-rc01"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.46"

View File

@@ -10,6 +10,7 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import com.example.hpostesting.data.DataHolder
import com.example.hpostesting.data.constant.Constants
import com.example.hpostesting.data.constant.HemoCubeCommands
@@ -20,8 +21,15 @@ import com.example.hpostesting.presentation.UsbServiceListener
import com.example.hpostesting.presentation.dashboard.DashboardActivity
import com.example.hpostesting.presentation.utils.MyDialogListener
import com.example.hpostesting.presentation.utils.UIUtils
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import kotlinx.coroutines.withContext
import kotlin.math.log10
class HemoCubeFragment : Fragment() {
@@ -34,7 +42,7 @@ class HemoCubeFragment : Fragment() {
private var resultData: String = ""
private var isUsingExistingBuffer = false
private var isTestOngoing = false
private var bloodGroup: String = ""
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
@@ -53,6 +61,15 @@ class HemoCubeFragment : Fragment() {
private fun initViews() {
binding.btnSubmit.setOnClickListener {
val bloodGroupText = binding.etBloodGroup.text.toString()
if (bloodGroupText.isNullOrBlank() || bloodGroupText == "Select Blood Group") {
binding.etBloodGroup.error = "Please enter your blood group"
Toast.makeText(context, "Please enter your blood group", Toast.LENGTH_SHORT).show()
} else {
binding.etBloodGroup.error = null
bloodGroup = bloodGroupText
checkBloodGroup()
}
it.isEnabled = false
binding.progressBar.visibility = View.VISIBLE
fetchResult()
@@ -91,6 +108,24 @@ class HemoCubeFragment : Fragment() {
}
}
private fun checkBloodGroup() {
binding.apply {
// bloodGroup = etBloodGroup.text.toString()
val db: FirebaseFirestore = Firebase.firestore
// Launch a new coroutine scope
lifecycleScope.launch {
val userdata =
db.collection("patientData").whereEqualTo("_id", hemoCubeViewModel.testDetails?._id)
.get().await()
if (userdata.documents.isNotEmpty()) {
db.collection("patientData").document(userdata.documents[0].id)
.update("bloodGroup", bloodGroup)
}
}
}
}
private fun observeViewModel() {
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
if (result == "Success") {

View File

@@ -30,7 +30,7 @@ class HemoCubeViewModel @Inject constructor(
) : ViewModel() {
var isServiceConnected = false
val progressBar = MutableLiveData(false)
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
val messages = MutableLiveData<String>()
private val sharedPreference: SharedPreferences = context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)