Compare commits
1 Commits
2.1.104
...
API-CALLS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf2e904445 |
@@ -14,13 +14,13 @@ android {
|
||||
compileSdk 34
|
||||
namespace 'in.sminnovations.hpostesting'
|
||||
|
||||
// dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production
|
||||
// prod - production, preprod - preproduction, quality - qc, dev - development
|
||||
defaultConfig {
|
||||
applicationId "in.sminnovations.hpostesting.quality"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 106
|
||||
versionName "2.1.106"
|
||||
versionCode 100
|
||||
versionName "2.1.100"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -112,8 +112,6 @@ dependencies {
|
||||
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
|
||||
androidTestImplementation 'org.mockito:mockito-inline:3.12.4'
|
||||
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
|
||||
testImplementation 'org.powermock:powermock-api-mockito2:2.0.9'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
|
||||
|
||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'
|
||||
|
||||
@@ -95,7 +95,6 @@
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_dashboard"
|
||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||
android:screenOrientation="portrait"
|
||||
tools:ignore="AppLinkUrlError,MissingClass">
|
||||
|
||||
<intent-filter>
|
||||
@@ -120,12 +119,8 @@
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.MONKEY"/>
|
||||
<category android:name="android.intent.category.LAUNCHER_APP" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.example.hpostesting.data.constant
|
||||
|
||||
object Constants {
|
||||
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
||||
const val HEMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
|
||||
const val BASE_URL = "www.google.com"
|
||||
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val MOLBIO_INTEGRATION = false
|
||||
const val MOLBIO_INTERGATION = false
|
||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||
const val DEVICE_ID_API = "deviceIDAPI"
|
||||
|
||||
@@ -5,8 +5,5 @@ data class DiagnosticsData (
|
||||
var appVersion: String? = "",
|
||||
var deviceType: String = "HEMOCUBE",
|
||||
var deviceData: String = "",
|
||||
var devicePassword: String = "",
|
||||
var deviceNatsToken: String = "",
|
||||
var accessToken: String = "",
|
||||
var runTime: String = ""
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.hpostesting.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
@@ -31,7 +32,7 @@ class LogFileManagerImpl @Inject constructor(private val context: Context) : Log
|
||||
|
||||
file
|
||||
} catch (e: IOException) {
|
||||
// Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||
Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,54 +208,74 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
//Setting up the SDK handler
|
||||
|
||||
//Setting up the SDK handler
|
||||
sdkHandler = SDKHandler(this)
|
||||
|
||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
||||
|
||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
||||
sdkHandler!!.dcssdkSetDelegate(this)
|
||||
|
||||
//this command is telling the sdk that we're going to be connecting to the scanner via USB
|
||||
|
||||
//this command is telling the sdk that we're going to be connecting to the scanner via USB
|
||||
sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_SNAPI)
|
||||
|
||||
|
||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
||||
//first we use bitmapping to set these values into the notifications_mask.
|
||||
|
||||
|
||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
||||
//first we use bitmapping to set these values into the notifications_mask.
|
||||
var notifications_mask = 0
|
||||
// We would like to subscribe to all barcode events
|
||||
// We would like to subscribe to all barcode events
|
||||
notifications_mask =
|
||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||
// subscribe to events set in notification mask
|
||||
// subscribe to events set in notification mask
|
||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||
|
||||
|
||||
//so adding all the scanners to the mScannerInfoList, then connecting to the first scanner.
|
||||
//There's only one scanner so this step is unnecessary, I did it thinking about possible scalability.
|
||||
//here I just get the list of available scanners which also returns the USB scanner attached to the tinker board.
|
||||
|
||||
|
||||
//so adding all the scanners to the mScannerInfoList, then connecting to the first scanner.
|
||||
//There's only one scanner so this step is unnecessary, I did it thinking about possible scalability.
|
||||
//here I just get the list of available scanners which also returns the USB scanner attached to the tinker board.
|
||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
||||
Log.e("scannersize",sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
||||
|
||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||
|
||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||
if (mScannerInfoList.isNotEmpty()) {
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
} else {
|
||||
Toast.makeText(this,"Error", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun pullTrigger() {
|
||||
// Check if the list is not empty before accessing its elements
|
||||
if (mScannerInfoList.isNotEmpty()) {
|
||||
// Only proceed if the scanner is not active
|
||||
if (!mScannerInfoList[0].isActive) {
|
||||
sdkHandler?.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
}
|
||||
val inXML = "<inArgs><scannerID> 1 </scannerID></inArgs>"
|
||||
val outXML = StringBuilder()
|
||||
val result: DCSSDK_RESULT =
|
||||
sdkHandler!!.dcssdkExecuteCommandOpCodeInXMLForScanner(
|
||||
DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER, inXML, outXML, mScannerInfoList[0].scannerID // Ensure you're using the correct scanner ID
|
||||
)
|
||||
if (result == DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS) {
|
||||
Log.d("Scanning", "Success")
|
||||
} else if (result == DCSSDK_RESULT.DCSSDK_RESULT_FAILURE) {
|
||||
Log.d("Scanning", "Failed")
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the list is empty, perhaps notify the user or log an error
|
||||
Log.e("ScannerError", "No scanners are connected or available.")
|
||||
Toast.makeText(this, "No scanner is Available", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
||||
fun pullTrigger() {
|
||||
if (!mScannerInfoList[0].isActive) {
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
}
|
||||
val inXML = "<inArgs><scannerID> 1 </scannerID></inArgs>"
|
||||
val outXML = StringBuilder()
|
||||
val result: DCSSDK_RESULT =
|
||||
sdkHandler!!.dcssdkExecuteCommandOpCodeInXMLForScanner(
|
||||
DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER, inXML, outXML, 1
|
||||
)
|
||||
if (result == DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS) Log.d(
|
||||
"Scanning",
|
||||
"Success"
|
||||
) else if (result == DCSSDK_RESULT.DCSSDK_RESULT_FAILURE) Log.d("Scanning", "Failed")
|
||||
//new MyAsyncTask(1, DCSSDKDefs.DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER,null).execute(inXML);
|
||||
}
|
||||
|
||||
//this function is called if barcode is detected.
|
||||
override fun dcssdkEventBarcode(barcodeData: ByteArray?, barcodeType: Int, fromScannerID: Int) {
|
||||
|
||||
@@ -23,7 +23,6 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
fun connect() {
|
||||
Log.d(TAG, "TRY TO CONNECT")
|
||||
Thread {
|
||||
|
||||
val seedString = "SUAEB5PUWNS6C2HUV3MFI6HUDEAPGPFPBHMI73NHIQATCDD2BWALVEZXZ4"
|
||||
val seedBytes = seedString.toCharArray()
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Spinner
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
@@ -31,9 +30,6 @@ class AssuranceControlsFragment: Fragment() {
|
||||
binding = FragmentAssuranceControlsBinding.inflate(inflater, container, false)
|
||||
sharedPreferences =
|
||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
|
||||
DataHolder.hemoCubeTestData!!.solution = ""
|
||||
DataHolder.hemoCubeTestData!!.volume = ""
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -46,7 +42,7 @@ class AssuranceControlsFragment: Fragment() {
|
||||
// binding.btnSubmit.visibility = View.GONE
|
||||
|
||||
val solutionSpinner: Spinner = binding.spinnerSolutions
|
||||
val solutionOptions = arrayOf("Select solution", "Tartrazine", "Acid Red")
|
||||
val solutionOptions = arrayOf("Select solution", "Tartrazine", "AR")
|
||||
val solutionAdapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, solutionOptions)
|
||||
solutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
solutionSpinner.adapter = solutionAdapter
|
||||
@@ -125,13 +121,6 @@ class AssuranceControlsFragment: Fragment() {
|
||||
volumeSpinner.setSelection(volumePosition)
|
||||
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
val selectedSolution = DataHolder.hemoCubeTestData!!.solution
|
||||
val selectedVolume = DataHolder.hemoCubeTestData!!.volume
|
||||
if (selectedSolution == "Select solution" || selectedVolume == "Select volume") {
|
||||
Toast.makeText(requireContext(), "Please select both solution and volume", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
DataHolder.hemoCubeTestData!!.quickCapture = true
|
||||
val currentUnixTime = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Instant.now().epochSecond
|
||||
|
||||
@@ -145,18 +145,18 @@ class AutoDacActivity: AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -12,15 +12,11 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.presentation.UsbServiceListener
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class AutoDacFragment: Fragment() {
|
||||
|
||||
@@ -105,6 +101,8 @@ class AutoDacFragment: Fragment() {
|
||||
HemoCubeCommands.AUTO_DAC_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
|
||||
|
||||
}
|
||||
override fun onUsbError(e: Exception?) {
|
||||
autoDacViewModel.progressBar.postValue(false)
|
||||
@@ -143,22 +141,22 @@ class AutoDacFragment: Fragment() {
|
||||
}
|
||||
|
||||
if (resultData.contains("#CC")) {
|
||||
autoDacViewModel.addAutoDacDataToDb(
|
||||
DiagnosticsData(
|
||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||
devicePassword = sharedPreferences.getString(Constants.DEVICE_PASSWORD_API, "").toString(),
|
||||
deviceNatsToken = sharedPreferences.getString(Constants.NATS_TOKEN, "").toString(),
|
||||
accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString(),
|
||||
deviceData = resultData,
|
||||
runTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
)
|
||||
)
|
||||
activity?.runOnUiThread {
|
||||
binding.ivCheck.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
||||
// autoDacViewModel.addAutoDacDataToDb(
|
||||
// DiagnosticsData(
|
||||
// deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||
// deviceData = resultData,
|
||||
// runTime = SimpleDateFormat(
|
||||
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
// ).format(Calendar.getInstance().time)
|
||||
// )
|
||||
// )
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
@@ -170,6 +168,7 @@ class AutoDacFragment: Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun parseData(inputData: List<String>): List<Pair<String, String>> {
|
||||
val pattern = Regex("([A-Z]+)\\s(\\d+)")
|
||||
val parsedData = mutableListOf<Pair<String, String>>()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.example.hpostesting.presentation.buffercheck
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PendingIntent
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ComponentName
|
||||
@@ -125,22 +124,21 @@ open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("MutableImplicitPendingIntent")
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -144,18 +144,18 @@ class CalibrationActivity: AppCompatActivity() {
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.hpostesting.presentation.dashboard
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
@@ -15,13 +14,12 @@ import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
||||
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
||||
|
||||
|
||||
class GalleryFragment : Fragment() {
|
||||
|
||||
private var _binding: FragmentGalleryBinding? = null
|
||||
@@ -84,19 +82,6 @@ class GalleryFragment : Fragment() {
|
||||
startActivity(Intent(requireContext(), DeviceActivity::class.java))
|
||||
}
|
||||
|
||||
binding.btnFirefox.setOnClickListener {
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.component = ComponentName("org.mozilla.firefox", "org.mozilla.gecko.BrowserApp")
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
binding.btnFiles.setOnClickListener {
|
||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
intent.type = "file/*"
|
||||
startActivity(intent)
|
||||
|
||||
}
|
||||
|
||||
userid = sharedPreferences.getString(Constants.USER_ID, "").toString()
|
||||
binding.tvSubtitle4.text = "Login ID : ${userid}"
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ class HomeFragment : Fragment() {
|
||||
loadUserData()
|
||||
setSearch()
|
||||
checkForLocalDBData()
|
||||
// This function could be called directly where you need to perform the login operation.
|
||||
forceLogin()
|
||||
checkForTokenAndUpdate()
|
||||
} else {
|
||||
binding.internetAvailableCL.visibility = View.GONE
|
||||
@@ -188,12 +190,31 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun forceLogin() {
|
||||
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||
if (userID.isNotEmpty() && password.isNotEmpty() ) {
|
||||
// Directly call the login API without checking the access token
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
} else {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Contact Help and get your device provision done",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun checkForTokenAndUpdate() {
|
||||
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
||||
if (accessToken.isEmpty()) {
|
||||
if (accessToken.isEmpty()) {
|
||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||
} else {
|
||||
if (isTokenExpired(accessToken)) {
|
||||
@@ -203,16 +224,8 @@ class HomeFragment : Fragment() {
|
||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||
hemoCubeViewModel.uploadLogs()
|
||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
"Contact Help and get your device provision done",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
|
||||
@@ -24,11 +24,15 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationFragment
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationViewModel
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityCalibrationBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityDeviceBinding
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@@ -144,18 +148,18 @@ class DeviceActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
@@ -32,7 +32,7 @@ class DeviceFragment : Fragment() {
|
||||
): View {
|
||||
binding = FragmentDeviceBinding.inflate(inflater, container, false)
|
||||
sharedPreferences =
|
||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.example.hpostesting.presentation.deviceinfo
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
@@ -11,15 +14,16 @@ import javax.inject.Inject
|
||||
class DeviceViewModel @Inject constructor(
|
||||
private val hemoCubeDao: HemoCubeDao,
|
||||
private val repository: Repository,
|
||||
context: Context
|
||||
) : ViewModel() {
|
||||
var isServiceConnected = false
|
||||
val progressBar = MutableLiveData(false)
|
||||
val messages = MutableLiveData<String>()
|
||||
// private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
// val allUserData = hemoCubeDao.getAll()
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
// val networkStatusLiveData: LiveData<Boolean>
|
||||
// get() = _networkStatusLiveData
|
||||
val networkStatusLiveData: LiveData<Boolean>
|
||||
get() = _networkStatusLiveData
|
||||
val fireBaseUpload = MutableLiveData<String>()
|
||||
|
||||
}
|
||||
@@ -144,18 +144,18 @@ class DeviceProvisionActivity : AppCompatActivity() {
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getDeviceId() {
|
||||
(activity as DeviceProvisionActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
@@ -145,19 +146,40 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun extractV2HardwareId(input: String): String? {
|
||||
val pattern = Regex("SNS\\s*(.*?)\\s*SNE")
|
||||
val matchResult: MatchResult? = pattern.find(input)
|
||||
// private fun handleUsbData() {
|
||||
// when {
|
||||
// resultData.contains("SNE") -> {
|
||||
// val pattern = Regex("HPP1-\\d{4}")
|
||||
// val matchResult = pattern.find(resultData)
|
||||
// val hardwareId = matchResult?.value
|
||||
//
|
||||
// if (hardwareId.toString().length == 9) {
|
||||
// with(sharedPreferences.edit()) {
|
||||
// putString(Constants.DEVICE_ID, hardwareId)
|
||||
// apply()
|
||||
// }
|
||||
// activity?.runOnUiThread {
|
||||
// binding.btnSubmit.visibility = View.VISIBLE
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return matchResult?.groups?.get(1)?.value
|
||||
}
|
||||
|
||||
private fun handleUsbData() {
|
||||
when {
|
||||
resultData.contains("SNE") -> {
|
||||
val hardwareId = extractV2HardwareId(resultData)
|
||||
// Updated pattern to match all specified formats
|
||||
val pattern = Regex("HPP1-\\d{4}|HPP1-\\d{3}-\\d{4}|HCV-\\d{3}-\\d{4}")
|
||||
val matchResult = pattern.find(resultData)
|
||||
val hardwareId = matchResult?.value
|
||||
|
||||
if (!hardwareId.isNullOrBlank()) {
|
||||
// Assuming hardwareId validation is based on matching the pattern,
|
||||
// so no need to check length explicitly here.
|
||||
// If there are more specific requirements for validation,
|
||||
// they need to be implemented accordingly.
|
||||
if (hardwareId != null) { // Check if hardwareId is not null instead
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, hardwareId)
|
||||
apply()
|
||||
@@ -169,4 +191,5 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
@@ -146,18 +148,18 @@ class DiagnosticsActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -148,9 +148,6 @@ class DiagnosticsFragment : Fragment() {
|
||||
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
||||
diagnosticsViewModel.addDiagnosticsDataToDb(DiagnosticsData(
|
||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||
devicePassword = sharedPreferences.getString(Constants.DEVICE_PASSWORD_API, "").toString(),
|
||||
deviceNatsToken = sharedPreferences.getString(Constants.NATS_TOKEN, "").toString(),
|
||||
accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString(),
|
||||
deviceData = resultData,
|
||||
runTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
|
||||
@@ -153,7 +153,7 @@ class HemoCubeFragment : Fragment() {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
uploadedToMolbio = true
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
if (Constants.MOLBIO_INTERGATION) {
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
@@ -805,8 +805,8 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
calculatedPredictedDenovixRatio = fittedAbs3.div(fittedAbs1)
|
||||
|
||||
val slope = (led4Average - led1Average) / (431-411)
|
||||
val calculatedSlopeRatio = abs(led2Average / slope)
|
||||
val slope = (led1Average - led2Average) / (435 - 415)
|
||||
val calculatedSlopeRatio = abs(led3Average / slope)
|
||||
val slopeClass = slopeRatioClassification(calculatedSlopeRatio)
|
||||
|
||||
if (fittedAbs1 <= fittedAbs2) {
|
||||
@@ -874,8 +874,8 @@ class HemoCubeFragment : Fragment() {
|
||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||
this.slopeRatioClass = slopeClass
|
||||
this.classificationResult = findResultWithAdditionalMethods(deviceRatio, deviceRatioClass, slopeRatio)
|
||||
hemoCubeViewModel.messages.postValue("${this.classificationResult} \n Device Ratio: ${"%.3f".format(this.deviceRatio)} \n Slope Ratio: ${"%.3f".format(this.slopeRatio)}")
|
||||
this.classificationResult = deviceRatioClass //findResult(calculatedRatio)
|
||||
hemoCubeViewModel.messages.postValue("${this.deviceRatioClass} ${if (led4Average < 0.17) " - Low Hb" else ""}\n")
|
||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||
this.errorMessages = testState.allErrorMessages
|
||||
@@ -909,36 +909,50 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun findResultWithAdditionalMethods(deviceRatio: Double?, deviceRatioClass: String?, slopeRatio: Double?): String {
|
||||
fun findResult(calculatedRatio: Double?): String {
|
||||
try {
|
||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||
if (deviceRatio != null) {
|
||||
if (slopeRatio != null) {
|
||||
if (deviceRatioClass == "Normal" && slopeRatio > 45.0)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
hemoCubeViewModel.messages.postValue("result classification")
|
||||
if (calculatedRatio != null) {
|
||||
if (calculatedRatio < 0.05)
|
||||
return getString(R.string.error_repeat_test_higher_volume)
|
||||
if (calculatedRatio in 0.05..0.155) {
|
||||
return getString(R.string.normal)
|
||||
}
|
||||
if (calculatedRatio in 0.155..0.175)
|
||||
return getString(R.string.negative_borderline)
|
||||
if (calculatedRatio in 0.175..0.22)
|
||||
return getString(R.string.sickle_cell_trait)
|
||||
if (calculatedRatio in 0.22..0.25)
|
||||
return getString(R.string.positive_for_sickle_cell)
|
||||
if (calculatedRatio in 0.25..0.35)
|
||||
return getString(R.string.sickle_cell_disease)
|
||||
if (calculatedRatio > 0.35)
|
||||
return getString(R.string.error_repeat_test_lower_volume)
|
||||
} else {
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
handleException(e)
|
||||
return "Error"
|
||||
showToast(R.string.error_classification)
|
||||
Firebase.crashlytics.recordException(e)
|
||||
return getString(R.string.error)
|
||||
}
|
||||
return deviceRatioClass.toString()
|
||||
return getString(R.string.invalid)
|
||||
}
|
||||
|
||||
fun deviceRatioClassification(ratio: Double?): String {
|
||||
try {
|
||||
if (ratio != null) {
|
||||
if (ratio in 0.001..0.23) {
|
||||
if (ratio in 0.1..0.29) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in 0.23..0.24)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
if (ratio in 0.24..0.29)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.29..0.32)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
if (ratio in 0.32..0.35)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.35..0.38)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
if (ratio in 0.32..Double.POSITIVE_INFINITY)
|
||||
if (ratio in 0.38..0.5)
|
||||
return "Sickle Cell Disease"
|
||||
} else {
|
||||
return "Invalid"
|
||||
|
||||
@@ -130,18 +130,18 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -127,23 +127,23 @@ class TrueHemeActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("MutableImplicitPendingIntent", "UnspecifiedRegisterReceiverFlag")
|
||||
@SuppressLint("MutableImplicitPendingIntent")
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.example.hpostesting.presentation.trueheme
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
@@ -34,7 +33,6 @@ import kotlin.math.abs
|
||||
import kotlin.math.log10
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@SuppressLint("SetTextI18n")
|
||||
class TrueHemeFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentTruehemeSampleBinding
|
||||
@@ -156,7 +154,7 @@ class TrueHemeFragment : Fragment() {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
uploadedToMolbio = true
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
if (Constants.MOLBIO_INTERGATION) {
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
@@ -1143,8 +1141,4 @@ class TrueHemeFragment : Fragment() {
|
||||
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||
return coefficient1 * ratio + coefficient2
|
||||
}
|
||||
|
||||
private fun reconnect() {
|
||||
(activity as HemocubeActivity).reconnectDevice()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<vector android:height="24dp" android:tint="@color/primary"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/primary" android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
|
||||
</vector>
|
||||
@@ -108,33 +108,4 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
||||
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_firefox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/Firefox"
|
||||
android:textColor="@color/white"
|
||||
app:cornerRadius="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_files"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:clickable="false"
|
||||
android:text="@string/Files"
|
||||
android:textColor="@color/white"
|
||||
app:cornerRadius="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btn_firefox" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -115,8 +115,6 @@
|
||||
<string name="assurance_controls">Quality Assurance</string>
|
||||
<string name="calibration">Calibration</string>
|
||||
<string name="deviceProvision">Device Provision</string>
|
||||
<string name="Firefox">Firefox</string>
|
||||
<string name="Files">Files</string>
|
||||
<string name="deviceinfo">Device Information</string>
|
||||
<string name="place_buffer">Start</string>
|
||||
<string name="Start_Sample">Start Sample</string>
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
//
|
||||
//@PrepareForTest(Object::class)
|
||||
//class AuthInterceptorTest {
|
||||
//
|
||||
//// @Rule
|
||||
//// val rule = PowerMockRule()
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var sharedPreferences: SharedPreferences
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var chain: Interceptor.Chain
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var request: okhttp3.Request
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var response: Response
|
||||
//
|
||||
// @Captor
|
||||
// private lateinit var captor: ArgumentCaptor<okhttp3.Request>
|
||||
//
|
||||
// private lateinit var authInterceptor: AuthInterceptor
|
||||
//
|
||||
// @Before
|
||||
// fun setup() {
|
||||
// MockitoAnnotations.initMocks(this)
|
||||
// authInterceptor = AuthInterceptor(sharedPreferences)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun intercept_withToken_shouldAddAuthorizationHeader() {
|
||||
// // Arrange
|
||||
// val accessToken = "fakeAccessToken"
|
||||
// `when`(sharedPreferences.getString(Constants.ACCESS_TOKEN, null)).thenReturn(accessToken)
|
||||
// `when`(chain.request()).thenReturn(request)
|
||||
// `when`(chain.proceed(request)).thenReturn(response)
|
||||
//
|
||||
// // Act
|
||||
// val result = authInterceptor.intercept(chain)
|
||||
//
|
||||
// // Assert
|
||||
// verify(chain).proceed(captor.capture())
|
||||
// assertEquals("Bearer $accessToken", captor.value.header("Authorization"))
|
||||
// assertEquals(response, result)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun intercept_withoutToken_shouldNotAddAuthorizationHeader() {
|
||||
// // Arrange
|
||||
// `when`(sharedPreferences.getString(Constants.ACCESS_TOKEN, null)).thenReturn(null)
|
||||
// `when`(chain.request()).thenReturn(request)
|
||||
// `when`(chain.proceed(request)).thenReturn(response)
|
||||
//
|
||||
// // Act
|
||||
// val result = authInterceptor.intercept(chain)
|
||||
//
|
||||
// // Assert
|
||||
// verify(chain).proceed(captor.capture())
|
||||
// assertEquals(null, captor.value.header("Authorization"))
|
||||
// assertEquals(response, result)
|
||||
// }
|
||||
//}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import com.example.hpostesting.data.CsvWriter
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(manifest = Config.NONE)
|
||||
class CsvWriterTest {
|
||||
|
||||
private lateinit var csvWriter: CsvWriter
|
||||
private lateinit var context: Context
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
context = androidx.test.core.app.ApplicationProvider.getApplicationContext()
|
||||
csvWriter = CsvWriter(context)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writeCsv_Success() {
|
||||
// Arrange
|
||||
val fileName = "test.csv"
|
||||
val data = listOf(
|
||||
arrayOf("1", "A", "1990", "Positive", "2024-02-04", "image_url1", "John Doe"),
|
||||
arrayOf("2", "B", "1985", "Negative", "2024-02-05", "image_url2", "Jane Doe")
|
||||
)
|
||||
|
||||
// Act
|
||||
val result = csvWriter.writeCsv(fileName, data)
|
||||
|
||||
// Assert
|
||||
Assert.assertTrue(result)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun writeCsv_Failure() {
|
||||
// // Arrange
|
||||
// val fileName = "test.csv"
|
||||
// val data = listOf(
|
||||
// arrayOf("1", "A", "1990", "Positive", "2024-02-04", "image_url1", "John Doe"),
|
||||
// arrayOf("2", "B", "1985", "Negative", "2024-02-05", "image_url2", "Jane Doe")
|
||||
// )
|
||||
//
|
||||
// // Mocking Environment.getExternalStorageDirectory()
|
||||
// val mockFile = Mockito.mock(File::class.java)
|
||||
// Mockito.`when`(Environment.getExternalStorageDirectory()).thenReturn(mockFile)
|
||||
// Mockito.`when`(mockFile.exists()).thenReturn(true)
|
||||
//
|
||||
// // Mocking FileWriter to simulate IOException
|
||||
// val mockWriter = Mockito.mock(FileWriter::class.java)
|
||||
// Mockito.`when`(mockWriter.write(Mockito.anyString())).thenThrow(IOException::class.java)
|
||||
// Mockito.`when`(mockFile.absolutePath).thenReturn("/fake/path/to/file.csv")
|
||||
// Mockito.`when`(FileWriter(mockFile)).thenReturn(mockWriter)
|
||||
//
|
||||
// // Act
|
||||
// val result = csvWriter.writeCsv(fileName, data)
|
||||
//
|
||||
// // Assert
|
||||
// Assert.assertFalse("Expected writeCsv to fail", result)
|
||||
// }
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceViewModel
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class DeviceViewModelTest {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
@Mock
|
||||
private lateinit var hemoCubeDao: HemoCubeDao
|
||||
|
||||
@Mock
|
||||
private lateinit var repository: Repository
|
||||
|
||||
@Mock
|
||||
private lateinit var context: Context
|
||||
|
||||
private lateinit var viewModel: DeviceViewModel
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
viewModel = DeviceViewModel(hemoCubeDao, repository)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test initial state`() {
|
||||
assert(!viewModel.isServiceConnected)
|
||||
assert(!viewModel.progressBar.value!!)
|
||||
assert(viewModel.messages.value == null)
|
||||
// assert(viewModel.allUserData == hemoCubeDao.getAll())
|
||||
// assert(viewModel.deviceData.value == null)
|
||||
// assert(viewModel.networkStatusLiveData.value == false)
|
||||
assert(viewModel.fireBaseUpload.value == null)
|
||||
}
|
||||
|
||||
// Add more tests for other functions and interactions as needed
|
||||
}
|
||||
@@ -318,28 +318,28 @@ class HemoCubeFragmentTest {
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.22
|
||||
val ratio = 0.25
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||
val ratio = 0.235
|
||||
val ratio = 0.31
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.25
|
||||
val ratio = 0.34
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.31
|
||||
val ratio = 0.37
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
@@ -357,46 +357,4 @@ class HemoCubeFragmentTest {
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Invalid", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsNegativeBorderlineRepeatTest() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline, Repeat Test", 70.0)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 70.0)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||
assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
//
|
||||
//class LogFileManagerImplTest {
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var mockContext: Context
|
||||
//
|
||||
// private lateinit var logFileManager: LogFileManagerImpl
|
||||
//
|
||||
// @Before
|
||||
// fun setUp() {
|
||||
// mockContext = mock()
|
||||
// logFileManager = LogFileManagerImpl(mockContext)
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// fun testCreateLogFileSuccess() {
|
||||
// // Mock filesDir
|
||||
// whenever(mockContext.getString(R.string.app_name)).thenReturn("MockedAppName")
|
||||
// val mockFilesDir = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
//
|
||||
// // Set expected file name
|
||||
// val expectedFileName = "hpos_1234567890.log"
|
||||
// val currentTime = System.currentTimeMillis() / 1000L
|
||||
// doReturn(true).whenever(mockFilesDir).createNewFile(expectedFileName)
|
||||
// doReturn(mockFilesDir.absolutePath + File.separator + expectedFileName).whenever(mockFilesDir).absolutePath
|
||||
//
|
||||
// // Mock FileOutputStream
|
||||
// val mockFileOutputStream = mock<FileOutputStream>()
|
||||
// doReturn(mockFileOutputStream).whenever(FileOutputStream(mockFilesDir.absolutePath + File.separator + expectedFileName))
|
||||
//
|
||||
// // Call createLogFile and verify result
|
||||
// val logFile = logFileManager.createLogFile()
|
||||
//
|
||||
// assertNotNull(logFile)
|
||||
// assertTrue(logFile.exists())
|
||||
// assertEquals(expectedFileName, logFile.name)
|
||||
//
|
||||
// // Verify FileOutputStream was called
|
||||
// verify(mockFileOutputStream).write(any())
|
||||
// verify(mockFileOutputStream).close()
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testCreateLogFileExistingFile() throws IOException {
|
||||
// // Mock filesDir with existing file
|
||||
// val mockFilesDir = mock<File>()
|
||||
// val existingFile = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
// doReturn(true).whenever(mockFilesDir).exists()
|
||||
// doReturn(listOf(existingFile)).whenever(mockFilesDir).listFiles()
|
||||
//
|
||||
// // Call createLogFile and expect exception
|
||||
// try {
|
||||
// logFileManager.createLogFile()
|
||||
// fail("Expected IOException due to existing file")
|
||||
// } catch (e: IOException) {
|
||||
// // Expected behavior
|
||||
// }
|
||||
//
|
||||
// // Verify FileOutputStream was not called
|
||||
// verify(mockFilesDir, times(0)).createNewFile(anyString())
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testCreateLogFileIOException() throws IOException {
|
||||
// // Mock filesDir and IOException
|
||||
// val mockFilesDir = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
// doReturn(true).whenever(mockFilesDir).exists()
|
||||
// doThrow(IOException("Mock IOException")).whenever(mockFilesDir).createNewFile(anyString())
|
||||
//
|
||||
// // Call createLogFile and expect null result
|
||||
// val logFile = logFileManager.createLogFile()
|
||||
//
|
||||
// assertNull(logFile)
|
||||
//
|
||||
// // Verify FileOutputStream was not called
|
||||
// verify(mockFilesDir, times(0)).createNewFile(anyString())
|
||||
// }
|
||||
//}
|
||||
@@ -1,350 +0,0 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.example.hpostesting.presentation.trueheme.TrueHemeFragment
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class TrueHemeFragmentTest {
|
||||
|
||||
@Mock
|
||||
lateinit var mockContext: Context
|
||||
|
||||
@Mock
|
||||
private lateinit var mockSharedPreferences: SharedPreferences
|
||||
|
||||
private lateinit var fragment: TrueHemeFragment
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
fragment = TrueHemeFragment()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId to get device id`() {
|
||||
// Arrange
|
||||
Mockito.`when`(
|
||||
mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
).thenReturn("dummy_value")
|
||||
|
||||
// Act
|
||||
val deviceId = fragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-9000", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `updateDeviceId in shared pref`() {
|
||||
// Arrange
|
||||
Mockito.`when`(
|
||||
mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
).thenReturn("HPP1-0001")
|
||||
|
||||
// Act
|
||||
val deviceId = mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-0001", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `allReadingsComplete check`() {
|
||||
// Arrange
|
||||
val repeatReadingCount = 1
|
||||
val readingsPerSample = 1
|
||||
|
||||
// Act
|
||||
val result = fragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals(true, result)
|
||||
TestCase.assertEquals(fragment.allReadingsComplete(0, 1), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return hardware ID when input contains SN`() {
|
||||
// Arrange
|
||||
val input = "Some text SN ABC123 some more text"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("ABC123", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input does not contain SN`() {
|
||||
// Arrange
|
||||
val input = "Some text without SN"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input is empty`() {
|
||||
// Arrange
|
||||
val input = ""
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input is null`() {
|
||||
// Arrange
|
||||
val input: String? = null
|
||||
|
||||
// Act
|
||||
val result = input?.let { fragment.extractV1HardwareId(it) }
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return hardware ID when input contains SN in a specific format`() {
|
||||
// Arrange
|
||||
val input = """
|
||||
SN HCV-000-3001
|
||||
#BS
|
||||
#BC
|
||||
#SS
|
||||
#SC
|
||||
RESULT
|
||||
LB1 20636.32
|
||||
LB2 15855.67
|
||||
LB3 21801.36
|
||||
LB4 18362.33
|
||||
LS1 17287
|
||||
LS2 14855.67
|
||||
LS3 15282.31
|
||||
LS4 9737.98
|
||||
REND
|
||||
""".trimIndent()
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HCV-000-3001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should return the correct hardware ID when it exists in the input`() {
|
||||
// Arrange
|
||||
val input = "SNS ABC123 SNE"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("ABC123", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should return null when no hardware ID is found in the input`() {
|
||||
// Arrange
|
||||
val input = "No hardware ID in this input"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle whitespace around the hardware ID`() {
|
||||
// Arrange
|
||||
val input = "SNS XYZ789 SNE"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("XYZ789", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HCV-000-3013`() {
|
||||
// Arrange
|
||||
val input = "SNS HCV-000-3013 SNE\n" +
|
||||
"#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT \n" +
|
||||
"LB1 23411.00\n" +
|
||||
"LB2 21417.00\n" +
|
||||
"LB3 23869.00\n" +
|
||||
"LB4 24967.00\n" +
|
||||
"LS1 3401.00\n" +
|
||||
"LS2 1107.00\n" +
|
||||
"LS3 14410.00\n" +
|
||||
"LS4 15047.00\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HCV-000-3013", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP1-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP1-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP1-000-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP1-000-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-000-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP-000-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP-000-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP-000-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP-000-5001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP-000-5001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP-000-5001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.25
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||
val ratio = 0.31
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.34
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.37
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||
val ratio = 0.45
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationInvalid() {
|
||||
val ratio: Double? = null
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Invalid", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user