Merge branch 'repeat-readings' into 'dev'
support auto multiple readings per sample See merge request sminnovations/hpos!22
This commit is contained in:
@@ -254,6 +254,7 @@ object Constants {
|
|||||||
const val INCUBATION_TIME_MIN = 0
|
const val INCUBATION_TIME_MIN = 0
|
||||||
const val INCUBATION_TIME_MAX = 1400
|
const val INCUBATION_TIME_MAX = 1400
|
||||||
const val BATTERY_LEVEL_MIN = 0
|
const val BATTERY_LEVEL_MIN = 0
|
||||||
|
const val READINGS_PER_SAMPLE = 3
|
||||||
|
|
||||||
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
||||||
"HCV-000-3001" to listOf(
|
"HCV-000-3001" to listOf(
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import android.os.Bundle
|
|||||||
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.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Spinner
|
||||||
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
|
||||||
@@ -61,13 +64,15 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private var deviceHardwareId = ""
|
private var deviceHardwareId = ""
|
||||||
private var allErrorMessages = ""
|
private var allErrorMessages = ""
|
||||||
private var testStatusCode = 0.0
|
private var testStatusCode = 0.0
|
||||||
|
private var repeatReadingCount = 0
|
||||||
|
private var readingsPerSample = Constants.READINGS_PER_SAMPLE
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentHemoCubeReferenceBinding.inflate(inflater, container, false)
|
binding = FragmentHemoCubeReferenceBinding.inflate(inflater, container, false)
|
||||||
sharedPreferences =
|
sharedPreferences =
|
||||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,25 +135,36 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.tvDeviceMessages.visibility = View.VISIBLE
|
binding.tvDeviceMessages.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// val spinner: Spinner = binding.spinnerSolutions
|
||||||
|
// val options = arrayOf("KMnO4", "Tartrazine", "AR", "HB", "Blood")
|
||||||
|
// val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, options)
|
||||||
|
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
// spinner.adapter = adapter
|
||||||
|
// spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
// override fun onItemSelected(
|
||||||
|
// parent: AdapterView<*>?,
|
||||||
|
// view: View?,
|
||||||
|
// position: Int,
|
||||||
|
// id: Long
|
||||||
|
// ) {
|
||||||
|
// val selectedValue: String = options[position]
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
showToast(R.string.test_upload)
|
showToast(R.string.test_upload)
|
||||||
|
handleReadingFinish()
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.visibility = View.GONE
|
|
||||||
val i = Intent(
|
|
||||||
requireContext().applicationContext, DashboardActivity::class.java
|
|
||||||
)
|
|
||||||
startActivity(i)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (result == "Local") {
|
if (result == "Local") {
|
||||||
showToast(R.string.internt_not_local)
|
showToast(R.string.internt_not_local)
|
||||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
if (result == "Error") {
|
if (result == "Error") {
|
||||||
showToast(R.string.error_local)
|
showToast(R.string.error_local)
|
||||||
@@ -186,6 +202,34 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleReadingFinish() {
|
||||||
|
if (allReadingsComplete()) {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
val i = Intent(
|
||||||
|
requireContext().applicationContext, DashboardActivity::class.java
|
||||||
|
)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hemoCubeViewModel.messages.postValue("Reading $repeatReadingCount completed")
|
||||||
|
resetTest()
|
||||||
|
startSampleProcess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun allReadingsComplete(): Boolean {
|
||||||
|
return repeatReadingCount >= readingsPerSample
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resetTest() {
|
||||||
|
testStatusCode = 0.0
|
||||||
|
allErrorMessages = ""
|
||||||
|
validationError = false
|
||||||
|
resultData = ""
|
||||||
|
currentResultData = ""
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkAndStartProcess() {
|
private fun checkAndStartProcess() {
|
||||||
startBufferProcess()
|
startBufferProcess()
|
||||||
}
|
}
|
||||||
@@ -486,11 +530,20 @@ class HemoCubeFragment : Fragment() {
|
|||||||
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
repeatReadingCount += 1
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
|
||||||
binding.btnSubmit.isEnabled = true
|
if (readingsPerSample == 1) {
|
||||||
binding.btnSubmit.isClickable = true
|
activity?.runOnUiThread {
|
||||||
binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
binding.btnSubmit.isEnabled = true
|
||||||
|
binding.btnSubmit.isClickable = true
|
||||||
|
// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
|
binding.ivCheck.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
|
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -917,10 +970,4 @@ class HemoCubeFragment : Fragment() {
|
|||||||
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||||
return coefficient1 * ratio + coefficient2
|
return coefficient1 * ratio + coefficient2
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDeviceIdMismatch(deviceId: String, loginId: String): Boolean {
|
|
||||||
if (!deviceId.isNullOrEmpty() && !loginId.isNullOrEmpty() && deviceId.last() != loginId.last())
|
|
||||||
return true
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,25 +208,44 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
<ScrollView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/tv_device_messages"
|
||||||
android:layout_height="wrap_content"
|
style="@style/title1_1"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_width="414dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_height="201dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="#SS1\n#SC1"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="11sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||||
app:layout_constraintTop_toBottomOf="@id/error_message">
|
|
||||||
|
|
||||||
<TextView
|
<!-- <Spinner-->
|
||||||
android:id="@+id/tv_device_messages"
|
<!-- android:id="@+id/spinner_solutions"-->
|
||||||
style="@style/title1_1"
|
<!-- android:layout_width="0dp"-->
|
||||||
android:layout_width="match_parent"
|
<!-- android:layout_height="wrap_content"-->
|
||||||
android:layout_height="wrap_content"
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
android:gravity="center"
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
android:textColor="@color/black"
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
android:textSize="11sp"
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||||
android:visibility="gone" />
|
|
||||||
</ScrollView>
|
<!-- <Spinner-->
|
||||||
|
<!-- android:id="@+id/spinner_concentration"-->
|
||||||
|
<!-- android:layout_width="0dp"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/spinner_solutions" />-->
|
||||||
|
|
||||||
|
<!-- <Spinner-->
|
||||||
|
<!-- android:id="@+id/spinner_volume"-->
|
||||||
|
<!-- android:layout_width="0dp"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/spinner_concentration" />-->
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
@@ -241,6 +260,19 @@
|
|||||||
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/error_message" />
|
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_check"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:src="@drawable/check"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_device_messages" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user