Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fef75b937 | ||
|
|
42b33c9397 |
@@ -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 101
|
||||
versionName "2.1.101"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -223,26 +223,40 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
Log.e("scannersize",sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
||||
if (mScannerInfoList.isNotEmpty()) {
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
} else {
|
||||
Toast.makeText(this,"Error", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun pullTrigger() {
|
||||
if (!mScannerInfoList[0].isActive) {
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
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.")
|
||||
}
|
||||
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) {
|
||||
val result = String(barcodeData!!)
|
||||
|
||||
@@ -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
|
||||
@@ -805,8 +805,8 @@ 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) {
|
||||
@@ -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 = findResultWithAdditionalMethods(deviceRatio, deviceRatioClass, slopeRatio)
|
||||
hemoCubeViewModel.messages.postValue("${this.classificationResult} ")
|
||||
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 > 60.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.001..0.23) {
|
||||
// setSubtitleTextColor(R.color.green_2)
|
||||
return "Normal"
|
||||
}
|
||||
if (ratio in 0.29..0.32)
|
||||
if (ratio in 0.23..0.24)
|
||||
return "Negative Borderline, Repeat Test"
|
||||
if (ratio in 0.32..0.35)
|
||||
if (ratio in 0.24..0.29)
|
||||
return "Sickle Cell Trait"
|
||||
if (ratio in 0.35..0.38)
|
||||
if (ratio in 0.29..0.32)
|
||||
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||
if (ratio in 0.38..0.5)
|
||||
if (ratio in 0.32..Double.POSITIVE_INFINITY)
|
||||
return "Sickle Cell Disease"
|
||||
} else {
|
||||
return "Invalid"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -318,28 +318,28 @@ 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)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.34
|
||||
val ratio = 0.25
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.37
|
||||
val ratio = 0.31
|
||||
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
@@ -357,4 +357,18 @@ 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_ValidInput_ReturnsDeviceRatioClassToString() {
|
||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)
|
||||
assertEquals("Abnormal", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user