Blood-Group is added
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DesignSurface">
|
<component name="DesignSurface">
|
||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ plugins {
|
|||||||
//apply plugin: 'kotlin-android'
|
//apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
@@ -62,7 +62,7 @@ dependencies {
|
|||||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||||
implementation 'com.google.firebase:firebase-storage-ktx'
|
implementation 'com.google.firebase:firebase-storage-ktx'
|
||||||
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
|
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-location:21.0.1'
|
||||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.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 "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
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
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
implementation 'com.opencsv:opencsv:4.6'
|
||||||
@@ -85,20 +85,20 @@ dependencies {
|
|||||||
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
||||||
|
|
||||||
// Google ML Kit usign play services
|
// 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
|
//Room
|
||||||
implementation "androidx.room:room-ktx:2.6.0-alpha01"
|
implementation "androidx.room:room-ktx:2.6.0-alpha02"
|
||||||
implementation "androidx.room:room-runtime:2.6.0-alpha01"
|
implementation "androidx.room:room-runtime:2.6.0-alpha02"
|
||||||
kapt ("androidx.room:room-compiler:2.6.0-alpha01")
|
kapt ("androidx.room:room-compiler:2.6.0-alpha02")
|
||||||
|
|
||||||
//image
|
//image
|
||||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
|
||||||
|
|
||||||
// Navigation Component
|
// Navigation Component
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0-beta01"
|
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0-rc01"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.0-beta01"
|
implementation "androidx.navigation:navigation-ui-ktx:2.7.0-rc01"
|
||||||
|
|
||||||
//Dagger - Hilt
|
//Dagger - Hilt
|
||||||
implementation "com.google.dagger:hilt-android:2.46"
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||||||
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
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
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.dashboard.DashboardActivity
|
||||||
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.firestore.FirebaseFirestore
|
||||||
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
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
|
import kotlin.math.log10
|
||||||
|
|
||||||
class HemoCubeFragment : Fragment() {
|
class HemoCubeFragment : Fragment() {
|
||||||
@@ -34,7 +42,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
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 bloodGroup: String = ""
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
@@ -53,6 +61,15 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
binding.btnSubmit.setOnClickListener {
|
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
|
it.isEnabled = false
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
fetchResult()
|
fetchResult()
|
||||||
@@ -91,6 +108,26 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkBloodGroup() {
|
||||||
|
binding.apply {
|
||||||
|
val 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() {
|
private fun observeViewModel() {
|
||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference: SharedPreferences = context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
private val sharedPreference: SharedPreferences = context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
|||||||
@@ -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.0'
|
classpath 'com.android.tools.build:gradle:8.0.2'
|
||||||
classpath 'com.google.gms:google-services:4.3.15'
|
classpath 'com.google.gms:google-services:4.3.15'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.0'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.0'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user