Compare commits
17 Commits
nats_certi
...
2.1.110
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3609d728c1 | ||
|
|
7302ad669f | ||
|
|
ef98b09eaf | ||
|
|
f631a273d7 | ||
|
|
de74da3135 | ||
|
|
37c8dde5bd | ||
|
|
5f460f6aa3 | ||
|
|
ad625992a7 | ||
|
|
db518007b3 | ||
|
|
4d09bad516 | ||
|
|
aad33e3907 | ||
|
|
52279c4419 | ||
|
|
190a72e407 | ||
|
|
4aa6fb020b | ||
|
|
044a545979 | ||
|
|
1f9f8060cb | ||
|
|
4fef75b937 |
@@ -14,13 +14,13 @@ android {
|
||||
compileSdk 34
|
||||
namespace 'in.sminnovations.hpostesting'
|
||||
|
||||
// prod - production, preprod - preproduction, quality - qc, dev - development
|
||||
// dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production
|
||||
defaultConfig {
|
||||
applicationId "in.sminnovations.hpostesting.quality"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 99
|
||||
versionName "2.1.99"
|
||||
versionCode 106
|
||||
versionName "2.1.106"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@@ -157,7 +157,7 @@ dependencies {
|
||||
implementation("com.squareup.okhttp3:okhttp:4.9.3")
|
||||
|
||||
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
|
||||
implementation 'io.nats:jnats:2.11.2'
|
||||
|
||||
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
||||
|
||||
@@ -165,6 +165,4 @@ dependencies {
|
||||
implementation 'com.google.android.play:core:1.10.3'
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.aar'])
|
||||
implementation 'io.nats:jnats:2.11.4'
|
||||
|
||||
}
|
||||
BIN
app/release/hpos-app.apk
Normal file
BIN
app/release/hpos-app.apk
Normal file
Binary file not shown.
@@ -4,15 +4,15 @@
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "in.sminnovations.hpostesting.quality",
|
||||
"applicationId": "com.example.hpos",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 101,
|
||||
"versionName": "2.1.101",
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_dashboard"
|
||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||
android:screenOrientation="portrait"
|
||||
tools:ignore="AppLinkUrlError,MissingClass">
|
||||
|
||||
<intent-filter>
|
||||
@@ -119,9 +120,12 @@
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<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" />
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@@ -161,7 +165,7 @@
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.example.hpostesting.fileprovider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
|
||||
@@ -7,11 +7,8 @@ import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.Multipart
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.PUT
|
||||
@@ -34,10 +31,6 @@ interface MolbioResultApi {
|
||||
@Body deviceUpdateRequest: DeviceUpdateRequest
|
||||
): ResponseBody
|
||||
|
||||
@GET("deviceService/device/getClientCertificate")
|
||||
suspend fun downloadClientCertificate(
|
||||
): ResponseBody
|
||||
|
||||
@Multipart
|
||||
@POST("deviceService/device/uploadLogs")
|
||||
suspend fun uploadLogs(
|
||||
|
||||
@@ -8,7 +8,7 @@ object Constants {
|
||||
|
||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||
|
||||
const val MOLBIO_INTERGATION = false
|
||||
const val MOLBIO_INTEGRATION = false
|
||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||
const val DEVICE_ID_API = "deviceIDAPI"
|
||||
|
||||
@@ -5,5 +5,8 @@ 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 = ""
|
||||
)
|
||||
@@ -77,9 +77,6 @@ class DatabaseRepository @Inject constructor(
|
||||
return safeApiCall { molbioResultApi.deviceUpdate(deviceUpdateRequest) }
|
||||
}
|
||||
|
||||
override suspend fun downloadClientCertificate(): Result<ResponseBody> {
|
||||
return safeApiCall { molbioResultApi.downloadClientCertificate() }
|
||||
}
|
||||
override suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse> {
|
||||
return safeApiCall { molbioResultApi.uploadLogs(logFile) }
|
||||
}
|
||||
|
||||
@@ -45,6 +45,5 @@ interface Repository {
|
||||
|
||||
suspend fun deviceUpdate(deviceUpdateRequest: DeviceUpdateRequest): Result<ResponseBody>
|
||||
|
||||
suspend fun downloadClientCertificate(): Result<ResponseBody>
|
||||
suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse>
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.example.hpostesting.presentation
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import io.nats.client.AuthHandler
|
||||
import io.nats.client.Connection
|
||||
@@ -11,21 +8,10 @@ import io.nats.client.Message
|
||||
import io.nats.client.NKey
|
||||
import io.nats.client.Nats
|
||||
import io.nats.client.Options
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import io.nats.client.support.SSLUtils
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.Paths
|
||||
import java.security.GeneralSecurityException
|
||||
import java.security.KeyStore
|
||||
import java.security.SecureRandom
|
||||
import java.security.cert.CertificateFactory
|
||||
import javax.net.ssl.KeyManager
|
||||
import javax.net.ssl.KeyManagerFactory
|
||||
import javax.net.ssl.SSLContext
|
||||
import javax.net.ssl.TrustManager
|
||||
import javax.net.ssl.TrustManagerFactory
|
||||
|
||||
|
||||
class NatsManager(datacollector: DashboardActivity) {
|
||||
@@ -35,57 +21,18 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
val datacollector = datacollector
|
||||
var connect = false
|
||||
|
||||
private fun createSSLContext(): SSLContext {
|
||||
val keyStorePassword = "prime24".toCharArray() // Change as necessary
|
||||
val clientCertPath = "/storage/sdcard0/Download/client.p12"
|
||||
|
||||
// Load client certificate and key
|
||||
val keyStore = KeyStore.getInstance("PKCS12")
|
||||
FileInputStream(clientCertPath).use { keyStoreInputStream ->
|
||||
keyStore.load(keyStoreInputStream, keyStorePassword)
|
||||
}
|
||||
val caCertPath = "/storage/sdcard0/Android/data/in.sminnovations.hpostesting.quality/files/NATS/clientCertificate/client-cert.pem"
|
||||
val caCert = FileInputStream(caCertPath).use { inputStream ->
|
||||
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||
certificateFactory.generateCertificate(inputStream)
|
||||
}
|
||||
|
||||
val trustStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply {
|
||||
load(null, null) // Initialize the keystore
|
||||
setCertificateEntry("caCert", caCert) // Add the CA certificate
|
||||
}
|
||||
|
||||
// Initialize key manager factory
|
||||
val kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
|
||||
kmf.init(keyStore, keyStorePassword)
|
||||
|
||||
// Initialize trust manager factory
|
||||
val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
||||
tmf.init(trustStore)
|
||||
|
||||
// Initialize SSLContext
|
||||
val sslContext = SSLContext.getInstance("TLS")
|
||||
sslContext.init(kmf.keyManagers, tmf.trustManagers, SecureRandom())
|
||||
|
||||
return sslContext
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun connect() {
|
||||
Log.d(TAG, "TRY TO CONNECT")
|
||||
Thread {
|
||||
|
||||
val seedString = "SUAJH5VMO6GDRQA6QTXCLIJMS74IWIUTU3NJVYIOTZF2LBWUPD77DA2ZEA"
|
||||
Log.e("seedString",seedString)
|
||||
val seedString = "SUAEB5PUWNS6C2HUV3MFI6HUDEAPGPFPBHMI73NHIQATCDD2BWALVEZXZ4"
|
||||
val seedBytes = seedString.toCharArray()
|
||||
|
||||
val theNKey = NKey.fromSeed(seedBytes) // really should load from somewhere
|
||||
|
||||
val options = Options.Builder()
|
||||
.server("nats://nanodgx.in:4222")
|
||||
.sslContext(createSSLContext())
|
||||
.sslContext(SSLUtils.createOpenTLSContext())
|
||||
.authHandler(object : AuthHandler {
|
||||
override fun getID(): CharArray? {
|
||||
return try {
|
||||
@@ -123,11 +70,6 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
connect = true
|
||||
datacollector.setConnect(true)
|
||||
|
||||
if (nc?.status == Connection.Status.CONNECTED) {
|
||||
Log.e("NATSCONNECTION", "NATS is successfully connected.")
|
||||
} else {
|
||||
Log.e("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
||||
}
|
||||
|
||||
nc?.publish(
|
||||
"server.hpos.HCV-000-3001.ping",
|
||||
@@ -142,10 +84,9 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
println("PRITIMOI SARKAR $msg")
|
||||
}
|
||||
|
||||
|
||||
d?.subscribe("device.hpos.HCV-000-3001.update") { msg ->
|
||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||
datacollector. setResponse(response)
|
||||
datacollector.setResponse(response)
|
||||
println("Message received (up to 100 times): $response")
|
||||
}
|
||||
|
||||
@@ -176,7 +117,7 @@ class NatsManager(datacollector: DashboardActivity) {
|
||||
} catch (exp: Exception) {
|
||||
println(exp.printStackTrace())
|
||||
connect = false
|
||||
datacollector.setConnect(false)
|
||||
datacollector.setConnect(true)
|
||||
}
|
||||
}.start()
|
||||
|
||||
|
||||
@@ -3,19 +3,14 @@ package com.example.hpostesting.presentation.assurance
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.example.hpostesting.presentation.NatsManager
|
||||
import com.example.hpostesting.presentation.dashboard.IDataCollector
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityAssuranceControlsBinding
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AssuranceControlsActivity: AppCompatActivity(), IDataCollector {
|
||||
class AssuranceControlsActivity: AppCompatActivity() {
|
||||
lateinit var binding: ActivityAssuranceControlsBinding
|
||||
lateinit var sharedPreference: SharedPreferences
|
||||
lateinit var nats: NatsManager
|
||||
var responses: String = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -29,21 +24,5 @@ class AssuranceControlsActivity: AppCompatActivity(), IDataCollector {
|
||||
.replace(binding.fgAssuranceControls.id, AssuranceControlsFragment())
|
||||
.commit()
|
||||
}
|
||||
|
||||
// nats = NatsManager(this)
|
||||
// nats.connect()
|
||||
// nats.pub("server.hpos.HCV-000-3001.ping", "THIS IS A TEST MSG")
|
||||
}
|
||||
|
||||
override fun setConnect(connect: Boolean) {
|
||||
if(connect){
|
||||
Log.i("NATS Connection", connect.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun setResponse(response: String) {
|
||||
|
||||
responses = responses+response+"\n"
|
||||
println(responses)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ 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
|
||||
@@ -30,6 +31,9 @@ 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
|
||||
}
|
||||
|
||||
@@ -42,7 +46,7 @@ class AssuranceControlsFragment: Fragment() {
|
||||
// binding.btnSubmit.visibility = View.GONE
|
||||
|
||||
val solutionSpinner: Spinner = binding.spinnerSolutions
|
||||
val solutionOptions = arrayOf("Select solution", "Tartrazine", "AR")
|
||||
val solutionOptions = arrayOf("Select solution", "Tartrazine", "Acid Red")
|
||||
val solutionAdapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, solutionOptions)
|
||||
solutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
solutionSpinner.adapter = solutionAdapter
|
||||
@@ -121,6 +125,13 @@ 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
|
||||
|
||||
@@ -105,8 +105,6 @@ class AutoDacFragment: Fragment() {
|
||||
HemoCubeCommands.AUTO_DAC_COMMAND,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {
|
||||
|
||||
|
||||
}
|
||||
override fun onUsbError(e: Exception?) {
|
||||
autoDacViewModel.progressBar.postValue(false)
|
||||
@@ -148,6 +146,9 @@ class AutoDacFragment: Fragment() {
|
||||
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()
|
||||
@@ -169,7 +170,6 @@ 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>>()
|
||||
|
||||
@@ -156,9 +156,10 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||
val file = File(getExternalFilesDir("Updates"), "update.apk")
|
||||
file.setReadable(true, false) // Ensure the file is readable
|
||||
|
||||
val pInfo = baseContext.packageManager.getPackageInfo(baseContext.packageName, 0)
|
||||
val uri: Uri = FileProvider.getUriForFile(
|
||||
this,
|
||||
"com.example.hpostesting.fileprovider",
|
||||
"${pInfo}.fileprovider",
|
||||
file
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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
|
||||
@@ -14,12 +15,13 @@ 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.deviceprovision.DeviceProvisionActivity
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
||||
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
|
||||
@@ -82,6 +84,19 @@ 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}"
|
||||
|
||||
|
||||
@@ -43,19 +43,11 @@ import com.google.firebase.perf.ktx.performance
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.net.URL
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
@AndroidEntryPoint
|
||||
class HomeFragment : Fragment() {
|
||||
@@ -70,6 +62,7 @@ class HomeFragment : Fragment() {
|
||||
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
||||
|
||||
private var isTokenAvailable = false
|
||||
|
||||
private lateinit var sharedPreference: SharedPreferences
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||
@@ -210,7 +203,7 @@ class HomeFragment : Fragment() {
|
||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||
hemoCubeViewModel.uploadLogs()
|
||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||
hemoCubeViewModel.downloadClientCertificate()
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -220,11 +213,6 @@ class HomeFragment : Fragment() {
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
@@ -279,41 +267,6 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
hemoCubeViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
||||
when (response) {
|
||||
is Result.Success -> {
|
||||
val url = response.data
|
||||
|
||||
val fileName = "nats_certificate.zip"
|
||||
val downloadDirectory = "NATS"
|
||||
val file = downloadFile(url, requireContext(), fileName, downloadDirectory)
|
||||
Toast.makeText(requireContext(), "NATS certificate Downloaded", Toast.LENGTH_SHORT).show()
|
||||
|
||||
val unzipDirectoryPath = requireContext().getExternalFilesDir(null)?.absolutePath + "/$downloadDirectory"
|
||||
unzip(file.absolutePath, unzipDirectoryPath)
|
||||
Toast.makeText(requireContext(), "NATS certificate Extracted", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
is Result.Error -> {
|
||||
response.exception.let { message ->
|
||||
Toast.makeText(
|
||||
activity,
|
||||
"An error occurred in nats download: $message",
|
||||
Toast.LENGTH_LONG
|
||||
)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
is Result.Loading -> {
|
||||
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
@@ -338,11 +291,8 @@ class HomeFragment : Fragment() {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun isTokenExpired(token: String): Boolean {
|
||||
val parts = token.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val decodedPayload = String(Base64.decode(parts[1], Base64.DEFAULT))
|
||||
@@ -392,60 +342,6 @@ class HomeFragment : Fragment() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun downloadFile(responseBody: ResponseBody, context: Context, fileName: String, downloadDirectory: String): File {
|
||||
// Ensure the download directory exists
|
||||
val fileDir = File(context.getExternalFilesDir(null), downloadDirectory)
|
||||
if (!fileDir.exists()) {
|
||||
fileDir.mkdirs()
|
||||
}
|
||||
val file = File(fileDir, fileName)
|
||||
Log.d("Download", "Starting download to $file")
|
||||
responseBody.byteStream().use { inputStream ->
|
||||
FileOutputStream(file).use { outputStream ->
|
||||
inputStream.copyTo(outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
// After download
|
||||
Log.d("Download", "Download completed to ${file.absolutePath}")
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun unzip(zipFilePath: String, destDirectory: String) {
|
||||
val destDir = File(destDirectory)
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdir()
|
||||
}
|
||||
ZipInputStream(FileInputStream(zipFilePath)).use { zipIn ->
|
||||
var entry: ZipEntry? = zipIn.nextEntry
|
||||
while (entry != null) {
|
||||
val filePath = destDirectory + File.separator + entry.name
|
||||
if (!entry.isDirectory) {
|
||||
extractFile(zipIn, filePath)
|
||||
} else {
|
||||
val dir = File(filePath)
|
||||
dir.mkdir()
|
||||
}
|
||||
zipIn.closeEntry()
|
||||
entry = zipIn.nextEntry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractFile(zipIn: ZipInputStream, filePath: String) {
|
||||
BufferedOutputStream(FileOutputStream(filePath)).use { bos ->
|
||||
val bytesIn = ByteArray(4096)
|
||||
var read: Int
|
||||
while (zipIn.read(bytesIn).also { read = it } != -1) {
|
||||
bos.write(bytesIn, 0, read)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUserId() {
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
val userId = binding.userId.text.toString()
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -75,11 +74,6 @@ class DeviceProvisionFragment : Fragment() {
|
||||
Constants.NATS_TOKEN,
|
||||
response.data.data?.device?.deviceUser?.natsToken
|
||||
)
|
||||
response.data.data?.device?.deviceUser?.natsToken?.let {
|
||||
Log.e("natstoken",
|
||||
it
|
||||
)
|
||||
}
|
||||
putString(
|
||||
Constants.NATS_TOKEN_EXPIRE_DATE,
|
||||
response.data.data?.device?.deviceUser?.natsTokenExpiry
|
||||
@@ -120,7 +114,6 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getDeviceId() {
|
||||
(activity as DeviceProvisionActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||
@@ -152,14 +145,19 @@ class DeviceProvisionFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun extractV2HardwareId(input: String): String? {
|
||||
val pattern = Regex("SNS\\s*(.*?)\\s*SNE")
|
||||
val matchResult: MatchResult? = pattern.find(input)
|
||||
|
||||
return matchResult?.groups?.get(1)?.value
|
||||
}
|
||||
|
||||
private fun handleUsbData() {
|
||||
when {
|
||||
resultData.contains("SNE") -> {
|
||||
val pattern = Regex("HPP1-\\d{4}")
|
||||
val matchResult = pattern.find(resultData)
|
||||
val hardwareId = matchResult?.value
|
||||
val hardwareId = extractV2HardwareId(resultData)
|
||||
|
||||
if (hardwareId.toString().length == 9) {
|
||||
if (!hardwareId.isNullOrBlank()) {
|
||||
with(sharedPreferences.edit()) {
|
||||
putString(Constants.DEVICE_ID, hardwareId)
|
||||
apply()
|
||||
|
||||
@@ -148,6 +148,9 @@ 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_INTERGATION) {
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
@@ -643,10 +643,10 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
||||
assignDefaultDevice(resultData)
|
||||
testState.allErrorMessages += "Calibration configuration for this device id is not found\n"
|
||||
// testState.allErrorMessages += "Calibration configuration for this device id is not found\n"
|
||||
}
|
||||
if (!Constants.BUFFER_INTENSITY_THRESHOLDS.containsKey(deviceHardwareId)) {
|
||||
testState.allErrorMessages += "ADC thresholds for this device id are not found\n"
|
||||
// testState.allErrorMessages += "ADC thresholds for this device id are not found\n"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,9 +743,9 @@ class HemoCubeFragment : Fragment() {
|
||||
)?.get(0)!!
|
||||
) {
|
||||
// validationError = true
|
||||
testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (low)"
|
||||
// testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (low)"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = getString(R.string.error_improper_buffer_low)
|
||||
// binding.errorMessage.text = getString(R.string.error_improper_buffer_low)
|
||||
// binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
@@ -763,11 +763,11 @@ class HemoCubeFragment : Fragment() {
|
||||
)?.get(1)!!
|
||||
) {
|
||||
// validationError = true
|
||||
testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
||||
// testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text =
|
||||
// binding.errorMessage.text =
|
||||
getString(R.string.error_improper_buffer_high)
|
||||
binding.errorMessage.visibility = View.VISIBLE
|
||||
// binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,15 +805,15 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
calculatedPredictedDenovixRatio = fittedAbs3.div(fittedAbs1)
|
||||
|
||||
val slope = (led1Average - led2Average) / (435 - 415)
|
||||
val calculatedSlopeRatio = abs(led3Average / slope)
|
||||
val slope = (led4Average - led1Average) / (431-411)
|
||||
val calculatedSlopeRatio = abs(led2Average / slope)
|
||||
val slopeClass = slopeRatioClassification(calculatedSlopeRatio)
|
||||
|
||||
if (fittedAbs1 <= fittedAbs2) {
|
||||
// validationError = true
|
||||
testState.allErrorMessages += "Error: Invalid Test. Problem with de-oxygenation" + "\n"
|
||||
// testState.allErrorMessages += "Error: Invalid Test. Problem with de-oxygenation" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = getString(R.string.error_invalid_test)
|
||||
// binding.errorMessage.text = getString(R.string.error_invalid_test)
|
||||
// binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
@@ -837,9 +837,9 @@ class HemoCubeFragment : Fragment() {
|
||||
|
||||
if (fittedAbs3 < 0.1) {
|
||||
// validationError = true
|
||||
testState.allErrorMessages += "Error: Low Hb. Repeat test" + "\n"
|
||||
// testState.allErrorMessages += "Error: Low Hb. Repeat test" + "\n"
|
||||
activity?.runOnUiThread {
|
||||
binding.errorMessage.text = "Error: Low Hb. Repeat test"
|
||||
// binding.errorMessage.text = "Error: Low Hb. Repeat test"
|
||||
// binding.errorMessage.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
@@ -874,8 +874,8 @@ class HemoCubeFragment : Fragment() {
|
||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||
this.slopeRatioClass = slopeClass
|
||||
this.classificationResult = deviceRatioClass //findResult(calculatedRatio)
|
||||
hemoCubeViewModel.messages.postValue("${this.deviceRatioClass} ${if (led4Average < 0.17) " - Low Hb" else ""}\n")
|
||||
this.classificationResult = deviceRatioClass
|
||||
hemoCubeViewModel.messages.postValue("${this.classificationResult} \n Device Ratio: ${"%.3f".format(this.deviceRatio)}")
|
||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||
this.errorMessages = testState.allErrorMessages
|
||||
@@ -909,50 +909,36 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
fun findResult(calculatedRatio: Double?): String {
|
||||
fun findResultWithAdditionalMethods(deviceRatio: Double?, deviceRatioClass: String?, slopeRatio: Double?): String {
|
||||
try {
|
||||
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)
|
||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||
if (deviceRatio != null) {
|
||||
if (slopeRatio != null) {
|
||||
if (deviceRatioClass == "Normal" && slopeRatio > 45.0)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
}
|
||||
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) {
|
||||
showToast(R.string.error_classification)
|
||||
Firebase.crashlytics.recordException(e)
|
||||
return getString(R.string.error)
|
||||
handleException(e)
|
||||
return "Error"
|
||||
}
|
||||
return getString(R.string.invalid)
|
||||
return deviceRatioClass.toString()
|
||||
}
|
||||
|
||||
fun deviceRatioClassification(ratio: Double?): String {
|
||||
try {
|
||||
if (ratio != null) {
|
||||
if (ratio in 0.1..0.29) {
|
||||
if (ratio in 0.016..0.22) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in 0.29..0.32)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
if (ratio in 0.32..0.35)
|
||||
if (ratio in 0.22..0.24)
|
||||
return "Negative Borderline"
|
||||
if (ratio in 0.24..0.32)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.35..0.38)
|
||||
if (ratio in 0.32..0.37)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
if (ratio in 0.38..0.5)
|
||||
if (ratio in 0.37..0.56)
|
||||
return "Sickle Cell Disease"
|
||||
} else {
|
||||
return "Invalid"
|
||||
|
||||
@@ -79,7 +79,6 @@ class HemoCubeViewModel @Inject constructor(
|
||||
val checkUpdate = MutableLiveData<Result<CheckUpdateResponse>>()
|
||||
|
||||
val deviceUpdate = MutableLiveData<Result<ResponseBody>>()
|
||||
val downloadcertificate = MutableLiveData<Result<ResponseBody>>()
|
||||
|
||||
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
||||
|
||||
@@ -142,9 +141,6 @@ class HemoCubeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
||||
checkUpdate.postValue(Result.Loading())
|
||||
repository.checkUpdate(checkUpdateRequest).let {
|
||||
@@ -159,17 +155,6 @@ class HemoCubeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun downloadClientCertificate() = viewModelScope.launch {
|
||||
downloadcertificate.postValue(Result.Loading())
|
||||
repository.downloadClientCertificate().let {
|
||||
downloadcertificate.postValue(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun startPeriodicCheckUpdate() {
|
||||
val periodicRequest = PeriodicWorkRequestBuilder<CheckUpdateWorker>(
|
||||
repeatInterval = 1, repeatIntervalTimeUnit = TimeUnit.MINUTES
|
||||
|
||||
@@ -156,7 +156,7 @@ class TrueHemeFragment : Fragment() {
|
||||
when (it) {
|
||||
is Result.Success -> {
|
||||
uploadedToMolbio = true
|
||||
if (Constants.MOLBIO_INTERGATION) {
|
||||
if (Constants.MOLBIO_INTEGRATION) {
|
||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||
hemoCubeViewModel.updateMolbioFlag(
|
||||
it1._id
|
||||
|
||||
5
app/src/main/res/drawable/downloads.xml
Normal file
5
app/src/main/res/drawable/downloads.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<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,4 +108,33 @@
|
||||
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,6 +115,8 @@
|
||||
<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>
|
||||
|
||||
@@ -318,21 +318,21 @@ class HemoCubeFragmentTest {
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.25
|
||||
val ratio = 0.22
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||
val ratio = 0.31
|
||||
val ratio = 0.235
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Negative Borderline, Repeat Test", result)
|
||||
assertEquals("Negative Borderline", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.34
|
||||
val ratio = 0.25
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
@@ -357,4 +357,46 @@ 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user